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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 374 |
373 // Initializes the primary profile, possibly doing some user prompting to pick | 375 // Initializes the primary profile, possibly doing some user prompting to pick |
374 // a fallback profile. Returns the newly created profile, or NULL if startup | 376 // a fallback profile. Returns the newly created profile, or NULL if startup |
375 // should not continue. | 377 // should not continue. |
376 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, | 378 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, |
377 const base::FilePath& user_data_dir, | 379 const base::FilePath& user_data_dir, |
378 const base::CommandLine& parsed_command_line) { | 380 const base::CommandLine& parsed_command_line) { |
379 TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile") | 381 TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile") |
380 | 382 |
381 base::Time start = base::Time::Now(); | 383 base::Time start = base::Time::Now(); |
382 if (profiles::IsMultipleProfilesEnabled() && | 384 bool profile_dir_specified = |
383 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { | 385 profiles::IsMultipleProfilesEnabled() && |
| 386 parsed_command_line.HasSwitch(switches::kProfileDirectory); |
| 387 if (profile_dir_specified) { |
384 profiles::SetLastUsedProfile( | 388 profiles::SetLastUsedProfile( |
385 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); | 389 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); |
386 // Clear kProfilesLastActive since the user only wants to launch a specific | 390 // Clear kProfilesLastActive since the user only wants to launch a specific |
387 // profile. | 391 // profile. |
388 ListPrefUpdate update(g_browser_process->local_state(), | 392 ListPrefUpdate update(g_browser_process->local_state(), |
389 prefs::kProfilesLastActive); | 393 prefs::kProfilesLastActive); |
390 base::ListValue* profile_list = update.Get(); | 394 base::ListValue* profile_list = update.Get(); |
391 profile_list->Clear(); | 395 profile_list->Clear(); |
392 } | 396 } |
393 | 397 |
394 Profile* profile = NULL; | 398 Profile* profile = nullptr; |
395 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 399 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
396 // On ChromeOS and Android the ProfileManager will use the same path as the | 400 // 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 | 401 // one we got passed. GetActiveUserProfile will therefore use the correct path |
398 // automatically. | 402 // automatically. |
399 DCHECK_EQ(user_data_dir.value(), | 403 DCHECK_EQ(user_data_dir.value(), |
400 g_browser_process->profile_manager()->user_data_dir().value()); | 404 g_browser_process->profile_manager()->user_data_dir().value()); |
401 profile = ProfileManager::GetActiveUserProfile(); | 405 profile = ProfileManager::GetActiveUserProfile(); |
| 406 |
| 407 // TODO(port): fix this. See comments near the definition of |user_data_dir|. |
| 408 // It is better to CHECK-fail here than it is to silently exit because of |
| 409 // missing code in the above test. |
| 410 CHECK(profile) << "Cannot get default profile."; |
| 411 |
402 #else | 412 #else |
403 base::FilePath profile_path = | 413 profile = GetStartupProfile(user_data_dir, parsed_command_line); |
404 GetStartupProfilePath(user_data_dir, parsed_command_line); | |
405 | 414 |
406 profile = g_browser_process->profile_manager()->GetProfile( | 415 if (!profile && !profile_dir_specified) |
407 profile_path); | 416 profile = GetFallbackStartupProfile(); |
408 | 417 |
409 // If we're using the --new-profile-management flag and this profile is | 418 if (!profile) { |
410 // signed out, then we should show the user manager instead. By switching | 419 ProfileErrorType error_type = profile_dir_specified ? |
411 // the active profile to the guest profile we ensure that no | 420 PROFILE_ERROR_CREATE_FAILURE_SPECIFIED : |
412 // browser windows will be opened for the guest profile. | 421 PROFILE_ERROR_CREATE_FAILURE_ALL; |
413 if (switches::IsNewProfileManagement() && | 422 |
414 profile && | 423 ShowProfileErrorDialog(error_type, IDS_COULDNT_STARTUP_PROFILE_ERROR); |
415 !profile->IsGuestSession()) { | 424 return nullptr; |
416 ProfileAttributesEntry* entry; | |
417 bool has_entry = g_browser_process->profile_manager()-> | |
418 GetProfileAttributesStorage(). | |
419 GetProfileAttributesWithPath(profile_path, &entry); | |
420 if (has_entry && entry->IsSigninRequired()) { | |
421 profile = g_browser_process->profile_manager()->GetProfile( | |
422 ProfileManager::GetGuestProfilePath()); | |
423 } | |
424 } | 425 } |
425 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) | 426 #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 | 427 |
432 #if !defined(OS_WIN) | 428 UMA_HISTOGRAM_LONG_TIMES( |
433 // TODO(port): fix this. See comments near the definition of | 429 "Startup.CreateFirstProfile", base::Time::Now() - start); |
434 // user_data_dir. It is better to CHECK-fail here than it is to | 430 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 } | 431 } |
441 | 432 |
442 #if defined(OS_MACOSX) | 433 #if defined(OS_MACOSX) |
443 OSStatus KeychainCallback(SecKeychainEvent keychain_event, | 434 OSStatus KeychainCallback(SecKeychainEvent keychain_event, |
444 SecKeychainCallbackInfo* info, void* context) { | 435 SecKeychainCallbackInfo* info, void* context) { |
445 return noErr; | 436 return noErr; |
446 } | 437 } |
447 #endif // defined(OS_MACOSX) | 438 #endif // defined(OS_MACOSX) |
448 | 439 |
449 void RegisterComponentsForUpdate() { | 440 void RegisterComponentsForUpdate() { |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 chromeos::CrosSettings::Shutdown(); | 1974 chromeos::CrosSettings::Shutdown(); |
1984 #endif // defined(OS_CHROMEOS) | 1975 #endif // defined(OS_CHROMEOS) |
1985 #endif // defined(OS_ANDROID) | 1976 #endif // defined(OS_ANDROID) |
1986 } | 1977 } |
1987 | 1978 |
1988 // Public members: | 1979 // Public members: |
1989 | 1980 |
1990 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1981 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1991 chrome_extra_parts_.push_back(parts); | 1982 chrome_extra_parts_.push_back(parts); |
1992 } | 1983 } |
OLD | NEW |