diff options
-rw-r--r-- | android_webview/browser/aw_browser_main_parts.cc | 6 | ||||
-rw-r--r-- | apps/app_shim/chrome_main_app_mode_mac.mm | 3 | ||||
-rw-r--r-- | ash/drag_drop/drag_drop_interactive_uitest.cc | 3 | ||||
-rw-r--r-- | ash/shell/content_client/shell_main_delegate.cc | 3 | ||||
-rw-r--r-- | ash/shell/shell_main_parts.cc | 3 | ||||
-rw-r--r-- | ash/test/test_suite.cc | 3 | ||||
-rw-r--r-- | ash/wm/ash_native_cursor_manager_interactive_uitest.cc | 3 | ||||
-rw-r--r-- | chrome/app/chrome_main_delegate.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main_mac.mm | 3 | ||||
-rw-r--r-- | chrome/browser/ui/startup/bad_flags_prompt.cc | 3 | ||||
-rw-r--r-- | chrome/service/service_process.cc | 3 | ||||
-rw-r--r-- | chrome/test/base/chrome_unit_test_suite.cc | 3 | ||||
-rw-r--r-- | components/test/run_all_unittests.cc | 3 | ||||
-rw-r--r-- | content/public/test/render_view_test.cc | 5 | ||||
-rw-r--r-- | remoting/base/resources_linux.cc | 3 | ||||
-rw-r--r-- | remoting/base/resources_mac.cc | 3 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle.cc | 16 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle.h | 15 | ||||
-rw-r--r-- | ui/base/test/run_all_unittests.cc | 6 |
20 files changed, 55 insertions, 38 deletions
diff --git a/android_webview/browser/aw_browser_main_parts.cc b/android_webview/browser/aw_browser_main_parts.cc index f0785f9..c5b66fe 100644 --- a/android_webview/browser/aw_browser_main_parts.cc +++ b/android_webview/browser/aw_browser_main_parts.cc @@ -56,8 +56,10 @@ int AwBrowserMainParts::PreCreateThreads() { // fail) just to create the ResourceBundle instance. We should refactor // ResourceBundle/GetApplicationLocale to not require an instance to be // initialized. - ui::ResourceBundle::InitSharedInstanceLocaleOnly( - l10n_util::GetDefaultLocale(), NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + l10n_util::GetDefaultLocale(), + NULL, + ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); std::string locale = l10n_util::GetApplicationLocale(std::string()) + ".pak"; if (AwAssets::OpenAsset(locale, &pak_fd, &pak_off, &pak_len)) { VLOG(0) << "Load from apk succesful, fd=" << pak_fd << " off=" << pak_off diff --git a/apps/app_shim/chrome_main_app_mode_mac.mm b/apps/app_shim/chrome_main_app_mode_mac.mm index 18b8f9e..8b91322 100644 --- a/apps/app_shim/chrome_main_app_mode_mac.mm +++ b/apps/app_shim/chrome_main_app_mode_mac.mm @@ -582,7 +582,8 @@ int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info) { l10n_util::GetApplicationLocale(preferred_localization)); // Load localized strings. - ResourceBundle::InitSharedInstanceLocaleOnly(locale, NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + locale, NULL, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); // Launch the IO thread. base::Thread::Options io_thread_options; diff --git a/ash/drag_drop/drag_drop_interactive_uitest.cc b/ash/drag_drop/drag_drop_interactive_uitest.cc index 24920fd..4e99df7 100644 --- a/ash/drag_drop/drag_drop_interactive_uitest.cc +++ b/ash/drag_drop/drag_drop_interactive_uitest.cc @@ -130,7 +130,8 @@ class DragDropTest : public test::AshTestBase { gfx::GLSurface::InitializeOneOffForTests(); ui::RegisterPathProvider(); - ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); base::FilePath resources_pack_path; PathService::Get(base::DIR_MODULE, &resources_pack_path); resources_pack_path = diff --git a/ash/shell/content_client/shell_main_delegate.cc b/ash/shell/content_client/shell_main_delegate.cc index 014fae1..5e61443 100644 --- a/ash/shell/content_client/shell_main_delegate.cc +++ b/ash/shell/content_client/shell_main_delegate.cc @@ -38,7 +38,8 @@ content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() { } void ShellMainDelegate::InitializeResourceBundle() { - ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); } } // namespace shell diff --git a/ash/shell/shell_main_parts.cc b/ash/shell/shell_main_parts.cc index 8cad410..0de3d31 100644 --- a/ash/shell/shell_main_parts.cc +++ b/ash/shell/shell_main_parts.cc @@ -14,7 +14,8 @@ namespace shell { void PreMainMessageLoopStart() { ui::RegisterPathProvider(); base::i18n::InitializeICU(); - ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); } } // namespace ash diff --git a/ash/test/test_suite.cc b/ash/test/test_suite.cc index 7955264..57e384e 100644 --- a/ash/test/test_suite.cc +++ b/ash/test/test_suite.cc @@ -51,7 +51,8 @@ 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::InitSharedInstanceWithLocale("en-US", NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); } void AuraShellTestSuite::Shutdown() { diff --git a/ash/wm/ash_native_cursor_manager_interactive_uitest.cc b/ash/wm/ash_native_cursor_manager_interactive_uitest.cc index 83df158..eb0e20a 100644 --- a/ash/wm/ash_native_cursor_manager_interactive_uitest.cc +++ b/ash/wm/ash_native_cursor_manager_interactive_uitest.cc @@ -34,7 +34,8 @@ class AshNativeCursorManagerTest : public test::AshTestBase { gfx::GLSurface::InitializeOneOffForTests(); ui::RegisterPathProvider(); - ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); base::FilePath resources_pack_path; PathService::Get(base::DIR_MODULE, &resources_pack_path); resources_pack_path = diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc index 0faeaf5..050b184 100644 --- a/chrome/app/chrome_main_delegate.cc +++ b/chrome/app/chrome_main_delegate.cc @@ -738,7 +738,8 @@ void ChromeMainDelegate::PreSandboxStartup() { const std::string loaded_locale = locale; #else const std::string loaded_locale = - ResourceBundle::InitSharedInstanceWithLocale(locale, NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); base::FilePath resources_pack_path; PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index ba08b41..1b51179 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -863,7 +863,8 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { TRACE_EVENT_BEGIN0("startup", "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); const std::string loaded_locale = - ResourceBundle::InitSharedInstanceWithLocale(locale, NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); TRACE_EVENT_END0("startup", "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); diff --git a/chrome/browser/chrome_browser_main_mac.mm b/chrome/browser/chrome_browser_main_mac.mm index 8c46f78..ecfd602 100644 --- a/chrome/browser/chrome_browser_main_mac.mm +++ b/chrome/browser/chrome_browser_main_mac.mm @@ -203,7 +203,8 @@ void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { // TODO(markusheintz): Read preference pref::kApplicationLocale in order // to enforce the application locale. const std::string loaded_locale = - ResourceBundle::InitSharedInstanceWithLocale(std::string(), NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + std::string(), NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); CHECK(!loaded_locale.empty()) << "Default locale could not be found"; base::FilePath resources_pack_path; diff --git a/chrome/browser/ui/startup/bad_flags_prompt.cc b/chrome/browser/ui/startup/bad_flags_prompt.cc index e3161d7..f924efd 100644 --- a/chrome/browser/ui/startup/bad_flags_prompt.cc +++ b/chrome/browser/ui/startup/bad_flags_prompt.cc @@ -106,7 +106,8 @@ void MaybeShowInvalidUserDataDirWarningDialog() { const char kUserDataDirDialogFallbackLocale[] = "en-US"; if (locale.empty()) locale = kUserDataDirDialogFallbackLocale; - ResourceBundle::InitSharedInstanceWithLocale(locale, NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); } const base::string16& title = diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc index 44f0318..fe4fe6d 100644 --- a/chrome/service/service_process.cc +++ b/chrome/service/service_process.cc @@ -177,7 +177,8 @@ bool ServiceProcess::Initialize(base::MessageLoopForUI* message_loop, if (locale.empty()) locale = kDefaultServiceProcessLocale; } - ResourceBundle::InitSharedInstanceWithLocale(locale, NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); PrepareRestartOnCrashEnviroment(command_line); diff --git a/chrome/test/base/chrome_unit_test_suite.cc b/chrome/test/base/chrome_unit_test_suite.cc index f58ba47..22f5188 100644 --- a/chrome/test/base/chrome_unit_test_suite.cc +++ b/chrome/test/base/chrome_unit_test_suite.cc @@ -146,7 +146,8 @@ void ChromeUnitTestSuite::InitializeProviders() { void ChromeUnitTestSuite::InitializeResourceBundle() { // Force unittests to run using en-US so if we test against string // output, it'll pass regardless of the system language. - ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); base::FilePath resources_pack_path; #if defined(OS_MACOSX) && !defined(OS_IOS) PathService::Get(base::DIR_MODULE, &resources_pack_path); diff --git a/components/test/run_all_unittests.cc b/components/test/run_all_unittests.cc index ca4e064..1cee176 100644 --- a/components/test/run_all_unittests.cc +++ b/components/test/run_all_unittests.cc @@ -76,7 +76,8 @@ class ComponentsTestSuite : public base::TestSuite { // TODO(tfarina): This should be changed to InitSharedInstanceWithPakFile() // so we can load our pak file instead of chrome.pak. crbug.com/348563 - ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); base::FilePath resources_pack_path; PathService::Get(base::DIR_MODULE, &resources_pack_path); ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( diff --git a/content/public/test/render_view_test.cc b/content/public/test/render_view_test.cc index f4e44ca..725bd0d 100644 --- a/content/public/test/render_view_test.cc +++ b/content/public/test/render_view_test.cc @@ -176,8 +176,9 @@ void RenderViewTest::SetUp() { // ResourceBundle isn't initialized (since we have to use a diferent test // suite implementation than for content_unittests). For browser_tests, this // is already initialized. - if (!ResourceBundle::HasSharedInstance()) - ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); + if (!ui::ResourceBundle::HasSharedInstance()) + ui::ResourceBundle::InitSharedInstanceWithLocale( + "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); mock_process_.reset(new MockRenderProcess); diff --git a/remoting/base/resources_linux.cc b/remoting/base/resources_linux.cc index d7d23ba..63a53f2 100644 --- a/remoting/base/resources_linux.cc +++ b/remoting/base/resources_linux.cc @@ -31,7 +31,8 @@ bool LoadResources(const std::string& pref_locale) { PathService::Override(ui::DIR_LOCALES, path.AppendASCII(kLocaleResourcesDirName)); - ui::ResourceBundle::InitSharedInstanceLocaleOnly(pref_locale, NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + pref_locale, NULL, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); } return true; diff --git a/remoting/base/resources_mac.cc b/remoting/base/resources_mac.cc index 7ea59b6..d848e67 100644 --- a/remoting/base/resources_mac.cc +++ b/remoting/base/resources_mac.cc @@ -32,7 +32,8 @@ bool LoadResources(const std::string& pref_locale) { if (pref_locale.empty()) l10n_util::OverrideLocaleWithCocoaLocale(); - ui::ResourceBundle::InitSharedInstanceLocaleOnly(pref_locale, NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + pref_locale, NULL, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); } return true; diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc index b5d5707..8d0aa547 100644 --- a/ui/base/resource/resource_bundle.cc +++ b/ui/base/resource/resource_bundle.cc @@ -164,18 +164,12 @@ class ResourceBundle::ResourceBundleImageSource : public gfx::ImageSkiaSource { // static std::string ResourceBundle::InitSharedInstanceWithLocale( - const std::string& pref_locale, Delegate* delegate) { - InitSharedInstance(delegate); - g_shared_instance_->LoadCommonResources(); - std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); - InitDefaultFontList(); - return result; -} - -// static -std::string ResourceBundle::InitSharedInstanceLocaleOnly( - const std::string& pref_locale, Delegate* delegate) { + const std::string& pref_locale, + Delegate* delegate, + LoadResources load_resources) { InitSharedInstance(delegate); + if (load_resources == LOAD_COMMON_RESOURCES) + g_shared_instance_->LoadCommonResources(); std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); InitDefaultFontList(); return result; diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h index 8fd932a..f5308e4 100644 --- a/ui/base/resource/resource_bundle.h +++ b/ui/base/resource/resource_bundle.h @@ -64,6 +64,11 @@ class UI_BASE_EXPORT ResourceBundle { RTL_DISABLED, }; + enum LoadResources { + LOAD_COMMON_RESOURCES, + DO_NOT_LOAD_COMMON_RESOURCES + }; + // Delegate class that allows interception of pack file loading and resource // requests. The methods of this class may be called on multiple threads. class Delegate { @@ -124,13 +129,11 @@ class UI_BASE_EXPORT ResourceBundle { // There is no way to specify which resource files are loaded, i.e. names of // the files are hardcoded in ResourceBundle. Fix it to allow to specify which // files are loaded (e.g. add a new method in Delegate). + // |load_resources| controls whether or not LoadCommonResources is called. static std::string InitSharedInstanceWithLocale( - const std::string& pref_locale, Delegate* delegate); - - // Same as InitSharedInstanceWithLocale(), but loads only localized resources, - // without default resource packs. - static std::string InitSharedInstanceLocaleOnly( - const std::string& pref_locale, Delegate* delegate); + const std::string& pref_locale, + Delegate* delegate, + LoadResources load_resources); // Initialize the ResourceBundle using the given file region. If |region| is // MemoryMappedFile::Region::kWholeFile, the entire |pak_file| is used. diff --git a/ui/base/test/run_all_unittests.cc b/ui/base/test/run_all_unittests.cc index bfc5f26..b70fe02 100644 --- a/ui/base/test/run_all_unittests.cc +++ b/ui/base/test/run_all_unittests.cc @@ -68,12 +68,14 @@ void UIBaseTestSuite::Initialize() { // chrome_100_percent.pak at the appropriate places to ui_test.pak. base::mac::SetOverrideFrameworkBundlePath( exe_path.AppendASCII("ui_unittests Framework.framework")); - ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); #elif defined(OS_IOS) || defined(OS_ANDROID) // On iOS, the ui_unittests binary is itself a mini bundle, with resources // built in. On Android, ui_unittests_apk provides the necessary framework. - ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); + ui::ResourceBundle::InitSharedInstanceWithLocale( + "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); #else // On other platforms, the (hardcoded) paths for chrome_100_percent.pak and |