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 29 matching lines...) Expand all Loading... | |
40 #include "base/values.h" | 40 #include "base/values.h" |
41 #include "build/build_config.h" | 41 #include "build/build_config.h" |
42 #include "cc/base/switches.h" | 42 #include "cc/base/switches.h" |
43 #include "chrome/browser/about_flags.h" | 43 #include "chrome/browser/about_flags.h" |
44 #include "chrome/browser/after_startup_task_utils.h" | 44 #include "chrome/browser/after_startup_task_utils.h" |
45 #include "chrome/browser/browser_process.h" | 45 #include "chrome/browser/browser_process.h" |
46 #include "chrome/browser/browser_process_impl.h" | 46 #include "chrome/browser/browser_process_impl.h" |
47 #include "chrome/browser/browser_process_platform_part.h" | 47 #include "chrome/browser/browser_process_platform_part.h" |
48 #include "chrome/browser/browser_shutdown.h" | 48 #include "chrome/browser/browser_shutdown.h" |
49 #include "chrome/browser/chrome_browser_main_extra_parts.h" | 49 #include "chrome/browser/chrome_browser_main_extra_parts.h" |
50 #include "chrome/browser/component_updater/cld_component_installer.h" | |
WC Leung
2016/06/15 17:44:09
Didn't know why this line didn't go away in my reb
| |
50 #include "chrome/browser/component_updater/ev_whitelist_component_installer.h" | 51 #include "chrome/browser/component_updater/ev_whitelist_component_installer.h" |
51 #include "chrome/browser/component_updater/file_type_policies_component_installe r.h" | 52 #include "chrome/browser/component_updater/file_type_policies_component_installe r.h" |
52 #include "chrome/browser/component_updater/origin_trials_component_installer.h" | 53 #include "chrome/browser/component_updater/origin_trials_component_installer.h" |
53 #include "chrome/browser/component_updater/pepper_flash_component_installer.h" | 54 #include "chrome/browser/component_updater/pepper_flash_component_installer.h" |
54 #include "chrome/browser/component_updater/recovery_component_installer.h" | 55 #include "chrome/browser/component_updater/recovery_component_installer.h" |
55 #include "chrome/browser/component_updater/sth_set_component_installer.h" | 56 #include "chrome/browser/component_updater/sth_set_component_installer.h" |
56 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h " | 57 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h " |
57 #include "chrome/browser/component_updater/swiftshader_component_installer.h" | 58 #include "chrome/browser/component_updater/swiftshader_component_installer.h" |
58 #include "chrome/browser/component_updater/widevine_cdm_component_installer.h" | 59 #include "chrome/browser/component_updater/widevine_cdm_component_installer.h" |
59 #include "chrome/browser/defaults.h" | 60 #include "chrome/browser/defaults.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
81 #include "chrome/browser/profiles/profile_attributes_storage.h" | 82 #include "chrome/browser/profiles/profile_attributes_storage.h" |
82 #include "chrome/browser/profiles/profile_manager.h" | 83 #include "chrome/browser/profiles/profile_manager.h" |
83 #include "chrome/browser/profiles/profiles_state.h" | 84 #include "chrome/browser/profiles/profiles_state.h" |
84 #include "chrome/browser/shell_integration.h" | 85 #include "chrome/browser/shell_integration.h" |
85 #include "chrome/browser/tracing/navigation_tracing.h" | 86 #include "chrome/browser/tracing/navigation_tracing.h" |
86 #include "chrome/browser/translate/translate_service.h" | 87 #include "chrome/browser/translate/translate_service.h" |
87 #include "chrome/browser/ui/app_list/app_list_service.h" | 88 #include "chrome/browser/ui/app_list/app_list_service.h" |
88 #include "chrome/browser/ui/app_modal/chrome_javascript_native_dialog_factory.h" | 89 #include "chrome/browser/ui/app_modal/chrome_javascript_native_dialog_factory.h" |
89 #include "chrome/browser/ui/browser.h" | 90 #include "chrome/browser/ui/browser.h" |
90 #include "chrome/browser/ui/browser_finder.h" | 91 #include "chrome/browser/ui/browser_finder.h" |
92 #include "chrome/browser/ui/profile_error_dialog.h" | |
93 #include "chrome/browser/ui/simple_message_box.h" | |
91 #include "chrome/browser/ui/startup/bad_flags_prompt.h" | 94 #include "chrome/browser/ui/startup/bad_flags_prompt.h" |
92 #include "chrome/browser/ui/startup/default_browser_prompt.h" | 95 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
93 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 96 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
94 #include "chrome/browser/ui/uma_browsing_activity_observer.h" | 97 #include "chrome/browser/ui/uma_browsing_activity_observer.h" |
95 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 98 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
96 #include "chrome/common/channel_info.h" | 99 #include "chrome/common/channel_info.h" |
97 #include "chrome/common/chrome_constants.h" | 100 #include "chrome/common/chrome_constants.h" |
98 #include "chrome/common/chrome_features.h" | 101 #include "chrome/common/chrome_features.h" |
99 #include "chrome/common/chrome_paths.h" | 102 #include "chrome/common/chrome_paths.h" |
100 #include "chrome/common/chrome_result_codes.h" | 103 #include "chrome/common/chrome_result_codes.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 profiles::SetLastUsedProfile( | 387 profiles::SetLastUsedProfile( |
385 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); | 388 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); |
386 // Clear kProfilesLastActive since the user only wants to launch a specific | 389 // Clear kProfilesLastActive since the user only wants to launch a specific |
387 // profile. | 390 // profile. |
388 ListPrefUpdate update(g_browser_process->local_state(), | 391 ListPrefUpdate update(g_browser_process->local_state(), |
389 prefs::kProfilesLastActive); | 392 prefs::kProfilesLastActive); |
390 base::ListValue* profile_list = update.Get(); | 393 base::ListValue* profile_list = update.Get(); |
391 profile_list->Clear(); | 394 profile_list->Clear(); |
392 } | 395 } |
393 | 396 |
394 Profile* profile = NULL; | 397 Profile* profile = nullptr; |
395 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 398 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
396 // On ChromeOS and Android the ProfileManager will use the same path as the | 399 // On ChromeOS and Android the ProfileManager will use the same path as the |
397 // one we got passed. GetActiveUserProfile will therefore use the correct path | 400 // one we got passed. GetActiveUserProfile will therefore use the correct path |
398 // automatically. | 401 // automatically. |
399 DCHECK_EQ(user_data_dir.value(), | 402 DCHECK_EQ(user_data_dir.value(), |
400 g_browser_process->profile_manager()->user_data_dir().value()); | 403 g_browser_process->profile_manager()->user_data_dir().value()); |
401 profile = ProfileManager::GetActiveUserProfile(); | 404 profile = ProfileManager::GetActiveUserProfile(); |
402 #else | 405 #else |
403 base::FilePath profile_path = | 406 base::FilePath profile_path = |
404 GetStartupProfilePath(user_data_dir, parsed_command_line); | 407 GetStartupProfilePath(user_data_dir, parsed_command_line); |
405 | 408 |
406 profile = g_browser_process->profile_manager()->GetProfile( | 409 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
407 profile_path); | 410 profile = profile_manager->GetProfile(profile_path); |
408 | 411 |
409 // If we're using the --new-profile-management flag and this profile is | 412 // If we're using the --new-profile-management flag and this profile is signed |
410 // signed out, then we should show the user manager instead. By switching | 413 // out, then we should show the user manager instead. By switching the active |
411 // the active profile to the guest profile we ensure that no | 414 // profile to the guest profile we ensure that no browser windows will be |
412 // browser windows will be opened for the guest profile. | 415 // opened for the guest profile. The initialization of guest profile is |
416 // possible to fail. | |
413 if (switches::IsNewProfileManagement() && | 417 if (switches::IsNewProfileManagement() && |
414 profile && | 418 profile && |
415 !profile->IsGuestSession()) { | 419 !profile->IsGuestSession()) { |
416 ProfileAttributesEntry* entry; | 420 ProfileAttributesEntry* entry; |
417 bool has_entry = g_browser_process->profile_manager()-> | 421 bool has_entry = g_browser_process->profile_manager() |
418 GetProfileAttributesStorage(). | 422 ->GetProfileAttributesStorage() |
419 GetProfileAttributesWithPath(profile_path, &entry); | 423 .GetProfileAttributesWithPath(profile_path, &entry); |
420 if (has_entry && entry->IsSigninRequired()) { | 424 if (has_entry && entry->IsSigninRequired()) { |
421 profile = g_browser_process->profile_manager()->GetProfile( | 425 profile = profile_manager->GetProfile( |
422 ProfileManager::GetGuestProfilePath()); | 426 ProfileManager::GetGuestProfilePath()); |
423 } | 427 } |
424 } | 428 } |
429 | |
430 // If the user specified a profile and it fails to initialize, do not start | |
431 // chromium. | |
432 if (profiles::IsMultipleProfilesEnabled() && | |
433 parsed_command_line.HasSwitch(switches::kProfileDirectory) && | |
434 !profile) { | |
435 ShowProfileErrorDialog(PROFILE_ERROR_CREATE_FAILURE_SPECIFIED, | |
436 IDS_COULDNT_OPEN_SPECIFIED_PROFILE_ERROR); | |
437 return nullptr; | |
438 } | |
439 | |
440 // If the last used profile is unable to initialize, see if any of other last | |
441 // opened profiles can initialize successfully. At this stage we assume | |
442 // creation of all new profile (including guest profile) to fail. | |
443 if (!profile) { | |
444 std::vector<Profile*> last_opened_profiles = | |
445 ProfileManager::GetLastOpenedProfiles(); | |
446 // Get the first profile that is not signed out.. | |
447 if (last_opened_profiles.size()) { | |
448 for (Profile* last_opened_profile : last_opened_profiles) { | |
449 ProfileAttributesEntry* entry; | |
450 bool has_entry = | |
451 g_browser_process->profile_manager() | |
452 ->GetProfileAttributesStorage() | |
453 .GetProfileAttributesWithPath(profile->GetPath(), | |
454 &entry); | |
455 if (!has_entry || !entry->IsSigninRequired()) { | |
456 profile = last_opened_profile; | |
457 break; | |
458 } | |
459 } | |
460 } | |
461 } | |
462 | |
463 // If it still fails, try to create a guest profile. Show the user manager | |
464 // if this is successful. | |
465 if (!profile) { | |
466 profile = profile_manager->GetProfile( | |
467 ProfileManager::GetGuestProfilePath()); | |
468 } | |
469 | |
470 // If still fails, try to open any non-signin profile. | |
471 if (!profile) { | |
472 std::vector<ProfileAttributesEntry*> entries = | |
473 profile_manager->GetProfileAttributesStorage() | |
474 .GetAllProfilesAttributes(); | |
475 for (ProfileAttributesEntry* entry : entries) { | |
476 if (!entry->IsSigninRequired()) { | |
477 profile = profile_manager->GetProfile(entry->GetPath()); | |
478 if (profile) | |
479 break; | |
480 } | |
481 } | |
482 } | |
483 | |
484 // If it continues to fail, we have to show an error message and give up. | |
485 if (!profile) { | |
486 ShowProfileErrorDialog(PROFILE_ERROR_CREATE_FAILURE_ALL, | |
487 IDS_COULDNT_OPEN_ANY_PROFILE_ERROR); | |
488 return nullptr; | |
489 } | |
425 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) | 490 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) |
426 if (profile) { | 491 if (profile) { |
427 UMA_HISTOGRAM_LONG_TIMES( | 492 UMA_HISTOGRAM_LONG_TIMES( |
428 "Startup.CreateFirstProfile", base::Time::Now() - start); | 493 "Startup.CreateFirstProfile", base::Time::Now() - start); |
429 return profile; | 494 return profile; |
430 } | 495 } |
431 | 496 |
432 #if !defined(OS_WIN) | |
433 // TODO(port): fix this. See comments near the definition of | 497 // TODO(port): fix this. See comments near the definition of |
434 // user_data_dir. It is better to CHECK-fail here than it is to | 498 // user_data_dir. It is better to CHECK-fail here than it is to |
435 // silently exit because of missing code in the above test. | 499 // silently exit because of missing code in the above test. |
436 CHECK(profile) << "Cannot get default profile."; | 500 CHECK(profile) << "Cannot get default profile."; |
437 #endif // !defined(OS_WIN) | |
438 | 501 |
439 return NULL; | 502 return nullptr; |
440 } | 503 } |
441 | 504 |
442 #if defined(OS_MACOSX) | 505 #if defined(OS_MACOSX) |
443 OSStatus KeychainCallback(SecKeychainEvent keychain_event, | 506 OSStatus KeychainCallback(SecKeychainEvent keychain_event, |
444 SecKeychainCallbackInfo* info, void* context) { | 507 SecKeychainCallbackInfo* info, void* context) { |
445 return noErr; | 508 return noErr; |
446 } | 509 } |
447 #endif // defined(OS_MACOSX) | 510 #endif // defined(OS_MACOSX) |
448 | 511 |
449 void RegisterComponentsForUpdate() { | 512 void RegisterComponentsForUpdate() { |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1983 chromeos::CrosSettings::Shutdown(); | 2046 chromeos::CrosSettings::Shutdown(); |
1984 #endif // defined(OS_CHROMEOS) | 2047 #endif // defined(OS_CHROMEOS) |
1985 #endif // defined(OS_ANDROID) | 2048 #endif // defined(OS_ANDROID) |
1986 } | 2049 } |
1987 | 2050 |
1988 // Public members: | 2051 // Public members: |
1989 | 2052 |
1990 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2053 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1991 chrome_extra_parts_.push_back(parts); | 2054 chrome_extra_parts_.push_back(parts); |
1992 } | 2055 } |
OLD | NEW |