Skip to content

Commit

Permalink
Setup Blimp internal string resources.
Browse files Browse the repository at this point in the history
Previously the 0.6 Chrome/Blimp integrated build still use strings in
//blimp/client/app, which also only generates android strings files.

This CL:
1. Setup strings resources in //blimp/client/core, all core code won't
use app resources anymore.

2. Internal core strings are protected behind the build flag
|enable_blimp_client|, so normal Chrome build won't contain Blimp
internal strings. Also the build flag is only used in
//blimp/client/core build files.

3. The Blimp linux shell only loads the English string pak file. Unit
tests and 0.5 app currently don't depends on the new core strings.

Clean resources bug.
BUG=630687

Decouple app and core code bug.
BUG=651964

Review-Url: https://codereview.chromium.org/2431653004
Cr-Commit-Position: refs/heads/master@{#431484}
  • Loading branch information
xingliu authored and Commit bot committed Nov 11, 2016
1 parent 24879bd commit 7d4d7a5
Show file tree
Hide file tree
Showing 76 changed files with 2,993 additions and 59 deletions.
1 change: 1 addition & 0 deletions blimp/client/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ include_rules = [
"+ui/android",
"+ui/base/ime/text_input_type.h",
"+ui/base/l10n",
"+ui/base/resource",
"+ui/events",
"+ui/events/android",
"+ui/events/blink",
Expand Down
17 changes: 17 additions & 0 deletions blimp/client/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# found in the LICENSE file.

import("//build/config/ui.gni")
import("//tools/grit/repack.gni")

if (is_android) {
import("//build/config/android/config.gni")
Expand Down Expand Up @@ -51,6 +52,7 @@ source_set("app") {
"//gpu/skia_bindings",
"//net",
"//third_party/libwebp",
"//ui/base:base",
"//ui/gfx/geometry",
"//ui/gl",
"//ui/gl/init",
Expand Down Expand Up @@ -140,8 +142,10 @@ if (is_linux && !is_chromeos && use_x11) {

deps = [
":app",
":shell_strings",
"//base",
"//blimp/client/core/compositor",
"//blimp/client/core/resources",
"//blimp/client/core/session",
"//blimp/client/core/settings:settings",
"//blimp/net",
Expand All @@ -166,6 +170,19 @@ if (is_linux && !is_chromeos && use_x11) {
}
}

# Resources file for linux shell.
repack("shell_strings") {
sources = [
"$root_gen_dir/blimp/client/core/resources/blimp_strings_en-US.pak",
]

deps = [
"//blimp/client/public/resources:shell_strings",
]

output = "$root_out_dir/blimp_shell.pak"
}

if (is_android) {
declare_args() {
# Package name used in the manifest for the Blimp APK.
Expand Down
10 changes: 10 additions & 0 deletions blimp/client/app/blimp_startup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "blimp/client/app/blimp_discardable_memory_allocator.h"
#include "blimp/client/core/compositor/decoding_image_generator.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gl/init/gl_factory.h"

class SkImageGenerator;
Expand Down Expand Up @@ -81,5 +82,14 @@ bool InitializeMainMessageLoop() {
return true;
}

void InitializeResourceBundle() {
// Load the pak file for the shell.
base::FilePath pak_file;
bool pak_file_valid = base::PathService::Get(base::DIR_MODULE, &pak_file);
CHECK(pak_file_valid);
pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_shell.pak"));
ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
}

} // namespace client
} // namespace blimp
2 changes: 2 additions & 0 deletions blimp/client/app/blimp_startup.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ void InitializeLogging();

bool InitializeMainMessageLoop();

void InitializeResourceBundle();

} // namespace client
} // namespace blimp

Expand Down
50 changes: 7 additions & 43 deletions blimp/client/app/linux/blimp_client_context_delegate_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "base/memory/ptr_util.h"
#include "blimp/client/app/linux/blimp_client_context_delegate_linux.h"
#include "blimp/client/public/resources/blimp_strings.h"
#include "blimp/client/support/session/blimp_default_identity_provider.h"
#include "net/base/net_errors.h"

Expand All @@ -20,48 +21,10 @@ void BlimpClientContextDelegateLinux::AttachBlimpContentsHelpers(
void BlimpClientContextDelegateLinux::OnAssignmentConnectionAttempted(
AssignmentRequestResult result,
const Assignment& assignment) {
// TODO(xingliu): Update this to use the new error strings and logging helper
// methods, and access the string from grd files. https://crbug.com/630687
switch (result) {
case AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_OK:
VLOG(0) << "Assignment request success";
break;
case AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_UNKNOWN:
LOG(WARNING) << "Assignment request result unknown";
break;
case AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_BAD_REQUEST:
LOG(WARNING) << "Assignment request error: Bad request";
break;
case AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_BAD_RESPONSE:
LOG(WARNING) << "Assignment request error: Bad response";
break;
case AssignmentRequestResult::
ASSIGNMENT_REQUEST_RESULT_INVALID_PROTOCOL_VERSION:
LOG(WARNING) << "Assignment request error: Invalid protocol version";
break;
case AssignmentRequestResult::
ASSIGNMENT_REQUEST_RESULT_EXPIRED_ACCESS_TOKEN:
LOG(WARNING) << "Assignment request error: Expired access token";
break;
case AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_USER_INVALID:
LOG(WARNING) << "Assignment request error: User invalid";
break;
case AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_OUT_OF_VMS:
LOG(WARNING) << "Assignment request error: Out of VMs";
break;
case AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_SERVER_ERROR:
LOG(WARNING) << "Assignment request error: Server error";
break;
case AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_SERVER_INTERRUPTED:
LOG(WARNING) << "Assignment request error: Server interrupted";
break;
case AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_NETWORK_FAILURE:
LOG(WARNING) << "Assignment request error: Network failure";
break;
case AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_INVALID_CERT:
LOG(WARNING) << "Assignment request error: Invalid cert";
break;
}
if (result == ASSIGNMENT_REQUEST_RESULT_OK)
return;

LOG(WARNING) << string::AssignmentResultErrorToString(result);
}

std::unique_ptr<IdentityProvider>
Expand All @@ -79,7 +42,8 @@ void BlimpClientContextDelegateLinux::OnConnected() {
}

void BlimpClientContextDelegateLinux::OnEngineDisconnected(int result) {
LOG(WARNING) << "Disconnected from the engine, reason: " << result;
LOG(WARNING) << "Disconnected from the engine, reason: "
<< string::EndConnectionMessageToString(result);
}

void BlimpClientContextDelegateLinux::OnNetworkDisconnected(int result) {
Expand Down
1 change: 1 addition & 0 deletions blimp/client/app/linux/blimp_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ int main(int argc, const char**argv) {

blimp::client::InitializeLogging();
blimp::client::InitializeMainMessageLoop();
blimp::client::InitializeResourceBundle();

base::Thread io_thread("BlimpIOThread");
base::Thread::Options options;
Expand Down
2 changes: 2 additions & 0 deletions blimp/client/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ group("core") {
"//blimp/client/core/feedback",
"//blimp/client/core/geolocation",
"//blimp/client/core/render_widget",
"//blimp/client/core/resources",
"//blimp/client/core/session",
"//blimp/client/core/settings",
"//blimp/client/core/switches",
Expand All @@ -52,6 +53,7 @@ group("dummy_core") {

deps = [
"//blimp/client/core/context:dummy",
"//blimp/client/core/resources:dummy",
]
}

Expand Down
2 changes: 1 addition & 1 deletion blimp/client/core/contents/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ if (is_android) {

deps = [
"//base:base_java",
"//blimp/client/app:blimp_java_resources",
"//blimp/client/core/resources:java_resources",
"//blimp/client/public:public_headers_java",
"//third_party/android_tools:android_support_v7_appcompat_java",
"//ui/android:ui_java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.blimp.R;
import org.chromium.blimp.core.R;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.base.ime.TextInputType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import android.widget.ProgressBar;
import android.widget.RelativeLayout;

import org.chromium.blimp.R;
import org.chromium.blimp.core.R;

/**
* A layout containing OK, Cancel buttons and a progress spinner which can be included at the bottom
Expand Down
Loading

0 comments on commit 7d4d7a5

Please sign in to comment.