Chromium Code Reviews| 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 <algorithm> | 10 #include <algorithm> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "base/logging.h" | 26 #include "base/logging.h" |
| 27 #include "base/memory/ptr_util.h" | 27 #include "base/memory/ptr_util.h" |
| 28 #include "base/metrics/field_trial.h" | 28 #include "base/metrics/field_trial.h" |
| 29 #include "base/metrics/histogram_macros.h" | 29 #include "base/metrics/histogram_macros.h" |
| 30 #include "base/path_service.h" | 30 #include "base/path_service.h" |
| 31 #include "base/profiler/scoped_tracker.h" | 31 #include "base/profiler/scoped_tracker.h" |
| 32 #include "base/run_loop.h" | 32 #include "base/run_loop.h" |
| 33 #include "base/strings/string_number_conversions.h" | 33 #include "base/strings/string_number_conversions.h" |
| 34 #include "base/strings/string_piece.h" | 34 #include "base/strings/string_piece.h" |
| 35 #include "base/strings/string_split.h" | 35 #include "base/strings/string_split.h" |
| 36 #include "base/strings/string_util.h" | |
| 36 #include "base/strings/sys_string_conversions.h" | 37 #include "base/strings/sys_string_conversions.h" |
| 37 #include "base/strings/utf_string_conversions.h" | 38 #include "base/strings/utf_string_conversions.h" |
| 38 #include "base/sys_info.h" | 39 #include "base/sys_info.h" |
| 39 #include "base/task_scheduler/scheduler_worker_pool_params.h" | 40 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
| 40 #include "base/task_scheduler/switches.h" | 41 #include "base/task_scheduler/switches.h" |
| 41 #include "base/task_scheduler/task_scheduler.h" | 42 #include "base/task_scheduler/task_scheduler.h" |
| 42 #include "base/task_scheduler/task_traits.h" | 43 #include "base/task_scheduler/task_traits.h" |
| 43 #include "base/threading/platform_thread.h" | 44 #include "base/threading/platform_thread.h" |
| 44 #include "base/time/default_tick_clock.h" | 45 #include "base/time/default_tick_clock.h" |
| 45 #include "base/time/time.h" | 46 #include "base/time/time.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 #include "chromeos/settings/cros_settings_names.h" | 199 #include "chromeos/settings/cros_settings_names.h" |
| 199 #endif // defined(OS_CHROMEOS) | 200 #endif // defined(OS_CHROMEOS) |
| 200 | 201 |
| 201 // TODO(port): several win-only methods have been pulled out of this, but | 202 // TODO(port): several win-only methods have been pulled out of this, but |
| 202 // BrowserMain() as a whole needs to be broken apart so that it's usable by | 203 // BrowserMain() as a whole needs to be broken apart so that it's usable by |
| 203 // other platforms. For now, it's just a stub. This is a serious work in | 204 // other platforms. For now, it's just a stub. This is a serious work in |
| 204 // progress and should not be taken as an indication of a real refactoring. | 205 // progress and should not be taken as an indication of a real refactoring. |
| 205 | 206 |
| 206 #if defined(OS_WIN) | 207 #if defined(OS_WIN) |
| 207 #include "base/trace_event/trace_event_etw_export_win.h" | 208 #include "base/trace_event/trace_event_etw_export_win.h" |
| 209 #include "base/win/win_util.h" | |
| 208 #include "base/win/windows_version.h" | 210 #include "base/win/windows_version.h" |
| 209 #include "chrome/app/file_pre_reader_win.h" | 211 #include "chrome/app/file_pre_reader_win.h" |
| 210 #include "chrome/browser/chrome_browser_main_win.h" | 212 #include "chrome/browser/chrome_browser_main_win.h" |
| 211 #include "chrome/browser/component_updater/caps_installer_win.h" | 213 #include "chrome/browser/component_updater/caps_installer_win.h" |
| 212 #include "chrome/browser/component_updater/sw_reporter_installer_win.h" | 214 #include "chrome/browser/component_updater/sw_reporter_installer_win.h" |
| 213 #include "chrome/browser/downgrade/user_data_downgrade.h" | 215 #include "chrome/browser/downgrade/user_data_downgrade.h" |
| 214 #include "chrome/browser/first_run/try_chrome_dialog_view.h" | 216 #include "chrome/browser/first_run/try_chrome_dialog_view.h" |
| 215 #include "chrome/browser/first_run/upgrade_util_win.h" | 217 #include "chrome/browser/first_run/upgrade_util_win.h" |
| 216 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 218 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 217 #include "chrome/browser/ui/network_profile_bubble.h" | 219 #include "chrome/browser/ui/network_profile_bubble.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 | 285 |
| 284 #if defined(OS_WIN) || defined(OS_MACOSX) || \ | 286 #if defined(OS_WIN) || defined(OS_MACOSX) || \ |
| 285 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) | 287 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
| 286 #include "chrome/browser/metrics/desktop_engagement/desktop_engagement_service.h " | 288 #include "chrome/browser/metrics/desktop_engagement/desktop_engagement_service.h " |
| 287 #endif | 289 #endif |
| 288 | 290 |
| 289 using content::BrowserThread; | 291 using content::BrowserThread; |
| 290 | 292 |
| 291 namespace { | 293 namespace { |
| 292 | 294 |
| 295 // feature used to remove AutoImport on first run is default-off | |
| 296 const base::Feature kFirstRunAutoImport{"FirstRunAutoImport", | |
|
manzagop (departed)
2016/08/18 15:59:56
I'd call it DisableFirstRunAutoImport, so it's acc
gcomanici
2016/08/19 16:04:30
Done.
| |
| 297 base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 298 | |
| 293 // A provider of Geolocation services to override AccessTokenStore. | 299 // A provider of Geolocation services to override AccessTokenStore. |
| 294 class ChromeGeolocationDelegate : public device::GeolocationDelegate { | 300 class ChromeGeolocationDelegate : public device::GeolocationDelegate { |
| 295 public: | 301 public: |
| 296 ChromeGeolocationDelegate() = default; | 302 ChromeGeolocationDelegate() = default; |
| 297 | 303 |
| 298 scoped_refptr<device::AccessTokenStore> CreateAccessTokenStore() final { | 304 scoped_refptr<device::AccessTokenStore> CreateAccessTokenStore() final { |
| 299 return new ChromeAccessTokenStore(); | 305 return new ChromeAccessTokenStore(); |
| 300 } | 306 } |
| 301 | 307 |
| 302 private: | 308 private: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 // |pool_descriptor| is a semi-colon separated value string with the following | 349 // |pool_descriptor| is a semi-colon separated value string with the following |
| 344 // items: | 350 // items: |
| 345 // 1. Minimum Thread Count (int) | 351 // 1. Minimum Thread Count (int) |
| 346 // 2. Maximum Thread Count (int) | 352 // 2. Maximum Thread Count (int) |
| 347 // 3. Thread Count Multiplier (double) | 353 // 3. Thread Count Multiplier (double) |
| 348 // 4. Thread Count Offset (int) | 354 // 4. Thread Count Offset (int) |
| 349 // 5. Detach Time in Milliseconds (milliseconds) | 355 // 5. Detach Time in Milliseconds (milliseconds) |
| 350 // Additional values may appear as necessary and will be ignored. | 356 // Additional values may appear as necessary and will be ignored. |
| 351 WorkerPoolVariationValues StringToWorkerPoolVariationValues( | 357 WorkerPoolVariationValues StringToWorkerPoolVariationValues( |
| 352 const base::StringPiece pool_descriptor) { | 358 const base::StringPiece pool_descriptor) { |
| 353 const std::vector<std::string> tokens = | 359 const std::vector<std::string> tokens = SplitString( |
| 354 SplitString(pool_descriptor, ";", | 360 pool_descriptor, ";", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 355 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | |
| 356 int minimum; | 361 int minimum; |
| 357 int maximum; | 362 int maximum; |
| 358 double multiplier; | 363 double multiplier; |
| 359 int offset; | 364 int offset; |
| 360 int detach_milliseconds; | 365 int detach_milliseconds; |
| 361 // Checking for a size greater than the expected amount allows us to be | 366 // Checking for a size greater than the expected amount allows us to be |
| 362 // forward compatible if we add more variation values. | 367 // forward compatible if we add more variation values. |
| 363 if (tokens.size() >= 5 && | 368 if (tokens.size() >= 5 && base::StringToInt(tokens[0], &minimum) && |
| 364 base::StringToInt(tokens[0], &minimum) && | |
| 365 base::StringToInt(tokens[1], &maximum) && | 369 base::StringToInt(tokens[1], &maximum) && |
| 366 base::StringToDouble(tokens[2], &multiplier) && | 370 base::StringToDouble(tokens[2], &multiplier) && |
| 367 base::StringToInt(tokens[3], &offset) && | 371 base::StringToInt(tokens[3], &offset) && |
| 368 base::StringToInt(tokens[4], &detach_milliseconds)) { | 372 base::StringToInt(tokens[4], &detach_milliseconds)) { |
| 369 const int num_of_cores = base::SysInfo::NumberOfProcessors(); | 373 const int num_of_cores = base::SysInfo::NumberOfProcessors(); |
| 370 const int threads = std::ceil<int>(num_of_cores * multiplier) + offset; | 374 const int threads = std::ceil<int>(num_of_cores * multiplier) + offset; |
| 371 WorkerPoolVariationValues values; | 375 WorkerPoolVariationValues values; |
| 372 values.threads = std::min(maximum, std::max(minimum, threads)); | 376 values.threads = std::min(maximum, std::max(minimum, threads)); |
| 373 values.detach_period = | 377 values.detach_period = |
| 374 base::TimeDelta::FromMilliseconds(detach_milliseconds); | 378 base::TimeDelta::FromMilliseconds(detach_milliseconds); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 } | 411 } |
| 408 | 412 |
| 409 using ThreadPriority = base::ThreadPriority; | 413 using ThreadPriority = base::ThreadPriority; |
| 410 using IORestriction = base::SchedulerWorkerPoolParams::IORestriction; | 414 using IORestriction = base::SchedulerWorkerPoolParams::IORestriction; |
| 411 struct SchedulerWorkerPoolPredefinedParams { | 415 struct SchedulerWorkerPoolPredefinedParams { |
| 412 const char* name; | 416 const char* name; |
| 413 ThreadPriority priority_hint; | 417 ThreadPriority priority_hint; |
| 414 IORestriction io_restriction; | 418 IORestriction io_restriction; |
| 415 }; | 419 }; |
| 416 static const SchedulerWorkerPoolPredefinedParams kAllPredefinedParams[] = { | 420 static const SchedulerWorkerPoolPredefinedParams kAllPredefinedParams[] = { |
| 417 {"Background", ThreadPriority::BACKGROUND, IORestriction::DISALLOWED}, | 421 {"Background", ThreadPriority::BACKGROUND, IORestriction::DISALLOWED}, |
| 418 {"BackgroundFileIO", ThreadPriority::BACKGROUND, IORestriction::ALLOWED}, | 422 {"BackgroundFileIO", ThreadPriority::BACKGROUND, IORestriction::ALLOWED}, |
| 419 {"Foreground", ThreadPriority::NORMAL, IORestriction::DISALLOWED}, | 423 {"Foreground", ThreadPriority::NORMAL, IORestriction::DISALLOWED}, |
| 420 {"ForegroundFileIO", ThreadPriority::NORMAL, IORestriction::ALLOWED}, | 424 {"ForegroundFileIO", ThreadPriority::NORMAL, IORestriction::ALLOWED}, |
| 421 }; | 425 }; |
| 422 static_assert(arraysize(kAllPredefinedParams) == WORKER_POOL_COUNT, | 426 static_assert(arraysize(kAllPredefinedParams) == WORKER_POOL_COUNT, |
| 423 "Mismatched Worker Pool Types and Predefined Parameters"); | 427 "Mismatched Worker Pool Types and Predefined Parameters"); |
| 424 | 428 |
| 425 std::vector<base::SchedulerWorkerPoolParams> params_vector; | 429 std::vector<base::SchedulerWorkerPoolParams> params_vector; |
| 426 for (const auto& predefined_params : kAllPredefinedParams) { | 430 for (const auto& predefined_params : kAllPredefinedParams) { |
| 427 const auto pair = variation_params.find(predefined_params.name); | 431 const auto pair = variation_params.find(predefined_params.name); |
| 428 if (pair == variation_params.end()) { | 432 if (pair == variation_params.end()) { |
| 429 DLOG(ERROR) << "Missing Worker Pool Configuration: " | 433 DLOG(ERROR) << "Missing Worker Pool Configuration: " |
| 430 << predefined_params.name; | 434 << predefined_params.name; |
| 431 return; | 435 return; |
| 432 } | 436 } |
| 433 | 437 |
| 434 const WorkerPoolVariationValues variation_values = | 438 const WorkerPoolVariationValues variation_values = |
| 435 StringToWorkerPoolVariationValues(pair->second); | 439 StringToWorkerPoolVariationValues(pair->second); |
| 436 | 440 |
| 437 if (variation_values.threads <= 0 || | 441 if (variation_values.threads <= 0 || |
| 438 variation_values.detach_period.is_zero()) { | 442 variation_values.detach_period.is_zero()) { |
| 439 DLOG(ERROR) << "Invalid Worker Pool Configuration: " << | 443 DLOG(ERROR) << "Invalid Worker Pool Configuration: " |
| 440 predefined_params.name << " [" << pair->second << "]"; | 444 << predefined_params.name << " [" << pair->second << "]"; |
| 441 return; | 445 return; |
| 442 } | 446 } |
| 443 | 447 |
| 444 params_vector.emplace_back(predefined_params.name, | 448 params_vector.emplace_back( |
| 445 predefined_params.priority_hint, | 449 predefined_params.name, predefined_params.priority_hint, |
| 446 predefined_params.io_restriction, | 450 predefined_params.io_restriction, variation_values.threads, |
| 447 variation_values.threads, | 451 variation_values.detach_period); |
| 448 variation_values.detach_period); | |
| 449 } | 452 } |
| 450 | 453 |
| 451 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size()); | 454 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size()); |
| 452 | 455 |
| 453 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( | 456 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( |
| 454 params_vector, base::Bind(WorkerPoolIndexForTraits)); | 457 params_vector, base::Bind(WorkerPoolIndexForTraits)); |
| 455 } | 458 } |
| 456 | 459 |
| 457 // Returns the new local state object, guaranteed non-NULL. | 460 // Returns the new local state object, guaranteed non-NULL. |
| 458 // |local_state_task_runner| must be a shutdown-blocking task runner. | 461 // |local_state_task_runner| must be a shutdown-blocking task runner. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 // missing code in the above test. | 577 // missing code in the above test. |
| 575 CHECK(profile) << "Cannot get default profile."; | 578 CHECK(profile) << "Cannot get default profile."; |
| 576 | 579 |
| 577 #else | 580 #else |
| 578 profile = GetStartupProfile(user_data_dir, parsed_command_line); | 581 profile = GetStartupProfile(user_data_dir, parsed_command_line); |
| 579 | 582 |
| 580 if (!profile && !profile_dir_specified) | 583 if (!profile && !profile_dir_specified) |
| 581 profile = GetFallbackStartupProfile(); | 584 profile = GetFallbackStartupProfile(); |
| 582 | 585 |
| 583 if (!profile) { | 586 if (!profile) { |
| 584 ProfileErrorType error_type = profile_dir_specified ? | 587 ProfileErrorType error_type = profile_dir_specified |
| 585 PROFILE_ERROR_CREATE_FAILURE_SPECIFIED : | 588 ? PROFILE_ERROR_CREATE_FAILURE_SPECIFIED |
| 586 PROFILE_ERROR_CREATE_FAILURE_ALL; | 589 : PROFILE_ERROR_CREATE_FAILURE_ALL; |
| 587 | 590 |
| 588 // TODO(lwchkg): What diagnostics do you want to include in the feedback | 591 // TODO(lwchkg): What diagnostics do you want to include in the feedback |
| 589 // report when an error occurs? | 592 // report when an error occurs? |
| 590 ShowProfileErrorDialog(error_type, IDS_COULDNT_STARTUP_PROFILE_ERROR, | 593 ShowProfileErrorDialog(error_type, IDS_COULDNT_STARTUP_PROFILE_ERROR, |
| 591 "Error creating primary profile."); | 594 "Error creating primary profile."); |
| 592 return nullptr; | 595 return nullptr; |
| 593 } | 596 } |
| 594 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) | 597 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 595 | 598 |
| 596 UMA_HISTOGRAM_LONG_TIMES( | 599 UMA_HISTOGRAM_LONG_TIMES("Startup.CreateFirstProfile", |
| 597 "Startup.CreateFirstProfile", base::Time::Now() - start); | 600 base::Time::Now() - start); |
| 598 return profile; | 601 return profile; |
| 599 } | 602 } |
| 600 | 603 |
| 601 #if defined(OS_MACOSX) | 604 #if defined(OS_MACOSX) |
| 602 OSStatus KeychainCallback(SecKeychainEvent keychain_event, | 605 OSStatus KeychainCallback(SecKeychainEvent keychain_event, |
| 603 SecKeychainCallbackInfo* info, void* context) { | 606 SecKeychainCallbackInfo* info, |
| 607 void* context) { | |
| 604 return noErr; | 608 return noErr; |
| 605 } | 609 } |
| 606 #endif // defined(OS_MACOSX) | 610 #endif // defined(OS_MACOSX) |
| 607 | 611 |
| 608 void RegisterComponentsForUpdate() { | 612 void RegisterComponentsForUpdate() { |
| 609 component_updater::ComponentUpdateService* cus = | 613 component_updater::ComponentUpdateService* cus = |
| 610 g_browser_process->component_updater(); | 614 g_browser_process->component_updater(); |
| 611 | 615 |
| 612 // Registration can be before or after cus->Start() so it is ok to post | 616 // Registration can be before or after cus->Start() so it is ok to post |
| 613 // a task to the UI thread to do registration once you done the necessary | 617 // a task to the UI thread to do registration once you done the necessary |
| 614 // file IO to know you existing component version. | 618 // file IO to know you existing component version. |
| 615 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 619 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 616 RegisterRecoveryComponent(cus, g_browser_process->local_state()); | 620 RegisterRecoveryComponent(cus, g_browser_process->local_state()); |
| 617 RegisterPepperFlashComponent(cus); | 621 RegisterPepperFlashComponent(cus); |
| 618 RegisterSwiftShaderComponent(cus); | 622 RegisterSwiftShaderComponent(cus); |
| 619 RegisterWidevineCdmComponent(cus); | 623 RegisterWidevineCdmComponent(cus); |
| 620 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 624 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 621 | 625 |
| 622 #if !defined(DISABLE_NACL) && !defined(OS_ANDROID) | 626 #if !defined(DISABLE_NACL) && !defined(OS_ANDROID) |
| 623 #if defined(OS_CHROMEOS) | 627 #if defined(OS_CHROMEOS) |
| 624 // PNaCl on Chrome OS is on rootfs and there is no need to download it. But | 628 // PNaCl on Chrome OS is on rootfs and there is no need to download it. But |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 std::string start_time_string = | 685 std::string start_time_string = |
| 682 command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime); | 686 command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime); |
| 683 int64_t remote_start_time; | 687 int64_t remote_start_time; |
| 684 if (base::StringToInt64(start_time_string, &remote_start_time)) { | 688 if (base::StringToInt64(start_time_string, &remote_start_time)) { |
| 685 base::TimeDelta elapsed = | 689 base::TimeDelta elapsed = |
| 686 base::Time::Now() - base::Time::FromInternalValue(remote_start_time); | 690 base::Time::Now() - base::Time::FromInternalValue(remote_start_time); |
| 687 if (command_line.HasSwitch(switches::kFastStart)) { | 691 if (command_line.HasSwitch(switches::kFastStart)) { |
| 688 UMA_HISTOGRAM_LONG_TIMES( | 692 UMA_HISTOGRAM_LONG_TIMES( |
| 689 "Startup.WarmStartTimeFromRemoteProcessStartFast", elapsed); | 693 "Startup.WarmStartTimeFromRemoteProcessStartFast", elapsed); |
| 690 } else { | 694 } else { |
| 691 UMA_HISTOGRAM_LONG_TIMES( | 695 UMA_HISTOGRAM_LONG_TIMES("Startup.WarmStartTimeFromRemoteProcessStart", |
| 692 "Startup.WarmStartTimeFromRemoteProcessStart", elapsed); | 696 elapsed); |
| 693 } | 697 } |
| 694 } | 698 } |
| 695 } | 699 } |
| 696 | 700 |
| 697 g_browser_process->platform_part()->PlatformSpecificCommandLineProcessing( | 701 g_browser_process->platform_part()->PlatformSpecificCommandLineProcessing( |
| 698 command_line); | 702 command_line); |
| 699 | 703 |
| 700 base::FilePath user_data_dir = | 704 base::FilePath user_data_dir = |
| 701 g_browser_process->profile_manager()->user_data_dir(); | 705 g_browser_process->profile_manager()->user_data_dir(); |
| 702 base::FilePath startup_profile_dir = | 706 base::FilePath startup_profile_dir = |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 808 if (parameters.ui_task) | 812 if (parameters.ui_task) |
| 809 browser_defaults::enable_help_app = false; | 813 browser_defaults::enable_help_app = false; |
| 810 | 814 |
| 811 // Chrome disallows cookies by default. All code paths that want to use | 815 // Chrome disallows cookies by default. All code paths that want to use |
| 812 // cookies need to go through one of Chrome's URLRequestContexts which have | 816 // cookies need to go through one of Chrome's URLRequestContexts which have |
| 813 // a ChromeNetworkDelegate attached that selectively allows cookies again. | 817 // a ChromeNetworkDelegate attached that selectively allows cookies again. |
| 814 net::URLRequest::SetDefaultCookiePolicyToBlock(); | 818 net::URLRequest::SetDefaultCookiePolicyToBlock(); |
| 815 } | 819 } |
| 816 | 820 |
| 817 ChromeBrowserMainParts::~ChromeBrowserMainParts() { | 821 ChromeBrowserMainParts::~ChromeBrowserMainParts() { |
| 818 for (int i = static_cast<int>(chrome_extra_parts_.size())-1; i >= 0; --i) | 822 for (int i = static_cast<int>(chrome_extra_parts_.size()) - 1; i >= 0; --i) |
| 819 delete chrome_extra_parts_[i]; | 823 delete chrome_extra_parts_[i]; |
| 820 chrome_extra_parts_.clear(); | 824 chrome_extra_parts_.clear(); |
| 821 } | 825 } |
| 822 | 826 |
| 823 // This will be called after the command-line has been mutated by about:flags | 827 // This will be called after the command-line has been mutated by about:flags |
| 824 void ChromeBrowserMainParts::SetupMetricsAndFieldTrials() { | 828 void ChromeBrowserMainParts::SetupMetricsAndFieldTrials() { |
| 825 TRACE_EVENT0("startup", "ChromeBrowserMainParts::SetupMetricsAndFieldTrials"); | 829 TRACE_EVENT0("startup", "ChromeBrowserMainParts::SetupMetricsAndFieldTrials"); |
| 826 // Must initialize metrics after labs have been converted into switches, | 830 // Must initialize metrics after labs have been converted into switches, |
| 827 // but before field trials are set up (so that client ID is available for | 831 // but before field trials are set up (so that client ID is available for |
| 828 // one-time randomized field trials). | 832 // one-time randomized field trials). |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 CHECK(result) << "Invalid --" << switches::kForceFieldTrials | 868 CHECK(result) << "Invalid --" << switches::kForceFieldTrials |
| 865 << " list specified."; | 869 << " list specified."; |
| 866 } | 870 } |
| 867 | 871 |
| 868 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 872 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 869 | 873 |
| 870 // Associate parameters chosen in about:flags and create trial/group for them. | 874 // Associate parameters chosen in about:flags and create trial/group for them. |
| 871 flags_ui::PrefServiceFlagsStorage flags_storage( | 875 flags_ui::PrefServiceFlagsStorage flags_storage( |
| 872 g_browser_process->local_state()); | 876 g_browser_process->local_state()); |
| 873 std::vector<std::string> variation_ids = | 877 std::vector<std::string> variation_ids = |
| 874 about_flags::RegisterAllFeatureVariationParameters( | 878 about_flags::RegisterAllFeatureVariationParameters(&flags_storage, |
| 875 &flags_storage, feature_list.get()); | 879 feature_list.get()); |
| 876 | 880 |
| 877 variations::VariationsHttpHeaderProvider* http_header_provider = | 881 variations::VariationsHttpHeaderProvider* http_header_provider = |
| 878 variations::VariationsHttpHeaderProvider::GetInstance(); | 882 variations::VariationsHttpHeaderProvider::GetInstance(); |
| 879 // Force the variation ids selected in chrome://flags and/or specified using | 883 // Force the variation ids selected in chrome://flags and/or specified using |
| 880 // the command-line flag. | 884 // the command-line flag. |
| 881 bool result = http_header_provider->ForceVariationIds( | 885 bool result = http_header_provider->ForceVariationIds( |
| 882 command_line->GetSwitchValueASCII(switches::kForceVariationIds), | 886 command_line->GetSwitchValueASCII(switches::kForceVariationIds), |
| 883 &variation_ids); | 887 &variation_ids); |
| 884 CHECK(result) << "Invalid list of variation ids specified (either in --" | 888 CHECK(result) << "Invalid list of variation ids specified (either in --" |
| 885 << switches::kForceVariationIds << " or in chrome://flags)"; | 889 << switches::kForceVariationIds << " or in chrome://flags)"; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1109 run_message_loop_ = false; | 1113 run_message_loop_ = false; |
| 1110 #if !defined(OS_ANDROID) | 1114 #if !defined(OS_ANDROID) |
| 1111 chrome::MaybeShowInvalidUserDataDirWarningDialog(); | 1115 chrome::MaybeShowInvalidUserDataDirWarningDialog(); |
| 1112 #endif // !defined(OS_ANDROID) | 1116 #endif // !defined(OS_ANDROID) |
| 1113 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) | 1117 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) |
| 1114 return chrome::RESULT_CODE_MISSING_DATA; | 1118 return chrome::RESULT_CODE_MISSING_DATA; |
| 1115 | 1119 |
| 1116 // Force MediaCaptureDevicesDispatcher to be created on UI thread. | 1120 // Force MediaCaptureDevicesDispatcher to be created on UI thread. |
| 1117 MediaCaptureDevicesDispatcher::GetInstance(); | 1121 MediaCaptureDevicesDispatcher::GetInstance(); |
| 1118 | 1122 |
| 1119 // Android's first run is done in Java instead of native. | 1123 // Android's first run is done in Java instead of native. |
| 1120 #if !defined(OS_ANDROID) | 1124 #if !defined(OS_ANDROID) |
| 1121 process_singleton_.reset(new ChromeProcessSingleton( | 1125 process_singleton_.reset(new ChromeProcessSingleton( |
| 1122 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); | 1126 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); |
| 1123 | 1127 |
| 1124 // Cache first run state early. | 1128 // Cache first run state early. |
| 1125 first_run::IsChromeFirstRun(); | 1129 first_run::IsChromeFirstRun(); |
| 1126 #endif // !defined(OS_ANDROID) | 1130 #endif // !defined(OS_ANDROID) |
| 1127 | 1131 |
| 1128 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = | 1132 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = |
| 1129 JsonPrefStore::GetTaskRunnerForFile( | 1133 JsonPrefStore::GetTaskRunnerForFile( |
| 1130 base::FilePath(chrome::kLocalStorePoolName), | 1134 base::FilePath(chrome::kLocalStorePoolName), |
| 1131 BrowserThread::GetBlockingPool()); | 1135 BrowserThread::GetBlockingPool()); |
| 1132 | 1136 |
| 1133 { | 1137 { |
| 1134 TRACE_EVENT0("startup", | 1138 TRACE_EVENT0( |
| 1135 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitBrowswerProcessImpl"); | 1139 "startup", |
| 1140 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitBrowswerProcessImpl"); | |
| 1136 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner.get(), | 1141 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner.get(), |
| 1137 parsed_command_line())); | 1142 parsed_command_line())); |
| 1138 } | 1143 } |
| 1139 | 1144 |
| 1140 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { | 1145 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { |
| 1141 TRACE_EVENT0("startup", | 1146 TRACE_EVENT0("startup", |
| 1142 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitProfiling"); | 1147 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitProfiling"); |
| 1143 // User wants to override default tracking status. | 1148 // User wants to override default tracking status. |
| 1144 std::string flag = | 1149 std::string flag = |
| 1145 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); | 1150 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); |
| 1146 // Default to basic profiling (no parent child support). | 1151 // Default to basic profiling (no parent child support). |
| 1147 tracked_objects::ThreadData::Status status = | 1152 tracked_objects::ThreadData::Status status = |
| 1148 tracked_objects::ThreadData::PROFILING_ACTIVE; | 1153 tracked_objects::ThreadData::PROFILING_ACTIVE; |
| 1149 if (flag.compare("0") != 0) | 1154 if (flag.compare("0") != 0) |
| 1150 status = tracked_objects::ThreadData::DEACTIVATED; | 1155 status = tracked_objects::ThreadData::DEACTIVATED; |
| 1151 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); | 1156 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); |
| 1152 } | 1157 } |
| 1153 | 1158 |
| 1154 local_state_ = InitializeLocalState( | 1159 local_state_ = InitializeLocalState(local_state_task_runner.get(), |
| 1155 local_state_task_runner.get(), parsed_command_line()); | 1160 parsed_command_line()); |
| 1156 | 1161 |
| 1157 #if !defined(OS_ANDROID) | 1162 #if !defined(OS_ANDROID) |
| 1158 // These members must be initialized before returning from this function. | 1163 // These members must be initialized before returning from this function. |
| 1159 master_prefs_.reset(new first_run::MasterPrefs); | 1164 master_prefs_.reset(new first_run::MasterPrefs); |
| 1160 // Android doesn't use StartupBrowserCreator. | 1165 // Android doesn't use StartupBrowserCreator. |
| 1161 browser_creator_.reset(new StartupBrowserCreator); | 1166 browser_creator_.reset(new StartupBrowserCreator); |
| 1162 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver | 1167 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver |
| 1163 chrome::UMABrowsingActivityObserver::Init(); | 1168 chrome::UMABrowsingActivityObserver::Init(); |
| 1164 #endif // !defined(OS_ANDROID) | 1169 #endif // !defined(OS_ANDROID) |
| 1165 | 1170 |
| 1166 #if !defined(OS_CHROMEOS) | 1171 #if !defined(OS_CHROMEOS) |
| 1167 // Convert active labs into switches. This needs to be done before | 1172 // Convert active labs into switches. This needs to be done before |
| 1168 // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are | 1173 // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are |
| 1169 // affected by experiment flags (--touch-optimized-ui in particular). | 1174 // affected by experiment flags (--touch-optimized-ui in particular). |
| 1170 // On ChromeOS system level flags are applied from the device settings from | 1175 // On ChromeOS system level flags are applied from the device settings from |
| 1171 // the session manager. | 1176 // the session manager. |
| 1172 { | 1177 { |
| 1173 TRACE_EVENT0("startup", | 1178 TRACE_EVENT0("startup", |
| 1174 "ChromeBrowserMainParts::PreCreateThreadsImpl:ConvertFlags"); | 1179 "ChromeBrowserMainParts::PreCreateThreadsImpl:ConvertFlags"); |
| 1175 flags_ui::PrefServiceFlagsStorage flags_storage( | 1180 flags_ui::PrefServiceFlagsStorage flags_storage( |
| 1176 g_browser_process->local_state()); | 1181 g_browser_process->local_state()); |
| 1177 about_flags::ConvertFlagsToSwitches(&flags_storage, | 1182 about_flags::ConvertFlagsToSwitches(&flags_storage, |
| 1178 base::CommandLine::ForCurrentProcess(), | 1183 base::CommandLine::ForCurrentProcess(), |
| 1179 flags_ui::kAddSentinels); | 1184 flags_ui::kAddSentinels); |
| 1180 } | 1185 } |
| 1181 #endif // !defined(OS_CHROMEOS) | 1186 #endif // !defined(OS_CHROMEOS) |
| 1182 // The MaterialDesignController needs to look at command line flags, which | 1187 // The MaterialDesignController needs to look at command line flags, which |
| 1183 // are not available until this point. Now that they are, proceed with | 1188 // are not available until this point. Now that they are, proceed with |
| 1184 // initializing the MaterialDesignController. | 1189 // initializing the MaterialDesignController. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1200 #endif // OS_WIN | 1205 #endif // OS_WIN |
| 1201 | 1206 |
| 1202 local_state_->UpdateCommandLinePrefStore( | 1207 local_state_->UpdateCommandLinePrefStore( |
| 1203 new CommandLinePrefStore(base::CommandLine::ForCurrentProcess())); | 1208 new CommandLinePrefStore(base::CommandLine::ForCurrentProcess())); |
| 1204 | 1209 |
| 1205 // Reset the command line in the crash report details, since we may have | 1210 // Reset the command line in the crash report details, since we may have |
| 1206 // just changed it to include experiments. | 1211 // just changed it to include experiments. |
| 1207 crash_keys::SetCrashKeysFromCommandLine( | 1212 crash_keys::SetCrashKeysFromCommandLine( |
| 1208 *base::CommandLine::ForCurrentProcess()); | 1213 *base::CommandLine::ForCurrentProcess()); |
| 1209 | 1214 |
| 1210 // Mac starts it earlier in |PreMainMessageLoopStart()| (because it is | 1215 // Mac starts it earlier in |PreMainMessageLoopStart()| (because it is |
| 1211 // needed when loading the MainMenu.nib and the language doesn't depend on | 1216 // needed when loading the MainMenu.nib and the language doesn't depend on |
| 1212 // anything since it comes from Cocoa. | 1217 // anything since it comes from Cocoa. |
| 1213 #if defined(OS_MACOSX) | 1218 #if defined(OS_MACOSX) |
| 1214 std::string locale = | 1219 std::string locale = |
| 1215 parameters().ui_task ? "en-US" : l10n_util::GetLocaleOverride(); | 1220 parameters().ui_task ? "en-US" : l10n_util::GetLocaleOverride(); |
| 1216 browser_process_->SetApplicationLocale(locale); | 1221 browser_process_->SetApplicationLocale(locale); |
| 1217 #else | 1222 #else |
| 1218 const std::string locale = | 1223 const std::string locale = local_state_->GetString(prefs::kApplicationLocale); |
| 1219 local_state_->GetString(prefs::kApplicationLocale); | |
| 1220 | 1224 |
| 1221 // On a POSIX OS other than ChromeOS, the parameter that is passed to the | 1225 // On a POSIX OS other than ChromeOS, the parameter that is passed to the |
| 1222 // method InitSharedInstance is ignored. | 1226 // method InitSharedInstance is ignored. |
| 1223 | 1227 |
| 1224 TRACE_EVENT_BEGIN0("startup", | 1228 TRACE_EVENT_BEGIN0( |
| 1229 "startup", | |
| 1225 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); | 1230 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); |
| 1226 const std::string loaded_locale = | 1231 const std::string loaded_locale = |
| 1227 ui::ResourceBundle::InitSharedInstanceWithLocale( | 1232 ui::ResourceBundle::InitSharedInstanceWithLocale( |
| 1228 locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 1233 locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
| 1229 TRACE_EVENT_END0("startup", | 1234 TRACE_EVENT_END0( |
| 1235 "startup", | |
| 1230 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); | 1236 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); |
| 1231 | 1237 |
| 1232 if (loaded_locale.empty() && | 1238 if (loaded_locale.empty() && |
| 1233 !parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) { | 1239 !parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) { |
| 1234 ShowMissingLocaleMessageBox(); | 1240 ShowMissingLocaleMessageBox(); |
| 1235 return chrome::RESULT_CODE_MISSING_DATA; | 1241 return chrome::RESULT_CODE_MISSING_DATA; |
| 1236 } | 1242 } |
| 1237 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; | 1243 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; |
| 1238 browser_process_->SetApplicationLocale(loaded_locale); | 1244 browser_process_->SetApplicationLocale(loaded_locale); |
| 1239 | 1245 |
| 1240 { | 1246 { |
| 1241 TRACE_EVENT0("startup", | 1247 TRACE_EVENT0("startup", |
| 1242 "ChromeBrowserMainParts::PreCreateThreadsImpl:AddDataPack"); | 1248 "ChromeBrowserMainParts::PreCreateThreadsImpl:AddDataPack"); |
| 1243 base::FilePath resources_pack_path; | 1249 base::FilePath resources_pack_path; |
| 1244 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); | 1250 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| 1245 #if defined(OS_ANDROID) | 1251 #if defined(OS_ANDROID) |
| 1246 ui::LoadMainAndroidPackFile("assets/resources.pak", resources_pack_path); | 1252 ui::LoadMainAndroidPackFile("assets/resources.pak", resources_pack_path); |
| 1247 #else | 1253 #else |
| 1248 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 1254 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 1249 resources_pack_path, ui::SCALE_FACTOR_NONE); | 1255 resources_pack_path, ui::SCALE_FACTOR_NONE); |
| 1250 #endif // defined(OS_ANDROID) | 1256 #endif // defined(OS_ANDROID) |
| 1251 } | 1257 } |
| 1252 #endif // defined(OS_MACOSX) | 1258 #endif // defined(OS_MACOSX) |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1439 | 1445 |
| 1440 namespace { | 1446 namespace { |
| 1441 | 1447 |
| 1442 void WINAPI SyzyASANExperimentCallback(const char* name, const char* group) { | 1448 void WINAPI SyzyASANExperimentCallback(const char* name, const char* group) { |
| 1443 // Indirect through the function above, so that the friend declaration doesn't | 1449 // Indirect through the function above, so that the friend declaration doesn't |
| 1444 // need the ugly calling convention. | 1450 // need the ugly calling convention. |
| 1445 SyzyASANRegisterExperiment(name, group); | 1451 SyzyASANRegisterExperiment(name, group); |
| 1446 } | 1452 } |
| 1447 | 1453 |
| 1448 void SetupSyzyASAN() { | 1454 void SetupSyzyASAN() { |
| 1449 typedef VOID(WINAPI* SyzyASANExperimentCallbackFn)(const char* name, | 1455 typedef VOID(WINAPI * SyzyASANExperimentCallbackFn)(const char* name, |
| 1450 const char* group); | 1456 const char* group); |
| 1451 typedef VOID(WINAPI* SyzyASANEnumExperimentsFn)(SyzyASANExperimentCallbackFn); | 1457 typedef VOID(WINAPI * |
| 1458 SyzyASANEnumExperimentsFn)(SyzyASANExperimentCallbackFn); | |
| 1452 HMODULE syzyasan_handle = ::GetModuleHandle(L"syzyasan_rtl.dll"); | 1459 HMODULE syzyasan_handle = ::GetModuleHandle(L"syzyasan_rtl.dll"); |
| 1453 if (!syzyasan_handle) | 1460 if (!syzyasan_handle) |
| 1454 return; | 1461 return; |
| 1455 | 1462 |
| 1456 // Export the SyzyASAN experiments as synthetic field trials. | 1463 // Export the SyzyASAN experiments as synthetic field trials. |
| 1457 SyzyASANEnumExperimentsFn syzyasan_enum_experiments = | 1464 SyzyASANEnumExperimentsFn syzyasan_enum_experiments = |
| 1458 reinterpret_cast<SyzyASANEnumExperimentsFn>( | 1465 reinterpret_cast<SyzyASANEnumExperimentsFn>( |
| 1459 ::GetProcAddress(syzyasan_handle, "asan_EnumExperiments")); | 1466 ::GetProcAddress(syzyasan_handle, "asan_EnumExperiments")); |
| 1460 if (syzyasan_enum_experiments) { | 1467 if (syzyasan_enum_experiments) { |
| 1461 syzyasan_enum_experiments(&SyzyASANExperimentCallback); | 1468 syzyasan_enum_experiments(&SyzyASANExperimentCallback); |
| 1462 } | 1469 } |
| 1463 | 1470 |
| 1464 // Enable the deferred free mechanism in the syzyasan module, which helps the | 1471 // Enable the deferred free mechanism in the syzyasan module, which helps the |
| 1465 // performance by deferring some work on the critical path to a background | 1472 // performance by deferring some work on the critical path to a background |
| 1466 // thread. | 1473 // thread. |
| 1467 if (base::FeatureList::IsEnabled(features::kSyzyasanDeferredFree)) { | 1474 if (base::FeatureList::IsEnabled(features::kSyzyasanDeferredFree)) { |
| 1468 typedef VOID(WINAPI * SyzyasanEnableDeferredFreeThreadFunc)(VOID); | 1475 typedef VOID(WINAPI * SyzyasanEnableDeferredFreeThreadFunc)(VOID); |
| 1469 bool success = false; | 1476 bool success = false; |
| 1470 SyzyasanEnableDeferredFreeThreadFunc syzyasan_enable_deferred_free = | 1477 SyzyasanEnableDeferredFreeThreadFunc syzyasan_enable_deferred_free = |
| 1471 reinterpret_cast<SyzyasanEnableDeferredFreeThreadFunc>( | 1478 reinterpret_cast<SyzyasanEnableDeferredFreeThreadFunc>( |
| 1472 ::GetProcAddress(syzyasan_handle, | 1479 ::GetProcAddress(syzyasan_handle, "asan_EnableDeferredFreeThread")); |
| 1473 "asan_EnableDeferredFreeThread")); | |
| 1474 if (syzyasan_enable_deferred_free) { | 1480 if (syzyasan_enable_deferred_free) { |
| 1475 syzyasan_enable_deferred_free(); | 1481 syzyasan_enable_deferred_free(); |
| 1476 success = true; | 1482 success = true; |
| 1477 } | 1483 } |
| 1478 UMA_HISTOGRAM_BOOLEAN("Syzyasan.DeferredFreeWasEnabled", success); | 1484 UMA_HISTOGRAM_BOOLEAN("Syzyasan.DeferredFreeWasEnabled", success); |
| 1479 } | 1485 } |
| 1480 } | 1486 } |
| 1481 | 1487 |
| 1482 } // namespace | 1488 } // namespace |
| 1483 | 1489 |
| 1484 #endif // SYZYASAN | 1490 #endif // SYZYASAN |
| 1485 | 1491 |
| 1486 | |
| 1487 void ChromeBrowserMainParts::PreBrowserStart() { | 1492 void ChromeBrowserMainParts::PreBrowserStart() { |
| 1488 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreBrowserStart"); | 1493 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreBrowserStart"); |
| 1489 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1494 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 1490 chrome_extra_parts_[i]->PreBrowserStart(); | 1495 chrome_extra_parts_[i]->PreBrowserStart(); |
| 1491 | 1496 |
| 1492 three_d_observer_.reset(new ThreeDAPIObserver()); | 1497 three_d_observer_.reset(new ThreeDAPIObserver()); |
| 1493 | 1498 |
| 1494 #if defined(SYZYASAN) | 1499 #if defined(SYZYASAN) |
| 1495 SetupSyzyASAN(); | 1500 SetupSyzyASAN(); |
| 1496 #endif | 1501 #endif |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1507 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1512 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 1508 chrome_extra_parts_[i]->PostBrowserStart(); | 1513 chrome_extra_parts_[i]->PostBrowserStart(); |
| 1509 #if !defined(OS_ANDROID) | 1514 #if !defined(OS_ANDROID) |
| 1510 // Allow ProcessSingleton to process messages. | 1515 // Allow ProcessSingleton to process messages. |
| 1511 process_singleton_->Unlock(); | 1516 process_singleton_->Unlock(); |
| 1512 #endif // !defined(OS_ANDROID) | 1517 #endif // !defined(OS_ANDROID) |
| 1513 #if defined(ENABLE_WEBRTC) | 1518 #if defined(ENABLE_WEBRTC) |
| 1514 // Set up a task to delete old WebRTC log files for all profiles. Use a delay | 1519 // Set up a task to delete old WebRTC log files for all profiles. Use a delay |
| 1515 // to reduce the impact on startup time. | 1520 // to reduce the impact on startup time. |
| 1516 BrowserThread::PostDelayedTask( | 1521 BrowserThread::PostDelayedTask( |
| 1517 BrowserThread::UI, | 1522 BrowserThread::UI, FROM_HERE, |
| 1518 FROM_HERE, | |
| 1519 base::Bind(&WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles), | 1523 base::Bind(&WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles), |
| 1520 base::TimeDelta::FromMinutes(1)); | 1524 base::TimeDelta::FromMinutes(1)); |
| 1521 #endif // defined(ENABLE_WEBRTC) | 1525 #endif // defined(ENABLE_WEBRTC) |
| 1522 | 1526 |
| 1523 #if !defined(OS_ANDROID) | 1527 #if !defined(OS_ANDROID) |
| 1524 // WebUSB is an experimental web API. The sites these notifications will link | 1528 // WebUSB is an experimental web API. The sites these notifications will link |
| 1525 // to will only work if the experiment is enabled and WebUSB feature is | 1529 // to will only work if the experiment is enabled and WebUSB feature is |
| 1526 // enabled. | 1530 // enabled. |
| 1527 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1531 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1528 switches::kEnableExperimentalWebPlatformFeatures) && | 1532 switches::kEnableExperimentalWebPlatformFeatures) && |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1557 installer::GetModulePath(installer::kChromeChildDll), | 1561 installer::GetModulePath(installer::kChromeChildDll), |
| 1558 pre_read_options)); | 1562 pre_read_options)); |
| 1559 } | 1563 } |
| 1560 | 1564 |
| 1561 // Windows parental controls calls can be slow, so we do an early init here | 1565 // Windows parental controls calls can be slow, so we do an early init here |
| 1562 // that calculates this value off of the UI thread. | 1566 // that calculates this value off of the UI thread. |
| 1563 IncognitoModePrefs::InitializePlatformParentalControls(); | 1567 IncognitoModePrefs::InitializePlatformParentalControls(); |
| 1564 #endif | 1568 #endif |
| 1565 | 1569 |
| 1566 #if defined(ENABLE_EXTENSIONS) | 1570 #if defined(ENABLE_EXTENSIONS) |
| 1567 if (!variations::GetVariationParamValue( | 1571 if (!variations::GetVariationParamValue("LightSpeed", "EarlyInitStartup") |
| 1568 "LightSpeed", "EarlyInitStartup").empty()) { | 1572 .empty()) { |
| 1569 // Try to compute this early on another thread so that we don't spend time | 1573 // Try to compute this early on another thread so that we don't spend time |
| 1570 // during profile load initializing the extensions APIs. | 1574 // during profile load initializing the extensions APIs. |
| 1571 BrowserThread::PostTask( | 1575 BrowserThread::PostTask(BrowserThread::FILE_USER_BLOCKING, FROM_HERE, |
| 1572 BrowserThread::FILE_USER_BLOCKING, | 1576 base::Bind(base::IgnoreResult( |
| 1573 FROM_HERE, | 1577 &extensions::FeatureProvider::GetAPIFeatures))); |
| 1574 base::Bind( | |
| 1575 base::IgnoreResult(&extensions::FeatureProvider::GetAPIFeatures))); | |
| 1576 } | 1578 } |
| 1577 #endif | 1579 #endif |
| 1578 | 1580 |
| 1579 // Android updates the metrics service dynamically depending on whether the | 1581 // Android updates the metrics service dynamically depending on whether the |
| 1580 // application is in the foreground or not. Do not start here. | 1582 // application is in the foreground or not. Do not start here. |
| 1581 #if !defined(OS_ANDROID) | 1583 #if !defined(OS_ANDROID) |
| 1582 // Now that the file thread has been started, start recording. | 1584 // Now that the file thread has been started, start recording. |
| 1583 StartMetricsRecording(); | 1585 StartMetricsRecording(); |
| 1584 #endif // !defined(OS_ANDROID) | 1586 #endif // !defined(OS_ANDROID) |
| 1585 | 1587 |
| 1586 if (!base::debug::BeingDebugged()) { | 1588 if (!base::debug::BeingDebugged()) { |
| 1587 // Create watchdog thread after creating all other threads because it will | 1589 // Create watchdog thread after creating all other threads because it will |
| 1588 // watch the other threads and they must be running. | 1590 // watch the other threads and they must be running. |
| 1589 browser_process_->watchdog_thread(); | 1591 browser_process_->watchdog_thread(); |
| 1590 } | 1592 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1603 bool already_running = browser_util::IsBrowserAlreadyRunning(); | 1605 bool already_running = browser_util::IsBrowserAlreadyRunning(); |
| 1604 | 1606 |
| 1605 // If the command line specifies 'uninstall' then we need to work here | 1607 // If the command line specifies 'uninstall' then we need to work here |
| 1606 // unless we detect another chrome browser running. | 1608 // unless we detect another chrome browser running. |
| 1607 if (parsed_command_line().HasSwitch(switches::kUninstall)) { | 1609 if (parsed_command_line().HasSwitch(switches::kUninstall)) { |
| 1608 return DoUninstallTasks(already_running); | 1610 return DoUninstallTasks(already_running); |
| 1609 } | 1611 } |
| 1610 | 1612 |
| 1611 if (parsed_command_line().HasSwitch(switches::kHideIcons) || | 1613 if (parsed_command_line().HasSwitch(switches::kHideIcons) || |
| 1612 parsed_command_line().HasSwitch(switches::kShowIcons)) { | 1614 parsed_command_line().HasSwitch(switches::kShowIcons)) { |
| 1613 return ChromeBrowserMainPartsWin::HandleIconsCommands( | 1615 return ChromeBrowserMainPartsWin::HandleIconsCommands(parsed_command_line_); |
| 1614 parsed_command_line_); | |
| 1615 } | 1616 } |
| 1616 | 1617 |
| 1617 ui::SelectFileDialog::SetFactory(new ChromeSelectFileDialogFactory( | 1618 ui::SelectFileDialog::SetFactory(new ChromeSelectFileDialogFactory( |
| 1618 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); | 1619 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); |
| 1619 #endif // defined(OS_WIN) | 1620 #endif // defined(OS_WIN) |
| 1620 | 1621 |
| 1621 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { | 1622 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { |
| 1622 bool is_managed = g_browser_process->local_state()->IsManagedPreference( | 1623 bool is_managed = g_browser_process->local_state()->IsManagedPreference( |
| 1623 prefs::kDefaultBrowserSettingEnabled); | 1624 prefs::kDefaultBrowserSettingEnabled); |
| 1624 if (is_managed && !g_browser_process->local_state()->GetBoolean( | 1625 if (is_managed && |
| 1625 prefs::kDefaultBrowserSettingEnabled)) { | 1626 !g_browser_process->local_state()->GetBoolean( |
| 1627 prefs::kDefaultBrowserSettingEnabled)) { | |
| 1626 return static_cast<int>(chrome::RESULT_CODE_ACTION_DISALLOWED_BY_POLICY); | 1628 return static_cast<int>(chrome::RESULT_CODE_ACTION_DISALLOWED_BY_POLICY); |
| 1627 } | 1629 } |
| 1628 | 1630 |
| 1629 return shell_integration::SetAsDefaultBrowser() | 1631 return shell_integration::SetAsDefaultBrowser() |
| 1630 ? static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) | 1632 ? static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) |
| 1631 : static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); | 1633 : static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); |
| 1632 } | 1634 } |
| 1633 | 1635 |
| 1634 #if defined(USE_AURA) | 1636 #if defined(USE_AURA) |
| 1635 // Make sure aura::Env has been initialized. | 1637 // Make sure aura::Env has been initialized. |
| 1636 CHECK(aura::Env::GetInstance()); | 1638 CHECK(aura::Env::GetInstance()); |
| 1637 #endif // defined(USE_AURA) | 1639 #endif // defined(USE_AURA) |
| 1638 | 1640 |
| 1639 // Android doesn't support extensions and doesn't implement ProcessSingleton. | 1641 // Android doesn't support extensions and doesn't implement ProcessSingleton. |
| 1640 #if !defined(OS_ANDROID) | 1642 #if !defined(OS_ANDROID) |
| 1641 // If the command line specifies --pack-extension, attempt the pack extension | 1643 // If the command line specifies --pack-extension, attempt the pack extension |
| 1642 // startup action and exit. | 1644 // startup action and exit. |
| 1643 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { | 1645 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { |
| 1644 extensions::StartupHelper extension_startup_helper; | 1646 extensions::StartupHelper extension_startup_helper; |
| 1645 if (extension_startup_helper.PackExtension(parsed_command_line())) | 1647 if (extension_startup_helper.PackExtension(parsed_command_line())) |
| 1646 return content::RESULT_CODE_NORMAL_EXIT; | 1648 return content::RESULT_CODE_NORMAL_EXIT; |
| 1647 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; | 1649 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; |
| 1648 } | 1650 } |
| 1649 | 1651 |
| 1650 // When another process is running, use that process instead of starting a | 1652 // When another process is running, use that process instead of starting a |
| 1651 // new one. NotifyOtherProcess will currently give the other process up to | 1653 // new one. NotifyOtherProcess will currently give the other process up to |
| 1652 // 20 seconds to respond. Note that this needs to be done before we attempt | 1654 // 20 seconds to respond. Note that this needs to be done before we attempt |
| 1653 // to read the profile. | 1655 // to read the profile. |
| 1654 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); | 1656 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); |
| 1655 switch (notify_result_) { | 1657 switch (notify_result_) { |
| 1656 case ProcessSingleton::PROCESS_NONE: | 1658 case ProcessSingleton::PROCESS_NONE: |
| 1657 // No process already running, fall through to starting a new one. | 1659 // No process already running, fall through to starting a new one. |
| 1658 break; | 1660 break; |
| 1659 | 1661 |
| 1660 case ProcessSingleton::PROCESS_NOTIFIED: | 1662 case ProcessSingleton::PROCESS_NOTIFIED: |
| 1661 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1663 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 1662 // On POSIX systems, print a message notifying the process is running. | 1664 // On POSIX systems, print a message notifying the process is running. |
| 1663 printf("%s\n", base::SysWideToNativeMB(base::UTF16ToWide( | 1665 printf("%s\n", base::SysWideToNativeMB( |
| 1664 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); | 1666 base::UTF16ToWide(l10n_util::GetStringUTF16( |
| 1667 IDS_USED_EXISTING_BROWSER))) | |
| 1668 .c_str()); | |
| 1665 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | 1669 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
| 1666 | 1670 |
| 1667 // Having a differentiated return type for testing allows for tests to | 1671 // Having a differentiated return type for testing allows for tests to |
| 1668 // verify proper handling of some switches. When not testing, stick to | 1672 // verify proper handling of some switches. When not testing, stick to |
| 1669 // the standard Unix convention of returning zero when things went as | 1673 // the standard Unix convention of returning zero when things went as |
| 1670 // expected. | 1674 // expected. |
| 1671 if (parsed_command_line().HasSwitch(switches::kTestType)) | 1675 if (parsed_command_line().HasSwitch(switches::kTestType)) |
| 1672 return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; | 1676 return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; |
| 1673 return content::RESULT_CODE_NORMAL_EXIT; | 1677 return content::RESULT_CODE_NORMAL_EXIT; |
| 1674 | 1678 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1745 | 1749 |
| 1746 metrics::MetricsService::SetExecutionPhase( | 1750 metrics::MetricsService::SetExecutionPhase( |
| 1747 metrics::MetricsService::CREATE_PROFILE, | 1751 metrics::MetricsService::CREATE_PROFILE, |
| 1748 g_browser_process->local_state()); | 1752 g_browser_process->local_state()); |
| 1749 | 1753 |
| 1750 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep1Time", | 1754 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep1Time", |
| 1751 base::TimeTicks::Now() - start_time_step1); | 1755 base::TimeTicks::Now() - start_time_step1); |
| 1752 | 1756 |
| 1753 // This step is costly and is already measured in Startup.CreateFirstProfile | 1757 // This step is costly and is already measured in Startup.CreateFirstProfile |
| 1754 // and more directly Profile.CreateAndInitializeProfile. | 1758 // and more directly Profile.CreateAndInitializeProfile. |
| 1755 profile_ = CreatePrimaryProfile(parameters(), | 1759 profile_ = |
| 1756 user_data_dir_, | 1760 CreatePrimaryProfile(parameters(), user_data_dir_, parsed_command_line()); |
| 1757 parsed_command_line()); | |
| 1758 if (!profile_) | 1761 if (!profile_) |
| 1759 return content::RESULT_CODE_NORMAL_EXIT; | 1762 return content::RESULT_CODE_NORMAL_EXIT; |
| 1760 | 1763 |
| 1761 #if !defined(OS_ANDROID) | 1764 #if !defined(OS_ANDROID) |
| 1762 const base::TimeTicks start_time_step2 = base::TimeTicks::Now(); | 1765 const base::TimeTicks start_time_step2 = base::TimeTicks::Now(); |
| 1763 // The first run sentinel must be created after the process singleton was | 1766 // The first run sentinel must be created after the process singleton was |
| 1764 // grabbed and no early return paths were otherwise hit above. | 1767 // grabbed and no early return paths were otherwise hit above. |
| 1765 first_run::CreateSentinelIfNeeded(); | 1768 first_run::CreateSentinelIfNeeded(); |
| 1766 #endif // !defined(OS_ANDROID) | 1769 #endif // !defined(OS_ANDROID) |
| 1767 | 1770 |
| 1768 #if BUILDFLAG(ENABLE_BACKGROUND) | 1771 #if BUILDFLAG(ENABLE_BACKGROUND) |
| 1769 // Autoload any profiles which are running background apps. | 1772 // Autoload any profiles which are running background apps. |
| 1770 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. | 1773 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. |
| 1771 browser_process_->profile_manager()->AutoloadProfiles(); | 1774 browser_process_->profile_manager()->AutoloadProfiles(); |
| 1772 #endif // BUILDFLAG(ENABLE_BACKGROUND) | 1775 #endif // BUILDFLAG(ENABLE_BACKGROUND) |
| 1773 // Post-profile init --------------------------------------------------------- | 1776 // Post-profile init --------------------------------------------------------- |
| 1774 | 1777 |
| 1775 TranslateService::Initialize(); | 1778 TranslateService::Initialize(); |
| 1776 | 1779 |
| 1777 // Needs to be done before PostProfileInit, since login manager on CrOS is | 1780 // Needs to be done before PostProfileInit, since login manager on CrOS is |
| 1778 // called inside PostProfileInit. | 1781 // called inside PostProfileInit. |
| 1779 content::WebUIControllerFactory::RegisterFactory( | 1782 content::WebUIControllerFactory::RegisterFactory( |
| 1780 ChromeWebUIControllerFactory::GetInstance()); | 1783 ChromeWebUIControllerFactory::GetInstance()); |
| 1781 | 1784 |
| 1782 // NaClBrowserDelegateImpl is accessed inside PostProfileInit(). | 1785 // NaClBrowserDelegateImpl is accessed inside PostProfileInit(). |
| 1783 // So make sure to create it before that. | 1786 // So make sure to create it before that. |
| 1784 #if !defined(DISABLE_NACL) | 1787 #if !defined(DISABLE_NACL) |
| 1785 NaClBrowserDelegateImpl* delegate = | 1788 NaClBrowserDelegateImpl* delegate = |
| 1786 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); | 1789 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); |
| 1787 nacl::NaClBrowser::SetDelegate(delegate); | 1790 nacl::NaClBrowser::SetDelegate(delegate); |
| 1788 #endif // !defined(DISABLE_NACL) | 1791 #endif // !defined(DISABLE_NACL) |
| 1789 | 1792 |
| 1790 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. | 1793 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. |
| 1791 // (requires supporting early exit). | 1794 // (requires supporting early exit). |
| 1792 PostProfileInit(); | 1795 PostProfileInit(); |
| 1793 | 1796 |
| 1794 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 1797 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| 1795 // Show the First Run UI if this is the first time Chrome has been run on | 1798 // Show the First Run UI if this is the first time Chrome has been run on |
| 1796 // this computer, or we're being compelled to do so by a command line flag. | 1799 // this computer, or we're being compelled to do so by a command line flag. |
| 1797 // Note that this be done _after_ the PrefService is initialized and all | 1800 // Note that this be done _after_ the PrefService is initialized and all |
| 1798 // preferences are registered, since some of the code that the importer | 1801 // preferences are registered, since some of the code that the importer |
| 1799 // touches reads preferences. | 1802 // touches reads preferences. |
| 1800 if (first_run::IsChromeFirstRun()) { | 1803 if (first_run::IsChromeFirstRun()) { |
| 1801 first_run::AutoImport(profile_, | 1804 // By default, autoImport is performed on first run. |
| 1802 master_prefs_->homepage_defined, | 1805 bool perform_autoImport_on_first_run = true; |
| 1803 master_prefs_->do_import_items, | 1806 // A field trial that is designed to turn off the AutoImport feature |
| 1804 master_prefs_->dont_import_items, | 1807 // for Windows users (on first run). |
| 1805 master_prefs_->import_bookmarks_path); | 1808 // The feature keeps running for enterprise. |
| 1809 #if defined(OS_WIN) | |
| 1810 base::FieldTrial* trial = base::FieldTrialList::Find("FirstRunAutoImport"); | |
| 1811 perform_autoImport_on_first_run = | |
| 1812 !trial || !base::FeatureList::IsEnabled(kFirstRunAutoImport) || | |
| 1813 base::win::IsEnrolledToDomain(); | |
| 1814 #endif | |
| 1815 if (perform_autoImport_on_first_run) { | |
| 1816 first_run::AutoImport(profile_, master_prefs_->homepage_defined, | |
| 1817 master_prefs_->do_import_items, | |
| 1818 master_prefs_->dont_import_items, | |
| 1819 master_prefs_->import_bookmarks_path); | |
| 1820 } | |
| 1806 | 1821 |
| 1807 // Note: this can pop the first run consent dialog on linux. | 1822 // Note: this can pop the first run consent dialog on linux. |
| 1808 first_run::DoPostImportTasks(profile_, | 1823 first_run::DoPostImportTasks(profile_, |
| 1809 master_prefs_->make_chrome_default_for_user); | 1824 master_prefs_->make_chrome_default_for_user); |
| 1810 | 1825 |
| 1811 if (!master_prefs_->suppress_first_run_default_browser_prompt) { | 1826 if (!master_prefs_->suppress_first_run_default_browser_prompt) { |
| 1812 browser_creator_->set_show_main_browser_window( | 1827 browser_creator_->set_show_main_browser_window( |
| 1813 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); | 1828 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); |
| 1814 } else { | 1829 } else { |
| 1815 browser_creator_->set_is_default_browser_dialog_suppressed(true); | 1830 browser_creator_->set_is_default_browser_dialog_suppressed(true); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1830 // but should run on startup if extended to handle crashes/hangs/patches. | 1845 // but should run on startup if extended to handle crashes/hangs/patches. |
| 1831 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. | 1846 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. |
| 1832 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 1847 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 1833 ChromeBrowserMainPartsWin::RegisterApplicationRestart( | 1848 ChromeBrowserMainPartsWin::RegisterApplicationRestart( |
| 1834 parsed_command_line()); | 1849 parsed_command_line()); |
| 1835 } | 1850 } |
| 1836 | 1851 |
| 1837 // Verify that the profile is not on a network share and if so prepare to show | 1852 // Verify that the profile is not on a network share and if so prepare to show |
| 1838 // notification to the user. | 1853 // notification to the user. |
| 1839 if (NetworkProfileBubble::ShouldCheckNetworkProfile(profile_)) { | 1854 if (NetworkProfileBubble::ShouldCheckNetworkProfile(profile_)) { |
| 1840 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 1855 BrowserThread::PostTask( |
| 1856 BrowserThread::FILE, FROM_HERE, | |
| 1841 base::Bind(&NetworkProfileBubble::CheckNetworkProfile, | 1857 base::Bind(&NetworkProfileBubble::CheckNetworkProfile, |
| 1842 profile_->GetPath())); | 1858 profile_->GetPath())); |
| 1843 } | 1859 } |
| 1844 #endif // defined(OS_WIN) | 1860 #endif // defined(OS_WIN) |
| 1845 | 1861 |
| 1846 #if defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) | 1862 #if defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) |
| 1847 // Init the RLZ library. This just binds the dll and schedules a task on the | 1863 // Init the RLZ library. This just binds the dll and schedules a task on the |
| 1848 // file thread to be run sometime later. If this is the first run we record | 1864 // file thread to be run sometime later. If this is the first run we record |
| 1849 // the installation event. | 1865 // the installation event. |
| 1850 PrefService* pref_service = profile_->GetPrefs(); | 1866 PrefService* pref_service = profile_->GetPrefs(); |
| 1851 int ping_delay = first_run::IsChromeFirstRun() ? master_prefs_->ping_delay : | 1867 int ping_delay = |
| 1852 pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); | 1868 first_run::IsChromeFirstRun() |
| 1869 ? master_prefs_->ping_delay | |
| 1870 : pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); | |
| 1853 // Negative ping delay means to send ping immediately after a first search is | 1871 // Negative ping delay means to send ping immediately after a first search is |
| 1854 // recorded. | 1872 // recorded. |
| 1855 rlz::RLZTracker::SetRlzDelegate( | 1873 rlz::RLZTracker::SetRlzDelegate( |
| 1856 base::WrapUnique(new ChromeRLZTrackerDelegate)); | 1874 base::WrapUnique(new ChromeRLZTrackerDelegate)); |
| 1857 rlz::RLZTracker::InitRlzDelayed( | 1875 rlz::RLZTracker::InitRlzDelayed( |
| 1858 first_run::IsChromeFirstRun(), ping_delay < 0, | 1876 first_run::IsChromeFirstRun(), ping_delay < 0, |
| 1859 base::TimeDelta::FromMilliseconds(abs(ping_delay)), | 1877 base::TimeDelta::FromMilliseconds(abs(ping_delay)), |
| 1860 ChromeRLZTrackerDelegate::IsGoogleDefaultSearch(profile_), | 1878 ChromeRLZTrackerDelegate::IsGoogleDefaultSearch(profile_), |
| 1861 ChromeRLZTrackerDelegate::IsGoogleHomepage(profile_), | 1879 ChromeRLZTrackerDelegate::IsGoogleHomepage(profile_), |
| 1862 ChromeRLZTrackerDelegate::IsGoogleInStartpages(profile_)); | 1880 ChromeRLZTrackerDelegate::IsGoogleInStartpages(profile_)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1898 browser_process_->GetApplicationLocale()); | 1916 browser_process_->GetApplicationLocale()); |
| 1899 | 1917 |
| 1900 // Start watching for hangs during startup. We disarm this hang detector when | 1918 // Start watching for hangs during startup. We disarm this hang detector when |
| 1901 // ThreadWatcher takes over or when browser is shutdown or when | 1919 // ThreadWatcher takes over or when browser is shutdown or when |
| 1902 // startup_watcher_ is deleted. | 1920 // startup_watcher_ is deleted. |
| 1903 metrics::MetricsService::SetExecutionPhase( | 1921 metrics::MetricsService::SetExecutionPhase( |
| 1904 metrics::MetricsService::STARTUP_TIMEBOMB_ARM, | 1922 metrics::MetricsService::STARTUP_TIMEBOMB_ARM, |
| 1905 g_browser_process->local_state()); | 1923 g_browser_process->local_state()); |
| 1906 startup_watcher_->Arm(base::TimeDelta::FromSeconds(600)); | 1924 startup_watcher_->Arm(base::TimeDelta::FromSeconds(600)); |
| 1907 | 1925 |
| 1908 // On mobile, need for clean shutdown arises only when the application comes | 1926 // On mobile, need for clean shutdown arises only when the application comes |
| 1909 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). | 1927 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). |
| 1910 // http://crbug.com/179143 | 1928 // http://crbug.com/179143 |
| 1911 #if !defined(OS_ANDROID) | 1929 #if !defined(OS_ANDROID) |
| 1912 // Start watching for a hang. | 1930 // Start watching for a hang. |
| 1913 browser_process_->metrics_service()->LogNeedForCleanShutdown(); | 1931 browser_process_->metrics_service()->LogNeedForCleanShutdown(); |
| 1914 #endif // !defined(OS_ANDROID) | 1932 #endif // !defined(OS_ANDROID) |
| 1915 | 1933 |
| 1916 #if defined(ENABLE_PRINT_PREVIEW) | 1934 #if defined(ENABLE_PRINT_PREVIEW) |
| 1917 // Create the instance of the cloud print proxy service so that it can launch | 1935 // Create the instance of the cloud print proxy service so that it can launch |
| 1918 // the service process if needed. This is needed because the service process | 1936 // the service process if needed. This is needed because the service process |
| 1919 // might have shutdown because an update was available. | 1937 // might have shutdown because an update was available. |
| 1920 // TODO(torne): this should maybe be done with | 1938 // TODO(torne): this should maybe be done with |
| 1921 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() | 1939 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() |
| 1922 // instead? | 1940 // instead? |
| 1923 CloudPrintProxyServiceFactory::GetForProfile(profile_); | 1941 CloudPrintProxyServiceFactory::GetForProfile(profile_); |
| 1924 #endif // defined(ENABLE_PRINT_PREVIEW) | 1942 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 1925 | 1943 |
| 1926 // Start watching all browser threads for responsiveness. | 1944 // Start watching all browser threads for responsiveness. |
| 1927 metrics::MetricsService::SetExecutionPhase( | 1945 metrics::MetricsService::SetExecutionPhase( |
| 1928 metrics::MetricsService::THREAD_WATCHER_START, | 1946 metrics::MetricsService::THREAD_WATCHER_START, |
| 1929 g_browser_process->local_state()); | 1947 g_browser_process->local_state()); |
| 1930 ThreadWatcherList::StartWatchingAll(parsed_command_line()); | 1948 ThreadWatcherList::StartWatchingAll(parsed_command_line()); |
| 1931 | 1949 |
| 1932 #if defined(OS_ANDROID) | 1950 #if defined(OS_ANDROID) |
| 1933 ThreadWatcherAndroid::RegisterApplicationStatusListener(); | 1951 ThreadWatcherAndroid::RegisterApplicationStatusListener(); |
| 1934 #endif // defined(OS_ANDROID) | 1952 #endif // defined(OS_ANDROID) |
| 1935 | 1953 |
| 1936 #if !defined(DISABLE_NACL) | 1954 #if !defined(DISABLE_NACL) |
| 1937 BrowserThread::PostTask( | 1955 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 1938 BrowserThread::IO, | 1956 base::Bind(nacl::NaClProcessHost::EarlyStartup)); |
|
manzagop (departed)
2016/08/18 15:59:56
Yes, this is too big a diff. I really think git cl
gcomanici
2016/08/19 16:04:31
Done.
| |
| 1939 FROM_HERE, | |
| 1940 base::Bind(nacl::NaClProcessHost::EarlyStartup)); | |
| 1941 #endif // !defined(DISABLE_NACL) | 1957 #endif // !defined(DISABLE_NACL) |
| 1942 | 1958 |
| 1943 // Make sure initial prefs are recorded | 1959 // Make sure initial prefs are recorded |
| 1944 PrefMetricsService::Factory::GetForProfile(profile_); | 1960 PrefMetricsService::Factory::GetForProfile(profile_); |
| 1945 | 1961 |
| 1946 PreBrowserStart(); | 1962 PreBrowserStart(); |
| 1947 | 1963 |
| 1948 // Instantiate the notification UI manager, as this triggers a perf timer | 1964 // Instantiate the notification UI manager, as this triggers a perf timer |
| 1949 // used to measure startup time. TODO(stevenjb): Figure out what is actually | 1965 // used to measure startup time. TODO(stevenjb): Figure out what is actually |
| 1950 // triggering the timer and call that explicitly in the approprate place. | 1966 // triggering the timer and call that explicitly in the approprate place. |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2209 chromeos::CrosSettings::Shutdown(); | 2225 chromeos::CrosSettings::Shutdown(); |
| 2210 #endif // defined(OS_CHROMEOS) | 2226 #endif // defined(OS_CHROMEOS) |
| 2211 #endif // defined(OS_ANDROID) | 2227 #endif // defined(OS_ANDROID) |
| 2212 } | 2228 } |
| 2213 | 2229 |
| 2214 // Public members: | 2230 // Public members: |
| 2215 | 2231 |
| 2216 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2232 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 2217 chrome_extra_parts_.push_back(parts); | 2233 chrome_extra_parts_.push_back(parts); |
| 2218 } | 2234 } |
| OLD | NEW |