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

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 10383114: Rename BrowserInit to StartupBrowserCreator, and move into startup subdir. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chrome_browser_main.h ('k') | chrome/browser/chromeos/login/login_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "chrome/browser/profiles/profile_manager.h" 72 #include "chrome/browser/profiles/profile_manager.h"
73 #include "chrome/browser/search_engines/search_engine_type.h" 73 #include "chrome/browser/search_engines/search_engine_type.h"
74 #include "chrome/browser/search_engines/template_url.h" 74 #include "chrome/browser/search_engines/template_url.h"
75 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 75 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
76 #include "chrome/browser/search_engines/template_url_service.h" 76 #include "chrome/browser/search_engines/template_url_service.h"
77 #include "chrome/browser/search_engines/template_url_service_factory.h" 77 #include "chrome/browser/search_engines/template_url_service_factory.h"
78 #include "chrome/browser/service/service_process_control.h" 78 #include "chrome/browser/service/service_process_control.h"
79 #include "chrome/browser/shell_integration.h" 79 #include "chrome/browser/shell_integration.h"
80 #include "chrome/browser/translate/translate_manager.h" 80 #include "chrome/browser/translate/translate_manager.h"
81 #include "chrome/browser/ui/browser.h" 81 #include "chrome/browser/ui/browser.h"
82 #include "chrome/browser/ui/browser_init.h" 82 #include "chrome/browser/ui/startup/startup_browser_creator.h"
83 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" 83 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h"
84 #include "chrome/common/child_process_logging.h" 84 #include "chrome/common/child_process_logging.h"
85 #include "chrome/common/chrome_constants.h" 85 #include "chrome/common/chrome_constants.h"
86 #include "chrome/common/chrome_paths.h" 86 #include "chrome/common/chrome_paths.h"
87 #include "chrome/common/chrome_result_codes.h" 87 #include "chrome/common/chrome_result_codes.h"
88 #include "chrome/common/chrome_switches.h" 88 #include "chrome/common/chrome_switches.h"
89 #include "chrome/common/chrome_version_info.h" 89 #include "chrome/common/chrome_version_info.h"
90 #include "chrome/common/env_vars.h" 90 #include "chrome/common/env_vars.h"
91 #include "chrome/common/json_pref_store.h" 91 #include "chrome/common/json_pref_store.h"
92 #include "chrome/common/jstemplate_builder.h" 92 #include "chrome/common/jstemplate_builder.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 #if defined(OS_CHROMEOS) 202 #if defined(OS_CHROMEOS)
203 // Test loading libcros and exit. We return 0 if the library could be loaded, 203 // Test loading libcros and exit. We return 0 if the library could be loaded,
204 // and 1 if it can't be. This is for validation that the library is installed 204 // and 1 if it can't be. This is for validation that the library is installed
205 // and versioned properly for Chrome to find. 205 // and versioned properly for Chrome to find.
206 if (command_line.HasSwitch(switches::kTestLoadLibcros)) 206 if (command_line.HasSwitch(switches::kTestLoadLibcros))
207 exit(!chromeos::CrosLibrary::Get()->libcros_loaded()); 207 exit(!chromeos::CrosLibrary::Get()->libcros_loaded());
208 #endif 208 #endif
209 } 209 }
210 210
211 void AddFirstRunNewTabs(BrowserInit* browser_init, 211 void AddFirstRunNewTabs(StartupBrowserCreator* browser_creator,
212 const std::vector<GURL>& new_tabs) { 212 const std::vector<GURL>& new_tabs) {
213 for (std::vector<GURL>::const_iterator it = new_tabs.begin(); 213 for (std::vector<GURL>::const_iterator it = new_tabs.begin();
214 it != new_tabs.end(); ++it) { 214 it != new_tabs.end(); ++it) {
215 if (it->is_valid()) 215 if (it->is_valid())
216 browser_init->AddFirstRunTab(*it); 216 browser_creator->AddFirstRunTab(*it);
217 } 217 }
218 } 218 }
219 219
220 void InitializeNetworkOptions(const CommandLine& parsed_command_line) { 220 void InitializeNetworkOptions(const CommandLine& parsed_command_line) {
221 if (parsed_command_line.HasSwitch(switches::kEnableFileCookies)) { 221 if (parsed_command_line.HasSwitch(switches::kEnableFileCookies)) {
222 // Enable cookie storage for file:// URLs. Must do this before the first 222 // Enable cookie storage for file:// URLs. Must do this before the first
223 // Profile (and therefore the first CookieMonster) is created. 223 // Profile (and therefore the first CookieMonster) is created.
224 net::CookieMonster::EnableFileScheme(); 224 net::CookieMonster::EnableFileScheme();
225 } 225 }
226 226
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 // We should never be called before the profile has been created. 491 // We should never be called before the profile has been created.
492 NOTREACHED(); 492 NOTREACHED();
493 return true; 493 return true;
494 } 494 }
495 495
496 ExtensionsStartupUtil ext_startup_util; 496 ExtensionsStartupUtil ext_startup_util;
497 ext_startup_util.UninstallExtension(command_line, profile); 497 ext_startup_util.UninstallExtension(command_line, profile);
498 return true; 498 return true;
499 } 499 }
500 500
501 BrowserInit::ProcessCommandLineAlreadyRunning( 501 StartupBrowserCreator::ProcessCommandLineAlreadyRunning(
502 command_line, current_directory); 502 command_line, current_directory);
503 return true; 503 return true;
504 } 504 }
505 505
506 bool HasImportSwitch(const CommandLine& command_line) { 506 bool HasImportSwitch(const CommandLine& command_line) {
507 return (command_line.HasSwitch(switches::kImport) || 507 return (command_line.HasSwitch(switches::kImport) ||
508 command_line.HasSwitch(switches::kImportFromFile)); 508 command_line.HasSwitch(switches::kImportFromFile));
509 } 509 }
510 510
511 } // namespace 511 } // namespace
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 1202
1203 void ChromeBrowserMainParts::PostMainMessageLoopStart() { 1203 void ChromeBrowserMainParts::PostMainMessageLoopStart() {
1204 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 1204 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1205 chrome_extra_parts_[i]->PostMainMessageLoopStart(); 1205 chrome_extra_parts_[i]->PostMainMessageLoopStart();
1206 } 1206 }
1207 1207
1208 int ChromeBrowserMainParts::PreCreateThreads() { 1208 int ChromeBrowserMainParts::PreCreateThreads() {
1209 result_code_ = PreCreateThreadsImpl(); 1209 result_code_ = PreCreateThreadsImpl();
1210 // These members must be initialized before returning from this function. 1210 // These members must be initialized before returning from this function.
1211 DCHECK(master_prefs_.get()); 1211 DCHECK(master_prefs_.get());
1212 DCHECK(browser_init_.get()); 1212 DCHECK(browser_creator_.get());
1213 return result_code_; 1213 return result_code_;
1214 } 1214 }
1215 1215
1216 int ChromeBrowserMainParts::PreCreateThreadsImpl() { 1216 int ChromeBrowserMainParts::PreCreateThreadsImpl() {
1217 run_message_loop_ = false; 1217 run_message_loop_ = false;
1218 #if defined(OS_WIN) 1218 #if defined(OS_WIN)
1219 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_); 1219 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_);
1220 #else 1220 #else
1221 // Getting the user data dir can fail if the directory isn't 1221 // Getting the user data dir can fail if the directory isn't
1222 // creatable, for example; on Windows in code below we bring up a 1222 // creatable, for example; on Windows in code below we bring up a
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 1260
1261 // This forces the TabCloseableStateWatcher to be created and, on chromeos, 1261 // This forces the TabCloseableStateWatcher to be created and, on chromeos,
1262 // register for the notifications it needs to track the closeable state of 1262 // register for the notifications it needs to track the closeable state of
1263 // tabs. 1263 // tabs.
1264 browser_process_->tab_closeable_state_watcher(); 1264 browser_process_->tab_closeable_state_watcher();
1265 1265
1266 local_state_ = InitializeLocalState(parsed_command_line(), is_first_run_); 1266 local_state_ = InitializeLocalState(parsed_command_line(), is_first_run_);
1267 1267
1268 // These members must be initialized before returning from this function. 1268 // These members must be initialized before returning from this function.
1269 master_prefs_.reset(new first_run::MasterPrefs); 1269 master_prefs_.reset(new first_run::MasterPrefs);
1270 browser_init_.reset(new BrowserInit); 1270 browser_creator_.reset(new StartupBrowserCreator);
1271 1271
1272 #if !defined(OS_ANDROID) 1272 #if !defined(OS_ANDROID)
1273 // Convert active labs into switches. This needs to be done before 1273 // Convert active labs into switches. This needs to be done before
1274 // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are 1274 // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are
1275 // affected by experiment flags (--touch-optimized-ui in particular). Not 1275 // affected by experiment flags (--touch-optimized-ui in particular). Not
1276 // needed on Android as there aren't experimental flags. 1276 // needed on Android as there aren't experimental flags.
1277 about_flags::ConvertFlagsToSwitches(local_state_, 1277 about_flags::ConvertFlagsToSwitches(local_state_,
1278 CommandLine::ForCurrentProcess()); 1278 CommandLine::ForCurrentProcess());
1279 #endif 1279 #endif
1280 local_state_->UpdateCommandLinePrefStore(CommandLine::ForCurrentProcess()); 1280 local_state_->UpdateCommandLinePrefStore(CommandLine::ForCurrentProcess());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 #endif // defined(OS_WIN) 1345 #endif // defined(OS_WIN)
1346 } 1346 }
1347 1347
1348 // On first run, we need to process the predictor preferences before the 1348 // On first run, we need to process the predictor preferences before the
1349 // browser's profile_manager object is created, but after ResourceBundle 1349 // browser's profile_manager object is created, but after ResourceBundle
1350 // is initialized. 1350 // is initialized.
1351 first_run_ui_bypass_ = false; // True to skip first run UI. 1351 first_run_ui_bypass_ = false; // True to skip first run UI.
1352 if (is_first_run_) { 1352 if (is_first_run_) {
1353 first_run_ui_bypass_ = !first_run::ProcessMasterPreferences( 1353 first_run_ui_bypass_ = !first_run::ProcessMasterPreferences(
1354 user_data_dir_, master_prefs_.get()); 1354 user_data_dir_, master_prefs_.get());
1355 AddFirstRunNewTabs(browser_init_.get(), master_prefs_->new_tabs); 1355 AddFirstRunNewTabs(browser_creator_.get(), master_prefs_->new_tabs);
1356 1356
1357 // If we are running in App mode, we do not want to show the importer 1357 // If we are running in App mode, we do not want to show the importer
1358 // (first run) UI. 1358 // (first run) UI.
1359 if (!first_run_ui_bypass_ && 1359 if (!first_run_ui_bypass_ &&
1360 (parsed_command_line().HasSwitch(switches::kApp) || 1360 (parsed_command_line().HasSwitch(switches::kApp) ||
1361 parsed_command_line().HasSwitch(switches::kAppId) || 1361 parsed_command_line().HasSwitch(switches::kAppId) ||
1362 parsed_command_line().HasSwitch(switches::kNoFirstRun))) 1362 parsed_command_line().HasSwitch(switches::kNoFirstRun)))
1363 first_run_ui_bypass_ = true; 1363 first_run_ui_bypass_ = true;
1364 1364
1365 // Create Sentinel if no-first-run argument is passed in. 1365 // Create Sentinel if no-first-run argument is passed in.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 } 1425 }
1426 1426
1427 // PreMainMessageLoopRun calls these extra stages in the following order: 1427 // PreMainMessageLoopRun calls these extra stages in the following order:
1428 // PreMainMessageLoopRunImpl() 1428 // PreMainMessageLoopRunImpl()
1429 // ... initial setup, including browser_process_ setup. 1429 // ... initial setup, including browser_process_ setup.
1430 // PreProfileInit() 1430 // PreProfileInit()
1431 // ... additional setup, including CreateProfile() 1431 // ... additional setup, including CreateProfile()
1432 // PostProfileInit() 1432 // PostProfileInit()
1433 // ... additional setup 1433 // ... additional setup
1434 // PreBrowserStart() 1434 // PreBrowserStart()
1435 // ... browser_init_->Start (OR parameters().ui_task->Run()) 1435 // ... browser_creator_->Start (OR parameters().ui_task->Run())
1436 // PostBrowserStart() 1436 // PostBrowserStart()
1437 1437
1438 void ChromeBrowserMainParts::PreProfileInit() { 1438 void ChromeBrowserMainParts::PreProfileInit() {
1439 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 1439 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1440 chrome_extra_parts_[i]->PreProfileInit(); 1440 chrome_extra_parts_[i]->PreProfileInit();
1441 } 1441 }
1442 1442
1443 void ChromeBrowserMainParts::PostProfileInit() { 1443 void ChromeBrowserMainParts::PostProfileInit() {
1444 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 1444 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1445 chrome_extra_parts_[i]->PostProfileInit(); 1445 chrome_extra_parts_[i]->PostProfileInit();
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 int result_code; 1819 int result_code;
1820 #if defined(OS_CHROMEOS) 1820 #if defined(OS_CHROMEOS)
1821 // On ChromeOS multiple profiles doesn't apply, and will break if we load 1821 // On ChromeOS multiple profiles doesn't apply, and will break if we load
1822 // them this early as the cryptohome hasn't yet been mounted (which happens 1822 // them this early as the cryptohome hasn't yet been mounted (which happens
1823 // only once we log in. 1823 // only once we log in.
1824 std::vector<Profile*> last_opened_profiles; 1824 std::vector<Profile*> last_opened_profiles;
1825 #else 1825 #else
1826 std::vector<Profile*> last_opened_profiles = 1826 std::vector<Profile*> last_opened_profiles =
1827 g_browser_process->profile_manager()->GetLastOpenedProfiles(); 1827 g_browser_process->profile_manager()->GetLastOpenedProfiles();
1828 #endif 1828 #endif
1829 if (browser_init_->Start(parsed_command_line(), FilePath(), 1829 if (browser_creator_->Start(parsed_command_line(), FilePath(),
1830 profile_, last_opened_profiles, &result_code)) { 1830 profile_, last_opened_profiles, &result_code)) {
1831 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) 1831 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
1832 // Initialize autoupdate timer. Timer callback costs basically nothing 1832 // Initialize autoupdate timer. Timer callback costs basically nothing
1833 // when browser is not in persistent mode, so it's OK to let it ride on 1833 // when browser is not in persistent mode, so it's OK to let it ride on
1834 // the main thread. This needs to be done here because we don't want 1834 // the main thread. This needs to be done here because we don't want
1835 // to start the timer when Chrome is run inside a test harness. 1835 // to start the timer when Chrome is run inside a test harness.
1836 browser_process_->StartAutoupdateTimer(); 1836 browser_process_->StartAutoupdateTimer();
1837 #endif 1837 #endif
1838 1838
1839 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1839 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1840 // On Linux, the running exe will be updated if an upgrade becomes 1840 // On Linux, the running exe will be updated if an upgrade becomes
(...skipping 24 matching lines...) Expand all
1865 if (parameters().ui_task == NULL && translate_manager_ != NULL) { 1865 if (parameters().ui_task == NULL && translate_manager_ != NULL) {
1866 translate_manager_->FetchLanguageListFromTranslateServer( 1866 translate_manager_->FetchLanguageListFromTranslateServer(
1867 profile_->GetPrefs()); 1867 profile_->GetPrefs());
1868 } 1868 }
1869 #endif 1869 #endif
1870 1870
1871 run_message_loop_ = true; 1871 run_message_loop_ = true;
1872 } else { 1872 } else {
1873 run_message_loop_ = false; 1873 run_message_loop_ = false;
1874 } 1874 }
1875 browser_init_.reset(); 1875 browser_creator_.reset();
1876 1876
1877 PostBrowserStart(); 1877 PostBrowserStart();
1878 1878
1879 if (parameters().ui_task) { 1879 if (parameters().ui_task) {
1880 parameters().ui_task->Run(); 1880 parameters().ui_task->Run();
1881 delete parameters().ui_task; 1881 delete parameters().ui_task;
1882 run_message_loop_ = false; 1882 run_message_loop_ = false;
1883 } 1883 }
1884 1884
1885 return result_code_; 1885 return result_code_;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 if (base::win::GetVersion() <= base::win::VERSION_XP) 2007 if (base::win::GetVersion() <= base::win::VERSION_XP)
2008 uma_name += "_XP"; 2008 uma_name += "_XP";
2009 2009
2010 uma_name += "_PreRead_"; 2010 uma_name += "_PreRead_";
2011 uma_name += pre_read_percentage; 2011 uma_name += pre_read_percentage;
2012 AddPreReadHistogramTime(uma_name.c_str(), time); 2012 AddPreReadHistogramTime(uma_name.c_str(), time);
2013 } 2013 }
2014 #endif 2014 #endif
2015 #endif 2015 #endif
2016 } 2016 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.h ('k') | chrome/browser/chromeos/login/login_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698