Chromium Code Reviews| Index: chrome/browser/chrome_browser_main.cc |
| diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc |
| index 2b0b0633d38214028d652ae62d2ac1924af98fc2..8ceaf04ad9d1543e08a462232f10f97dc24bf1d1 100644 |
| --- a/chrome/browser/chrome_browser_main.cc |
| +++ b/chrome/browser/chrome_browser_main.cc |
| @@ -978,19 +978,6 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
| flags_ui::kAddSentinels); |
| } |
| #endif // !defined(OS_CHROMEOS) |
| - // The MaterialDesignController needs to look at command line flags, which |
| - // are not available until this point. Now that they are, proceed with |
| - // initializing the MaterialDesignController. |
| - ui::MaterialDesignController::Initialize(); |
| -#if defined(OS_CHROMEOS) |
| - ash::MaterialDesignController::Initialize(); |
| -#endif // !defined(OS_CHROMEOS) |
| - |
| -#if defined(OS_MACOSX) |
| - // Material Design resource packs can be loaded now that command line flags |
| - // are set. See https://crbug.com/585290 . |
| - ui::ResourceBundle::GetSharedInstance().LoadMaterialDesignResources(); |
| -#endif |
| #if defined(OS_WIN) |
| // This is needed to enable ETW exporting when requested in about:flags. |
| @@ -1012,50 +999,6 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
| crash_keys::SetCrashKeysFromCommandLine( |
| *base::CommandLine::ForCurrentProcess()); |
| - // Mac starts it earlier in |PreMainMessageLoopStart()| (because it is |
| - // needed when loading the MainMenu.nib and the language doesn't depend on |
| - // anything since it comes from Cocoa. |
| -#if defined(OS_MACOSX) |
| - std::string locale = |
| - parameters().ui_task ? "en-US" : l10n_util::GetLocaleOverride(); |
| - browser_process_->SetApplicationLocale(locale); |
| -#else |
| - const std::string locale = |
| - local_state_->GetString(prefs::kApplicationLocale); |
| - |
| - // On a POSIX OS other than ChromeOS, the parameter that is passed to the |
| - // method InitSharedInstance is ignored. |
| - |
| - TRACE_EVENT_BEGIN0("startup", |
| - "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); |
| - const std::string loaded_locale = |
| - ui::ResourceBundle::InitSharedInstanceWithLocale( |
| - locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
| - TRACE_EVENT_END0("startup", |
| - "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); |
| - |
| - if (loaded_locale.empty() && |
| - !parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) { |
| - ShowMissingLocaleMessageBox(); |
| - return chrome::RESULT_CODE_MISSING_DATA; |
| - } |
| - CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; |
| - browser_process_->SetApplicationLocale(loaded_locale); |
| - |
| - { |
| - TRACE_EVENT0("startup", |
| - "ChromeBrowserMainParts::PreCreateThreadsImpl:AddDataPack"); |
| - base::FilePath resources_pack_path; |
| - PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| -#if defined(OS_ANDROID) |
| - ui::LoadMainAndroidPackFile("assets/resources.pak", resources_pack_path); |
| -#else |
| - ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| - resources_pack_path, ui::SCALE_FACTOR_NONE); |
| -#endif // defined(OS_ANDROID) |
| - } |
| -#endif // defined(OS_MACOSX) |
| - |
| // Android does first run in Java instead of native. |
| // Chrome OS has its own out-of-box-experience code. |
| #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| @@ -1150,6 +1093,70 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
| // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. |
| SetupMetricsAndFieldTrials(); |
| + const version_info::Channel channel = chrome::GetChannel(); |
| + ui::MaterialDesignController::SetWindowsShouldDefaultToMaterial( |
| + (channel == version_info::Channel::UNKNOWN) || |
| + (channel == version_info::Channel::CANARY) || |
| + (channel == version_info::Channel::DEV)); |
|
varkha
2016/05/06 14:58:22
Would it make sense to conditionally compile this
Peter Kasting
2016/05/13 06:36:45
Sure. It would be harmless to do the other way, b
|
| + |
| + // The MaterialDesignController needs to look at command line flags and field |
| + // trials, which are not available until this point. Now that they are, |
| + // proceed with initializing the MaterialDesignController. |
| + ui::MaterialDesignController::Initialize(); |
| +#if defined(OS_CHROMEOS) |
| + ash::MaterialDesignController::Initialize(); |
| +#endif // !defined(OS_CHROMEOS) |
| + |
| +#if defined(OS_MACOSX) |
| + // Material Design resource packs can be loaded now that command line flags |
| + // are set. See https://crbug.com/585290 . |
| + ui::ResourceBundle::GetSharedInstance().LoadMaterialDesignResources(); |
| +#endif |
| + |
| + // Mac starts it earlier in |PreMainMessageLoopStart()| (because it is |
| + // needed when loading the MainMenu.nib and the language doesn't depend on |
| + // anything since it comes from Cocoa. |
| +#if defined(OS_MACOSX) |
| + std::string locale = |
| + parameters().ui_task ? "en-US" : l10n_util::GetLocaleOverride(); |
| + browser_process_->SetApplicationLocale(locale); |
| +#else |
| + const std::string locale = |
| + local_state_->GetString(prefs::kApplicationLocale); |
| + |
| + // On a POSIX OS other than ChromeOS, the parameter that is passed to the |
| + // method InitSharedInstance is ignored. |
| + |
| + TRACE_EVENT_BEGIN0("startup", |
| + "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); |
| + const std::string loaded_locale = |
| + ui::ResourceBundle::InitSharedInstanceWithLocale( |
| + locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
| + TRACE_EVENT_END0("startup", |
| + "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); |
| + |
| + if (loaded_locale.empty() && |
| + !parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) { |
| + ShowMissingLocaleMessageBox(); |
| + return chrome::RESULT_CODE_MISSING_DATA; |
| + } |
| + CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; |
| + browser_process_->SetApplicationLocale(loaded_locale); |
| + |
| + { |
| + TRACE_EVENT0("startup", |
| + "ChromeBrowserMainParts::PreCreateThreadsImpl:AddDataPack"); |
| + base::FilePath resources_pack_path; |
| + PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| +#if defined(OS_ANDROID) |
| + ui::LoadMainAndroidPackFile("assets/resources.pak", resources_pack_path); |
| +#else |
| + ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| + resources_pack_path, ui::SCALE_FACTOR_NONE); |
| +#endif // defined(OS_ANDROID) |
| + } |
| +#endif // defined(OS_MACOSX) |
| + |
| // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. |
| browser_process_->PreCreateThreads(); |