| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/browser_init.h" | 5 #include "chrome/browser/ui/browser_init.h" |
| 6 | 6 |
| 7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/defaults.h" | 25 #include "chrome/browser/defaults.h" |
| 26 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 26 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 27 #include "chrome/browser/extensions/extension_creator.h" | 27 #include "chrome/browser/extensions/extension_creator.h" |
| 28 #include "chrome/browser/extensions/extension_service.h" | 28 #include "chrome/browser/extensions/extension_service.h" |
| 29 #include "chrome/browser/extensions/pack_extension_job.h" | 29 #include "chrome/browser/extensions/pack_extension_job.h" |
| 30 #include "chrome/browser/first_run/first_run.h" | 30 #include "chrome/browser/first_run/first_run.h" |
| 31 #include "chrome/browser/net/predictor_api.h" | 31 #include "chrome/browser/net/predictor_api.h" |
| 32 #include "chrome/browser/net/url_fixer_upper.h" | 32 #include "chrome/browser/net/url_fixer_upper.h" |
| 33 #include "chrome/browser/notifications/desktop_notification_service.h" | 33 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 34 #include "chrome/browser/prefs/incognito_mode_availability_prefs.h" |
| 34 #include "chrome/browser/prefs/pref_service.h" | 35 #include "chrome/browser/prefs/pref_service.h" |
| 35 #include "chrome/browser/prefs/session_startup_pref.h" | 36 #include "chrome/browser/prefs/session_startup_pref.h" |
| 36 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 37 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 37 #include "chrome/browser/printing/print_dialog_cloud.h" | 38 #include "chrome/browser/printing/print_dialog_cloud.h" |
| 38 #include "chrome/browser/profiles/profile.h" | 39 #include "chrome/browser/profiles/profile.h" |
| 39 #include "chrome/browser/profiles/profile_io_data.h" | 40 #include "chrome/browser/profiles/profile_io_data.h" |
| 40 #include "chrome/browser/search_engines/template_url.h" | 41 #include "chrome/browser/search_engines/template_url.h" |
| 41 #include "chrome/browser/search_engines/template_url_service.h" | 42 #include "chrome/browser/search_engines/template_url_service.h" |
| 42 #include "chrome/browser/search_engines/template_url_service_factory.h" | 43 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 43 #include "chrome/browser/sessions/session_restore.h" | 44 #include "chrome/browser/sessions/session_restore.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 358 } |
| 358 | 359 |
| 359 | 360 |
| 360 // Utility functions ---------------------------------------------------------- | 361 // Utility functions ---------------------------------------------------------- |
| 361 | 362 |
| 362 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, | 363 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, |
| 363 Profile* profile) { | 364 Profile* profile) { |
| 364 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); | 365 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); |
| 365 if (command_line.HasSwitch(switches::kRestoreLastSession)) | 366 if (command_line.HasSwitch(switches::kRestoreLastSession)) |
| 366 pref.type = SessionStartupPref::LAST; | 367 pref.type = SessionStartupPref::LAST; |
| 367 if ((command_line.HasSwitch(switches::kIncognito) || | 368 // Safe to cast: value's been sanitized at initialization. |
| 368 profile->GetPrefs()->GetBoolean(prefs::kIncognitoForced)) && | 369 IncognitoModeAvailabilityPrefs::IncognitoModeAvailability incognito_avail = |
| 369 pref.type == SessionStartupPref::LAST && | 370 static_cast<IncognitoModeAvailabilityPrefs::IncognitoModeAvailability>( |
| 370 profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) { | 371 profile->GetPrefs()->GetInteger(prefs::kIncognitoModeAvailability)); |
| 372 if (incognito_avail == IncognitoModeAvailabilityPrefs::FORCED) { |
| 371 // We don't store session information when incognito. If the user has | 373 // We don't store session information when incognito. If the user has |
| 372 // chosen to restore last session and launched incognito, fallback to | 374 // chosen to restore last session and launched incognito, fallback to |
| 373 // default launch behavior. | 375 // default launch behavior. |
| 374 pref.type = SessionStartupPref::DEFAULT; | 376 pref.type = SessionStartupPref::DEFAULT; |
| 375 } | 377 } |
| 376 return pref; | 378 return pref; |
| 377 } | 379 } |
| 378 | 380 |
| 379 enum LaunchMode { | 381 enum LaunchMode { |
| 380 LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut. | 382 LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 if (process_startup) { | 531 if (process_startup) { |
| 530 // NetworkStateNotifier has to be initialized before Launching browser | 532 // NetworkStateNotifier has to be initialized before Launching browser |
| 531 // because the page load can happen in parallel to this UI thread | 533 // because the page load can happen in parallel to this UI thread |
| 532 // and IO thread may access the NetworkStateNotifier. | 534 // and IO thread may access the NetworkStateNotifier. |
| 533 chromeos::CrosLibrary::Get()->GetNetworkLibrary() | 535 chromeos::CrosLibrary::Get()->GetNetworkLibrary() |
| 534 ->AddNetworkManagerObserver( | 536 ->AddNetworkManagerObserver( |
| 535 chromeos::NetworkStateNotifier::GetInstance()); | 537 chromeos::NetworkStateNotifier::GetInstance()); |
| 536 } | 538 } |
| 537 #endif | 539 #endif |
| 538 | 540 |
| 541 // Safe to cast: the value has been sanitized at initialization. |
| 542 IncognitoModeAvailabilityPrefs::IncognitoModeAvailability incognito_avail = |
| 543 static_cast<IncognitoModeAvailabilityPrefs::IncognitoModeAvailability>( |
| 544 profile->GetPrefs()->GetInteger(prefs::kIncognitoModeAvailability)); |
| 539 // Continue with the incognito profile from here on if --incognito | 545 // Continue with the incognito profile from here on if --incognito |
| 540 if ((command_line.HasSwitch(switches::kIncognito) || | 546 if (incognito_avail == IncognitoModeAvailabilityPrefs::FORCED) { |
| 541 profile->GetPrefs()->GetBoolean(prefs::kIncognitoForced)) && | |
| 542 profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) { | |
| 543 profile = profile->GetOffTheRecordProfile(); | 547 profile = profile->GetOffTheRecordProfile(); |
| 544 } | 548 } |
| 545 | 549 |
| 546 BrowserInit::LaunchWithProfile lwp(cur_dir, command_line, this); | 550 BrowserInit::LaunchWithProfile lwp(cur_dir, command_line, this); |
| 547 std::vector<GURL> urls_to_launch = BrowserInit::GetURLsFromCommandLine( | 551 std::vector<GURL> urls_to_launch = BrowserInit::GetURLsFromCommandLine( |
| 548 command_line, cur_dir, profile); | 552 command_line, cur_dir, profile); |
| 549 bool launched = lwp.Launch(profile, urls_to_launch, process_startup); | 553 bool launched = lwp.Launch(profile, urls_to_launch, process_startup); |
| 550 in_startup = false; | 554 in_startup = false; |
| 551 | 555 |
| 552 if (!launched) { | 556 if (!launched) { |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 return false; | 1444 return false; |
| 1441 automation->SetExpectedTabCount(expected_tabs); | 1445 automation->SetExpectedTabCount(expected_tabs); |
| 1442 | 1446 |
| 1443 AutomationProviderList* list = | 1447 AutomationProviderList* list = |
| 1444 g_browser_process->InitAutomationProviderList(); | 1448 g_browser_process->InitAutomationProviderList(); |
| 1445 DCHECK(list); | 1449 DCHECK(list); |
| 1446 list->AddProvider(automation); | 1450 list->AddProvider(automation); |
| 1447 | 1451 |
| 1448 return true; | 1452 return true; |
| 1449 } | 1453 } |
| OLD | NEW |