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/environment.h" | 9 #include "base/environment.h" |
10 #include "base/event_recorder.h" | 10 #include "base/event_recorder.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 363 |
364 | 364 |
365 // Utility functions ---------------------------------------------------------- | 365 // Utility functions ---------------------------------------------------------- |
366 | 366 |
367 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, | 367 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, |
368 Profile* profile) { | 368 Profile* profile) { |
369 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); | 369 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); |
370 if (command_line.HasSwitch(switches::kRestoreLastSession)) | 370 if (command_line.HasSwitch(switches::kRestoreLastSession)) |
371 pref.type = SessionStartupPref::LAST; | 371 pref.type = SessionStartupPref::LAST; |
372 if (command_line.HasSwitch(switches::kIncognito) && | 372 if (command_line.HasSwitch(switches::kIncognito) && |
373 pref.type == SessionStartupPref::LAST) { | 373 pref.type == SessionStartupPref::LAST && |
| 374 profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) { |
374 // We don't store session information when incognito. If the user has | 375 // We don't store session information when incognito. If the user has |
375 // chosen to restore last session and launched incognito, fallback to | 376 // chosen to restore last session and launched incognito, fallback to |
376 // default launch behavior. | 377 // default launch behavior. |
377 pref.type = SessionStartupPref::DEFAULT; | 378 pref.type = SessionStartupPref::DEFAULT; |
378 } | 379 } |
379 return pref; | 380 return pref; |
380 } | 381 } |
381 | 382 |
382 enum LaunchMode { | 383 enum LaunchMode { |
383 LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut. | 384 LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // NetworkStateNotifier has to be initialized before Launching browser | 478 // NetworkStateNotifier has to be initialized before Launching browser |
478 // because the page load can happen in parallel to this UI thread | 479 // because the page load can happen in parallel to this UI thread |
479 // and IO thread may access the NetworkStateNotifier. | 480 // and IO thread may access the NetworkStateNotifier. |
480 chromeos::CrosLibrary::Get()->GetNetworkLibrary() | 481 chromeos::CrosLibrary::Get()->GetNetworkLibrary() |
481 ->AddNetworkManagerObserver( | 482 ->AddNetworkManagerObserver( |
482 chromeos::NetworkStateNotifier::GetInstance()); | 483 chromeos::NetworkStateNotifier::GetInstance()); |
483 } | 484 } |
484 #endif | 485 #endif |
485 | 486 |
486 // Continue with the off-the-record profile from here on if --incognito | 487 // Continue with the off-the-record profile from here on if --incognito |
487 if (command_line.HasSwitch(switches::kIncognito)) | 488 if (command_line.HasSwitch(switches::kIncognito) && |
| 489 profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) { |
488 profile = profile->GetOffTheRecordProfile(); | 490 profile = profile->GetOffTheRecordProfile(); |
| 491 } |
489 | 492 |
490 BrowserInit::LaunchWithProfile lwp(cur_dir, command_line, this); | 493 BrowserInit::LaunchWithProfile lwp(cur_dir, command_line, this); |
491 bool launched = lwp.Launch(profile, process_startup); | 494 bool launched = lwp.Launch(profile, process_startup); |
492 in_startup = false; | 495 in_startup = false; |
493 | 496 |
494 if (!launched) { | 497 if (!launched) { |
495 LOG(ERROR) << "launch error"; | 498 LOG(ERROR) << "launch error"; |
496 if (return_code) | 499 if (return_code) |
497 *return_code = ResultCodes::INVALID_CMDLINE_URL; | 500 *return_code = ResultCodes::INVALID_CMDLINE_URL; |
498 return false; | 501 return false; |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 return false; | 1195 return false; |
1193 automation->SetExpectedTabCount(expected_tabs); | 1196 automation->SetExpectedTabCount(expected_tabs); |
1194 | 1197 |
1195 AutomationProviderList* list = | 1198 AutomationProviderList* list = |
1196 g_browser_process->InitAutomationProviderList(); | 1199 g_browser_process->InitAutomationProviderList(); |
1197 DCHECK(list); | 1200 DCHECK(list); |
1198 list->AddProvider(automation); | 1201 list->AddProvider(automation); |
1199 | 1202 |
1200 return true; | 1203 return true; |
1201 } | 1204 } |
OLD | NEW |