Skip to content

Commit

Permalink
content: Modfiy ResourceBundle and content_shell to run with alternat…
Browse files Browse the repository at this point in the history
…ive pak files.

BUG=111326
R=jam
TBR=sky,tony,ajwong,ananta

Review URL: http://codereview.chromium.org/9232060

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119566 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
erg@chromium.org committed Jan 28, 2012
1 parent e643e57 commit 70f9df1
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 34 deletions.
2 changes: 1 addition & 1 deletion ash/shell/shell_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace shell {
void PreMainMessageLoopStart() {
ui::RegisterPathProvider();
icu_util::Initialize();
ResourceBundle::InitSharedInstance("en-US");
ResourceBundle::InitSharedInstanceWithLocale("en-US");
}

} // namespace ash
Expand Down
2 changes: 1 addition & 1 deletion ash/shell/shell_main_parts_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
void PreMainMessageLoopStart() {
ui::RegisterPathProvider();
icu_util::Initialize();
ResourceBundle::InitSharedInstance("en-US");
ResourceBundle::InitSharedInstanceWithLocale("en-US");

scoped_nsobject<NSNib>
nib([[NSNib alloc] initWithNibNamed:@"MainMenu"
Expand Down
2 changes: 1 addition & 1 deletion ash/test/test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void AuraShellTestSuite::Initialize() {

// Force unittests to run using en-US so if we test against string
// output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstance("en-US");
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US");
ui::CompositorTestSupport::Initialize();
ui::SetupTestCompositor();
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/app/chrome_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
const std::string locale =
command_line.GetSwitchValueASCII(switches::kLang);
const std::string loaded_locale =
ResourceBundle::InitSharedInstance(locale);
ResourceBundle::InitSharedInstanceWithLocale(locale);
CHECK(!loaded_locale.empty()) << "Locale could not be found for " <<
locale;

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() {
// On a POSIX OS other than ChromeOS, the parameter that is passed to the
// method InitSharedInstance is ignored.
const std::string loaded_locale =
ResourceBundle::InitSharedInstance(locale);
ResourceBundle::InitSharedInstanceWithLocale(locale);
if (loaded_locale.empty() &&
!parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) {
ShowMissingLocaleMessageBox();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main_extra_parts_gtk.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -34,7 +34,7 @@ void ChromeBrowserMainExtraPartsGtk::DetectRunningAsRoot() {
// Get just enough of our resource machinery up so we can extract the
// locale appropriate string. Note that the GTK implementation ignores the
// passed in parameter and checks the LANG environment variables instead.
ResourceBundle::InitSharedInstance("");
ResourceBundle::InitSharedInstanceWithLocale("");

std::string message = l10n_util::GetStringFUTF8(
IDS_REFUSE_TO_RUN_AS_ROOT,
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_browser_main_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int DoUninstallTasks(bool chrome_still_running) {
// TODO(markusheintz): Read preference pref::kApplicationLocale in order
// to enforce the application locale.
const std::string loaded_locale =
ResourceBundle::InitSharedInstance(std::string());
ResourceBundle::InitSharedInstanceWithLocale(std::string());
CHECK(!loaded_locale.empty()) << "Default locale could not be found";

FilePath resources_pack_path;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/diagnostics/diagnostics_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class TestController : public DiagnosticsModel::Observer {
writer_->WriteResult(false, L"Diagnostics start", L"ICU failure");
return;
}
ResourceBundle::InitSharedInstance("");
ResourceBundle::InitSharedInstanceWithLocale("");
int count = model->GetTestAvailableCount();
writer_->WriteInfoText(base::StringPrintf(
L"%d available test(s)\n\n", count));
Expand Down
2 changes: 1 addition & 1 deletion chrome/service/service_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ bool ServiceProcess::Initialize(MessageLoopForUI* message_loop,
if (locale.empty())
locale = kDefaultServiceProcessLocale;
}
ResourceBundle::InitSharedInstance(locale);
ResourceBundle::InitSharedInstanceWithLocale(locale);

PrepareRestartOnCrashEnviroment(command_line);

Expand Down
2 changes: 1 addition & 1 deletion chrome/test/base/chrome_test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void ChromeTestSuite::Initialize() {

// Force unittests to run using en-US so if we test against string
// output, it'll pass regardless of the system language.
ResourceBundle::InitSharedInstance("en-US");
ResourceBundle::InitSharedInstanceWithLocale("en-US");
FilePath resources_pack_path;
PathService::Get(base::DIR_MODULE, &resources_pack_path);
resources_pack_path =
Expand Down
4 changes: 2 additions & 2 deletions chrome/tools/profiles/generate_profile.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -234,7 +234,7 @@ int main(int argc, const char* argv[]) {

chrome::RegisterPathProvider();
ui::RegisterPathProvider();
ResourceBundle::InitSharedInstance("en-US");
ResourceBundle::InitSharedInstanceWithLocale("en-US");
scoped_ptr<content::NotificationService> notification_service(
content::NotificationService::Create());
MessageLoopForUI message_loop;
Expand Down
2 changes: 1 addition & 1 deletion chrome_frame/test/net/fake_external_tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ void FakeExternalTab::Initialize() {
DCHECK(res_mod);
_AtlBaseModule.SetResourceInstance(res_mod);

ResourceBundle::InitSharedInstance("en-US");
ResourceBundle::InitSharedInstanceWithLocale("en-US");

CommandLine* cmd = CommandLine::ForCurrentProcess();
cmd->AppendSwitch(switches::kDisableWebResources);
Expand Down
8 changes: 2 additions & 6 deletions content/shell/shell_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ void ShellMainDelegate::InitializeShellContentClient(
void ShellMainDelegate::InitializeResourceBundle() {
FilePath pak_dir;
PathService::Get(base::DIR_MODULE, &pak_dir);
PathService::Override(ui::FILE_RESOURCES_PAK,
pak_dir.Append(
FILE_PATH_LITERAL("content_shell.pak")));

// Force the content shell to run using en-US because our ResourceBundle
// can't run without a language and it doesn't matter.
ui::ResourceBundle::InitSharedInstance("en-US");
FilePath pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
ui::ResourceBundle::InitSharedInstanceWithPakFile(pak_file);
}
2 changes: 1 addition & 1 deletion ui/aura/demo/demo_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int main(int argc, char** argv) {

ui::RegisterPathProvider();
icu_util::Initialize();
ResourceBundle::InitSharedInstance("en-US");
ResourceBundle::InitSharedInstanceWithLocale("en-US");

// Create the message-loop here before creating the root window.
MessageLoop message_loop(MessageLoop::TYPE_UI);
Expand Down
2 changes: 1 addition & 1 deletion ui/aura/test/test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void AuraTestSuite::Initialize() {

// Force unittests to run using en-US so if we test against string
// output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstance("en-US");
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US");
ui::CompositorTestSupport::Initialize();

ui::SetupTestCompositor();
Expand Down
4 changes: 2 additions & 2 deletions ui/base/resource/resource_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const SkColor ResourceBundle::toolbar_separator_color =
SkColorSetRGB(182, 186, 192);

// static
std::string ResourceBundle::InitSharedInstance(
std::string ResourceBundle::InitSharedInstanceWithLocale(
const std::string& pref_locale) {
DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice";
g_shared_instance_ = new ResourceBundle();
Expand All @@ -59,7 +59,7 @@ std::string ResourceBundle::InitSharedInstance(
}

// static
void ResourceBundle::InitSharedInstanceForTest(const FilePath& path) {
void ResourceBundle::InitSharedInstanceWithPakFile(const FilePath& path) {
DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice";
g_shared_instance_ = new ResourceBundle();

Expand Down
5 changes: 3 additions & 2 deletions ui/base/resource/resource_bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ class UI_EXPORT ResourceBundle {
// selected.
// NOTE: Mac ignores this and always loads up resources for the language
// defined by the Cocoa UI (ie-NSBundle does the langange work).
static std::string InitSharedInstance(const std::string& pref_locale);
static std::string InitSharedInstanceWithLocale(
const std::string& pref_locale);

// Initialize the ResourceBundle using given data pack path for testing.
static void InitSharedInstanceForTest(const FilePath& path);
static void InitSharedInstanceWithPakFile(const FilePath& path);

// Load a .pak file. Returns NULL if we fail to load |path|. The caller
// is responsible for deleting up this pointer.
Expand Down
2 changes: 1 addition & 1 deletion ui/gfx/test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void GfxTestSuite::Initialize() {

// Force unittests to run using en-US so if we test against string
// output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstance("en-US");
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US");
}

void GfxTestSuite::Shutdown() {
Expand Down
2 changes: 1 addition & 1 deletion ui/views/examples/examples_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int main(int argc, char** argv) {
ui::RegisterPathProvider();
bool icu_result = icu_util::Initialize();
CHECK(icu_result);
ui::ResourceBundle::InitSharedInstance("en-US");
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US");

MessageLoop main_message_loop(MessageLoop::TYPE_UI);

Expand Down
2 changes: 1 addition & 1 deletion ui/views/run_all_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ViewTestSuite : public base::TestSuite {
base::TestSuite::Initialize();

ui::RegisterPathProvider();
ui::ResourceBundle::InitSharedInstance("en-US");
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US");

ui::CompositorTestSupport::Initialize();
ui::SetupTestCompositor();
Expand Down
4 changes: 2 additions & 2 deletions webkit/support/platform_support_android.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -29,7 +29,7 @@ void AfterInitialize(bool unit_test_mode) {
FilePath data_path;
PathService::Get(base::DIR_EXE, &data_path);
data_path = data_path.Append("DumpRenderTree.pak");
ResourceBundle::InitSharedInstanceForTest(data_path);
ResourceBundle::InitSharedInstanceWithPakFile(data_path);

// We enable file-over-http to bridge the file protocol to http protocol
// in here, which can
Expand Down
4 changes: 2 additions & 2 deletions webkit/support/platform_support_linux.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -29,7 +29,7 @@ void AfterInitialize(bool unit_test_mode) {
FilePath data_path;
PathService::Get(base::DIR_EXE, &data_path);
data_path = data_path.Append("DumpRenderTree.pak");
ResourceBundle::InitSharedInstanceForTest(data_path);
ResourceBundle::InitSharedInstanceWithPakFile(data_path);
}

void BeforeShutdown() {
Expand Down
2 changes: 1 addition & 1 deletion webkit/tools/test_shell/test_shell_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void TestShell::InitializeTestShell(bool layout_test_mode,
FilePath data_path;
PathService::Get(base::DIR_EXE, &data_path);
data_path = data_path.Append("test_shell.pak");
ResourceBundle::InitSharedInstanceForTest(data_path);
ResourceBundle::InitSharedInstanceWithPakFile(data_path);

FilePath resources_dir;
PathService::Get(base::DIR_SOURCE_ROOT, &resources_dir);
Expand Down

0 comments on commit 70f9df1

Please sign in to comment.