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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 #include "chrome/browser/profiles/profile_attributes_storage.h" | 81 #include "chrome/browser/profiles/profile_attributes_storage.h" |
82 #include "chrome/browser/profiles/profile_manager.h" | 82 #include "chrome/browser/profiles/profile_manager.h" |
83 #include "chrome/browser/profiles/profiles_state.h" | 83 #include "chrome/browser/profiles/profiles_state.h" |
84 #include "chrome/browser/shell_integration.h" | 84 #include "chrome/browser/shell_integration.h" |
85 #include "chrome/browser/tracing/navigation_tracing.h" | 85 #include "chrome/browser/tracing/navigation_tracing.h" |
86 #include "chrome/browser/translate/translate_service.h" | 86 #include "chrome/browser/translate/translate_service.h" |
87 #include "chrome/browser/ui/app_list/app_list_service.h" | 87 #include "chrome/browser/ui/app_list/app_list_service.h" |
88 #include "chrome/browser/ui/app_modal/chrome_javascript_native_dialog_factory.h" | 88 #include "chrome/browser/ui/app_modal/chrome_javascript_native_dialog_factory.h" |
89 #include "chrome/browser/ui/browser.h" | 89 #include "chrome/browser/ui/browser.h" |
90 #include "chrome/browser/ui/browser_finder.h" | 90 #include "chrome/browser/ui/browser_finder.h" |
91 #include "chrome/browser/ui/profile_error_dialog.h" | |
92 #include "chrome/browser/ui/simple_message_box.h" | |
91 #include "chrome/browser/ui/startup/bad_flags_prompt.h" | 93 #include "chrome/browser/ui/startup/bad_flags_prompt.h" |
92 #include "chrome/browser/ui/startup/default_browser_prompt.h" | 94 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
93 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 95 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
94 #include "chrome/browser/ui/uma_browsing_activity_observer.h" | 96 #include "chrome/browser/ui/uma_browsing_activity_observer.h" |
95 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 97 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
96 #include "chrome/common/channel_info.h" | 98 #include "chrome/common/channel_info.h" |
97 #include "chrome/common/chrome_constants.h" | 99 #include "chrome/common/chrome_constants.h" |
98 #include "chrome/common/chrome_features.h" | 100 #include "chrome/common/chrome_features.h" |
99 #include "chrome/common/chrome_paths.h" | 101 #include "chrome/common/chrome_paths.h" |
100 #include "chrome/common/chrome_result_codes.h" | 102 #include "chrome/common/chrome_result_codes.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 profiles::SetLastUsedProfile( | 386 profiles::SetLastUsedProfile( |
385 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); | 387 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); |
386 // Clear kProfilesLastActive since the user only wants to launch a specific | 388 // Clear kProfilesLastActive since the user only wants to launch a specific |
387 // profile. | 389 // profile. |
388 ListPrefUpdate update(g_browser_process->local_state(), | 390 ListPrefUpdate update(g_browser_process->local_state(), |
389 prefs::kProfilesLastActive); | 391 prefs::kProfilesLastActive); |
390 base::ListValue* profile_list = update.Get(); | 392 base::ListValue* profile_list = update.Get(); |
391 profile_list->Clear(); | 393 profile_list->Clear(); |
392 } | 394 } |
393 | 395 |
394 Profile* profile = NULL; | 396 Profile* profile = nullptr; |
395 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 397 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
396 // On ChromeOS and Android the ProfileManager will use the same path as the | 398 // 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 | 399 // one we got passed. GetActiveUserProfile will therefore use the correct path |
398 // automatically. | 400 // automatically. |
399 DCHECK_EQ(user_data_dir.value(), | 401 DCHECK_EQ(user_data_dir.value(), |
400 g_browser_process->profile_manager()->user_data_dir().value()); | 402 g_browser_process->profile_manager()->user_data_dir().value()); |
401 profile = ProfileManager::GetActiveUserProfile(); | 403 profile = ProfileManager::GetActiveUserProfile(); |
404 | |
405 // TODO(port): fix this. See comments near the definition of |user_data_dir|. | |
406 // It is better to CHECK-fail here than it is to silently exit because of | |
407 // missing code in the above test. | |
408 CHECK(profile) << "Cannot get default profile."; | |
409 | |
402 #else | 410 #else |
403 base::FilePath profile_path = | 411 profile = GetStartupProfile(user_data_dir, parsed_command_line); |
404 GetStartupProfilePath(user_data_dir, parsed_command_line); | |
405 | 412 |
406 profile = g_browser_process->profile_manager()->GetProfile( | 413 bool profile_dir_specified = |
407 profile_path); | 414 profiles::IsMultipleProfilesEnabled() && |
brettw
2016/07/01 23:13:22
This same condition is used near the top of this f
WC Leung
2016/07/07 17:01:53
Done.
| |
415 parsed_command_line.HasSwitch(switches::kProfileDirectory); | |
408 | 416 |
409 // If we're using the --new-profile-management flag and this profile is | 417 if (!profile && !profile_dir_specified) |
410 // signed out, then we should show the user manager instead. By switching | 418 profile = GetFallbackStartupProfile(); |
411 // the active profile to the guest profile we ensure that no | 419 |
412 // browser windows will be opened for the guest profile. | 420 if (!profile) { |
413 if (switches::IsNewProfileManagement() && | 421 ProfileErrorType error_type = profile_dir_specified ? |
414 profile && | 422 PROFILE_ERROR_CREATE_FAILURE_SPECIFIED : |
415 !profile->IsGuestSession()) { | 423 PROFILE_ERROR_CREATE_FAILURE_ALL; |
416 ProfileAttributesEntry* entry; | 424 |
417 bool has_entry = g_browser_process->profile_manager()-> | 425 ShowProfileErrorDialog(error_type, IDS_COULDNT_STARTUP_PROFILE_ERROR); |
418 GetProfileAttributesStorage(). | 426 return nullptr; |
419 GetProfileAttributesWithPath(profile_path, &entry); | |
420 if (has_entry && entry->IsSigninRequired()) { | |
421 profile = g_browser_process->profile_manager()->GetProfile( | |
422 ProfileManager::GetGuestProfilePath()); | |
423 } | |
424 } | 427 } |
425 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) | 428 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) |
426 if (profile) { | |
427 UMA_HISTOGRAM_LONG_TIMES( | |
428 "Startup.CreateFirstProfile", base::Time::Now() - start); | |
429 return profile; | |
430 } | |
431 | 429 |
432 #if !defined(OS_WIN) | 430 UMA_HISTOGRAM_LONG_TIMES( |
433 // TODO(port): fix this. See comments near the definition of | 431 "Startup.CreateFirstProfile", base::Time::Now() - start); |
434 // user_data_dir. It is better to CHECK-fail here than it is to | 432 return profile; |
435 // silently exit because of missing code in the above test. | |
436 CHECK(profile) << "Cannot get default profile."; | |
437 #endif // !defined(OS_WIN) | |
438 | |
439 return NULL; | |
440 } | 433 } |
441 | 434 |
442 #if defined(OS_MACOSX) | 435 #if defined(OS_MACOSX) |
443 OSStatus KeychainCallback(SecKeychainEvent keychain_event, | 436 OSStatus KeychainCallback(SecKeychainEvent keychain_event, |
444 SecKeychainCallbackInfo* info, void* context) { | 437 SecKeychainCallbackInfo* info, void* context) { |
445 return noErr; | 438 return noErr; |
446 } | 439 } |
447 #endif // defined(OS_MACOSX) | 440 #endif // defined(OS_MACOSX) |
448 | 441 |
449 void RegisterComponentsForUpdate() { | 442 void RegisterComponentsForUpdate() { |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1983 chromeos::CrosSettings::Shutdown(); | 1976 chromeos::CrosSettings::Shutdown(); |
1984 #endif // defined(OS_CHROMEOS) | 1977 #endif // defined(OS_CHROMEOS) |
1985 #endif // defined(OS_ANDROID) | 1978 #endif // defined(OS_ANDROID) |
1986 } | 1979 } |
1987 | 1980 |
1988 // Public members: | 1981 // Public members: |
1989 | 1982 |
1990 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1983 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1991 chrome_extra_parts_.push_back(parts); | 1984 chrome_extra_parts_.push_back(parts); |
1992 } | 1985 } |
OLD | NEW |