| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 // On ChromeOS and Android the ProfileManager will use the same path as the | 423 // On ChromeOS and Android the ProfileManager will use the same path as the |
| 424 // one we got passed. GetActiveUserProfile will therefore use the correct path | 424 // one we got passed. GetActiveUserProfile will therefore use the correct path |
| 425 // automatically. | 425 // automatically. |
| 426 DCHECK_EQ(user_data_dir.value(), | 426 DCHECK_EQ(user_data_dir.value(), |
| 427 g_browser_process->profile_manager()->user_data_dir().value()); | 427 g_browser_process->profile_manager()->user_data_dir().value()); |
| 428 profile = ProfileManager::GetActiveUserProfile(); | 428 profile = ProfileManager::GetActiveUserProfile(); |
| 429 | 429 |
| 430 // TODO(port): fix this. See comments near the definition of |user_data_dir|. | 430 // TODO(port): fix this. See comments near the definition of |user_data_dir|. |
| 431 // It is better to CHECK-fail here than it is to silently exit because of | 431 // It is better to CHECK-fail here than it is to silently exit because of |
| 432 // missing code in the above test. | 432 // missing code in the above test. |
| 433 CHECK(profile) << "Cannot get default profile."; | 433 // Cannot get default profile. |
| 434 CHECK(profile); |
| 434 | 435 |
| 435 #else | 436 #else |
| 436 profile = GetStartupProfile(user_data_dir, parsed_command_line); | 437 profile = GetStartupProfile(user_data_dir, parsed_command_line); |
| 437 | 438 |
| 438 if (!profile && !profile_dir_specified) | 439 if (!profile && !profile_dir_specified) |
| 439 profile = GetFallbackStartupProfile(); | 440 profile = GetFallbackStartupProfile(); |
| 440 | 441 |
| 441 if (!profile) { | 442 if (!profile) { |
| 442 ProfileErrorType error_type = | 443 ProfileErrorType error_type = |
| 443 profile_dir_specified ? ProfileErrorType::CREATE_FAILURE_SPECIFIED | 444 profile_dir_specified ? ProfileErrorType::CREATE_FAILURE_SPECIFIED |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 base::CommandLine::ForCurrentProcess(); | 670 base::CommandLine::ForCurrentProcess(); |
| 670 if (command_line->HasSwitch(switches::kEnableBenchmarking) || | 671 if (command_line->HasSwitch(switches::kEnableBenchmarking) || |
| 671 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)) { | 672 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)) { |
| 672 base::FieldTrial::EnableBenchmarking(); | 673 base::FieldTrial::EnableBenchmarking(); |
| 673 } | 674 } |
| 674 | 675 |
| 675 if (command_line->HasSwitch(variations::switches::kForceFieldTrialParams)) { | 676 if (command_line->HasSwitch(variations::switches::kForceFieldTrialParams)) { |
| 676 bool result = variations::AssociateParamsFromString( | 677 bool result = variations::AssociateParamsFromString( |
| 677 command_line->GetSwitchValueASCII( | 678 command_line->GetSwitchValueASCII( |
| 678 variations::switches::kForceFieldTrialParams)); | 679 variations::switches::kForceFieldTrialParams)); |
| 679 CHECK(result) << "Invalid --" | 680 CHECK(result); |
| 680 << variations::switches::kForceFieldTrialParams | |
| 681 << " list specified."; | |
| 682 } | 681 } |
| 683 | 682 |
| 684 // Ensure any field trials specified on the command line are initialized. | 683 // Ensure any field trials specified on the command line are initialized. |
| 685 if (command_line->HasSwitch(switches::kForceFieldTrials)) { | 684 if (command_line->HasSwitch(switches::kForceFieldTrials)) { |
| 686 std::set<std::string> unforceable_field_trials; | 685 std::set<std::string> unforceable_field_trials; |
| 687 #if defined(OFFICIAL_BUILD) | 686 #if defined(OFFICIAL_BUILD) |
| 688 unforceable_field_trials.insert("SettingsEnforcement"); | 687 unforceable_field_trials.insert("SettingsEnforcement"); |
| 689 #endif // defined(OFFICIAL_BUILD) | 688 #endif // defined(OFFICIAL_BUILD) |
| 690 | 689 |
| 691 // Create field trials without activating them, so that this behaves in a | 690 // Create field trials without activating them, so that this behaves in a |
| 692 // consistent manner with field trials created from the server. | 691 // consistent manner with field trials created from the server. |
| 693 bool result = base::FieldTrialList::CreateTrialsFromString( | 692 bool result = base::FieldTrialList::CreateTrialsFromString( |
| 694 command_line->GetSwitchValueASCII(switches::kForceFieldTrials), | 693 command_line->GetSwitchValueASCII(switches::kForceFieldTrials), |
| 695 unforceable_field_trials); | 694 unforceable_field_trials); |
| 696 CHECK(result) << "Invalid --" << switches::kForceFieldTrials | 695 CHECK(result); |
| 697 << " list specified."; | |
| 698 } | 696 } |
| 699 | 697 |
| 700 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 698 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 701 | 699 |
| 702 // Associate parameters chosen in about:flags and create trial/group for them. | 700 // Associate parameters chosen in about:flags and create trial/group for them. |
| 703 flags_ui::PrefServiceFlagsStorage flags_storage( | 701 flags_ui::PrefServiceFlagsStorage flags_storage( |
| 704 g_browser_process->local_state()); | 702 g_browser_process->local_state()); |
| 705 std::vector<std::string> variation_ids = | 703 std::vector<std::string> variation_ids = |
| 706 about_flags::RegisterAllFeatureVariationParameters( | 704 about_flags::RegisterAllFeatureVariationParameters( |
| 707 &flags_storage, feature_list.get()); | 705 &flags_storage, feature_list.get()); |
| 708 | 706 |
| 709 variations::VariationsHttpHeaderProvider* http_header_provider = | 707 variations::VariationsHttpHeaderProvider* http_header_provider = |
| 710 variations::VariationsHttpHeaderProvider::GetInstance(); | 708 variations::VariationsHttpHeaderProvider::GetInstance(); |
| 711 // Force the variation ids selected in chrome://flags and/or specified using | 709 // Force the variation ids selected in chrome://flags and/or specified using |
| 712 // the command-line flag. | 710 // the command-line flag. |
| 713 bool result = http_header_provider->ForceVariationIds( | 711 bool result = http_header_provider->ForceVariationIds( |
| 714 command_line->GetSwitchValueASCII(switches::kForceVariationIds), | 712 command_line->GetSwitchValueASCII(switches::kForceVariationIds), |
| 715 &variation_ids); | 713 &variation_ids); |
| 716 CHECK(result) << "Invalid list of variation ids specified (either in --" | 714 CHECK(result); |
| 717 << switches::kForceVariationIds << " or in chrome://flags)"; | |
| 718 | 715 |
| 719 feature_list->InitializeFromCommandLine( | 716 feature_list->InitializeFromCommandLine( |
| 720 command_line->GetSwitchValueASCII(switches::kEnableFeatures), | 717 command_line->GetSwitchValueASCII(switches::kEnableFeatures), |
| 721 command_line->GetSwitchValueASCII(switches::kDisableFeatures)); | 718 command_line->GetSwitchValueASCII(switches::kDisableFeatures)); |
| 722 | 719 |
| 723 #if defined(FIELDTRIAL_TESTING_ENABLED) | 720 #if defined(FIELDTRIAL_TESTING_ENABLED) |
| 724 if (!command_line->HasSwitch( | 721 if (!command_line->HasSwitch( |
| 725 variations::switches::kDisableFieldTrialTestingConfig) && | 722 variations::switches::kDisableFieldTrialTestingConfig) && |
| 726 !command_line->HasSwitch(switches::kForceFieldTrials) && | 723 !command_line->HasSwitch(switches::kForceFieldTrials) && |
| 727 !command_line->HasSwitch(variations::switches::kVariationsServerURL)) { | 724 !command_line->HasSwitch(variations::switches::kVariationsServerURL)) { |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 ui::ResourceBundle::InitSharedInstanceWithLocale( | 1081 ui::ResourceBundle::InitSharedInstanceWithLocale( |
| 1085 locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 1082 locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
| 1086 TRACE_EVENT_END0("startup", | 1083 TRACE_EVENT_END0("startup", |
| 1087 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); | 1084 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); |
| 1088 | 1085 |
| 1089 if (loaded_locale.empty() && | 1086 if (loaded_locale.empty() && |
| 1090 !parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) { | 1087 !parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) { |
| 1091 ShowMissingLocaleMessageBox(); | 1088 ShowMissingLocaleMessageBox(); |
| 1092 return chrome::RESULT_CODE_MISSING_DATA; | 1089 return chrome::RESULT_CODE_MISSING_DATA; |
| 1093 } | 1090 } |
| 1094 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; | 1091 // Locale could not be found for |locale|. |
| 1092 CHECK(!loaded_locale.empty()); |
| 1095 browser_process_->SetApplicationLocale(loaded_locale); | 1093 browser_process_->SetApplicationLocale(loaded_locale); |
| 1096 | 1094 |
| 1097 { | 1095 { |
| 1098 TRACE_EVENT0("startup", | 1096 TRACE_EVENT0("startup", |
| 1099 "ChromeBrowserMainParts::PreCreateThreadsImpl:AddDataPack"); | 1097 "ChromeBrowserMainParts::PreCreateThreadsImpl:AddDataPack"); |
| 1100 base::FilePath resources_pack_path; | 1098 base::FilePath resources_pack_path; |
| 1101 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); | 1099 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| 1102 #if defined(OS_ANDROID) | 1100 #if defined(OS_ANDROID) |
| 1103 ui::LoadMainAndroidPackFile("assets/resources.pak", resources_pack_path); | 1101 ui::LoadMainAndroidPackFile("assets/resources.pak", resources_pack_path); |
| 1104 #else | 1102 #else |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 chromeos::CrosSettings::Shutdown(); | 2076 chromeos::CrosSettings::Shutdown(); |
| 2079 #endif // defined(OS_CHROMEOS) | 2077 #endif // defined(OS_CHROMEOS) |
| 2080 #endif // defined(OS_ANDROID) | 2078 #endif // defined(OS_ANDROID) |
| 2081 } | 2079 } |
| 2082 | 2080 |
| 2083 // Public members: | 2081 // Public members: |
| 2084 | 2082 |
| 2085 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2083 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 2086 chrome_extra_parts_.push_back(parts); | 2084 chrome_extra_parts_.push_back(parts); |
| 2087 } | 2085 } |
| OLD | NEW |