Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3587)

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 1955773002: Enable MD by default on Windows for Canary/Dev and local builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't break first run Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bde4cb11a0d9088a24ce92aa3da897a9d4d9f2c7 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,56 +999,11 @@ 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)
// On first run, we need to process the predictor preferences before the
- // browser's profile_manager object is created, but after ResourceBundle
- // is initialized.
+ // browser's profile_manager object is created.
if (first_run::IsChromeFirstRun()) {
first_run::ProcessMasterPreferencesResult pmp_result =
first_run::ProcessMasterPreferences(user_data_dir_,
@@ -1150,6 +1092,72 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() {
// IOThread's initialization which happens in BrowserProcess:PreCreateThreads.
SetupMetricsAndFieldTrials();
+#if defined(OS_WIN)
+ const version_info::Channel channel = chrome::GetChannel();
+ ui::MaterialDesignController::SetDefaultToMaterial(
+ (channel == version_info::Channel::UNKNOWN) ||
+ (channel == version_info::Channel::CANARY) ||
+ (channel == version_info::Channel::DEV));
varkha 2016/05/14 05:03:08 Could this channel check be done inside MaterialDe
Peter Kasting 2016/05/16 19:53:16 No. That's why this unorthodox design exists. Ma
+#endif
+
+ // 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(
sky 2016/05/13 15:49:56 Is resourcebundle set up to have Init called multi
Peter Kasting 2016/05/16 19:53:16 It should be OK if and only if you unload the shar
+ locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
sky 2016/05/13 15:49:56 nullptr
Peter Kasting 2016/05/16 19:53:16 Done.
+ 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();

Powered by Google App Engine
This is Rietveld 408576698