| 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); | 282 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); |
| 283 }; | 283 }; |
| 284 | 284 |
| 285 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, | 285 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, |
| 286 Profile* profile) { | 286 Profile* profile) { |
| 287 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); | 287 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); |
| 288 if (command_line.HasSwitch(switches::kRestoreLastSession)) | 288 if (command_line.HasSwitch(switches::kRestoreLastSession)) |
| 289 pref.type = SessionStartupPref::LAST; | 289 pref.type = SessionStartupPref::LAST; |
| 290 if (command_line.HasSwitch(switches::kIncognito) && | 290 if (command_line.HasSwitch(switches::kIncognito) && |
| 291 pref.type == SessionStartupPref::LAST) { | 291 pref.type == SessionStartupPref::LAST && |
| 292 profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) { |
| 292 // We don't store session information when incognito. If the user has | 293 // We don't store session information when incognito. If the user has |
| 293 // chosen to restore last session and launched incognito, fallback to | 294 // chosen to restore last session and launched incognito, fallback to |
| 294 // default launch behavior. | 295 // default launch behavior. |
| 295 pref.type = SessionStartupPref::DEFAULT; | 296 pref.type = SessionStartupPref::DEFAULT; |
| 296 } | 297 } |
| 297 return pref; | 298 return pref; |
| 298 } | 299 } |
| 299 | 300 |
| 300 enum LaunchMode { | 301 enum LaunchMode { |
| 301 LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut. | 302 LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 // NetworkStateNotifier has to be initialized before Launching browser | 393 // NetworkStateNotifier has to be initialized before Launching browser |
| 393 // because the page load can happen in parallel to this UI thread | 394 // because the page load can happen in parallel to this UI thread |
| 394 // and IO thread may access the NetworkStateNotifier. | 395 // and IO thread may access the NetworkStateNotifier. |
| 395 chromeos::CrosLibrary::Get()->GetNetworkLibrary() | 396 chromeos::CrosLibrary::Get()->GetNetworkLibrary() |
| 396 ->AddNetworkManagerObserver( | 397 ->AddNetworkManagerObserver( |
| 397 chromeos::NetworkStateNotifier::GetInstance()); | 398 chromeos::NetworkStateNotifier::GetInstance()); |
| 398 } | 399 } |
| 399 #endif | 400 #endif |
| 400 | 401 |
| 401 // Continue with the off-the-record profile from here on if --incognito | 402 // Continue with the off-the-record profile from here on if --incognito |
| 402 if (command_line.HasSwitch(switches::kIncognito)) | 403 if (command_line.HasSwitch(switches::kIncognito) && |
| 404 profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) { |
| 403 profile = profile->GetOffTheRecordProfile(); | 405 profile = profile->GetOffTheRecordProfile(); |
| 406 } |
| 404 | 407 |
| 405 BrowserInit::LaunchWithProfile lwp(cur_dir, command_line, this); | 408 BrowserInit::LaunchWithProfile lwp(cur_dir, command_line, this); |
| 406 bool launched = lwp.Launch(profile, process_startup); | 409 bool launched = lwp.Launch(profile, process_startup); |
| 407 in_startup = false; | 410 in_startup = false; |
| 408 | 411 |
| 409 if (!launched) { | 412 if (!launched) { |
| 410 LOG(ERROR) << "launch error"; | 413 LOG(ERROR) << "launch error"; |
| 411 if (return_code) | 414 if (return_code) |
| 412 *return_code = ResultCodes::INVALID_CMDLINE_URL; | 415 *return_code = ResultCodes::INVALID_CMDLINE_URL; |
| 413 return false; | 416 return false; |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 return false; | 1099 return false; |
| 1097 automation->SetExpectedTabCount(expected_tabs); | 1100 automation->SetExpectedTabCount(expected_tabs); |
| 1098 | 1101 |
| 1099 AutomationProviderList* list = | 1102 AutomationProviderList* list = |
| 1100 g_browser_process->InitAutomationProviderList(); | 1103 g_browser_process->InitAutomationProviderList(); |
| 1101 DCHECK(list); | 1104 DCHECK(list); |
| 1102 list->AddProvider(automation); | 1105 list->AddProvider(automation); |
| 1103 | 1106 |
| 1104 return true; | 1107 return true; |
| 1105 } | 1108 } |
| OLD | NEW |