Chromium Code Reviews| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 const PrefService* prefs) { | 328 const PrefService* prefs) { |
| 329 IncognitoModePrefs::Availability incognito_avail = | 329 IncognitoModePrefs::Availability incognito_avail = |
| 330 IncognitoModePrefs::GetAvailability(prefs); | 330 IncognitoModePrefs::GetAvailability(prefs); |
| 331 return incognito_avail != IncognitoModePrefs::DISABLED && | 331 return incognito_avail != IncognitoModePrefs::DISABLED && |
| 332 (command_line.HasSwitch(switches::kIncognito) || | 332 (command_line.HasSwitch(switches::kIncognito) || |
| 333 incognito_avail == IncognitoModePrefs::FORCED); | 333 incognito_avail == IncognitoModePrefs::FORCED); |
| 334 } | 334 } |
| 335 | 335 |
| 336 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, | 336 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, |
| 337 Profile* profile) { | 337 Profile* profile) { |
| 338 PrefService* pref_service = g_browser_process->local_state(); | |
| 339 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); | 338 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); |
| 340 if (command_line.HasSwitch(switches::kRestoreLastSession) || | 339 if (command_line.HasSwitch(switches::kRestoreLastSession) || |
| 341 pref_service->GetBoolean(prefs::kWasRestarted)) { | 340 BrowserInit::WasRestarted()) { |
| 342 pref.type = SessionStartupPref::LAST; | 341 pref.type = SessionStartupPref::LAST; |
| 343 } | 342 } |
| 344 if (pref.type == SessionStartupPref::LAST && | 343 if (pref.type == SessionStartupPref::LAST && |
| 345 IncognitoIsForced(command_line, profile->GetPrefs())) { | 344 IncognitoIsForced(command_line, profile->GetPrefs())) { |
| 346 // We don't store session information when incognito. If the user has | 345 // We don't store session information when incognito. If the user has |
| 347 // chosen to restore last session and launched incognito, fallback to | 346 // chosen to restore last session and launched incognito, fallback to |
| 348 // default launch behavior. | 347 // default launch behavior. |
| 349 pref.type = SessionStartupPref::DEFAULT; | 348 pref.type = SessionStartupPref::DEFAULT; |
| 350 } | 349 } |
| 351 return pref; | 350 return pref; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 g_browser_process->crl_set_fetcher()->StartInitialLoad(cus); | 491 g_browser_process->crl_set_fetcher()->StartInitialLoad(cus); |
| 493 | 492 |
| 494 cus->Start(); | 493 cus->Start(); |
| 495 } | 494 } |
| 496 | 495 |
| 497 } // namespace | 496 } // namespace |
| 498 | 497 |
| 499 | 498 |
| 500 // BrowserInit ---------------------------------------------------------------- | 499 // BrowserInit ---------------------------------------------------------------- |
| 501 | 500 |
| 501 bool BrowserInit::was_restarted_ = false; | |
|
sky
2011/12/13 16:54:42
Since these are only used in WasRestarted, why not
| |
| 502 bool BrowserInit::was_restarted_read_ = false; | |
| 503 | |
| 502 BrowserInit::BrowserInit() {} | 504 BrowserInit::BrowserInit() {} |
| 503 | 505 |
| 504 BrowserInit::~BrowserInit() {} | 506 BrowserInit::~BrowserInit() {} |
| 505 | 507 |
| 506 void BrowserInit::AddFirstRunTab(const GURL& url) { | 508 void BrowserInit::AddFirstRunTab(const GURL& url) { |
| 507 first_run_tabs_.push_back(url); | 509 first_run_tabs_.push_back(url); |
| 508 } | 510 } |
| 509 | 511 |
| 510 // static | 512 // static |
| 511 bool BrowserInit::InProcessStartup() { | 513 bool BrowserInit::InProcessStartup() { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 new chromeos::SmsObserver(profile); | 580 new chromeos::SmsObserver(profile); |
| 579 chromeos::CrosLibrary::Get()->GetNetworkLibrary() | 581 chromeos::CrosLibrary::Get()->GetNetworkLibrary() |
| 580 ->AddNetworkManagerObserver(sms_observer); | 582 ->AddNetworkManagerObserver(sms_observer); |
| 581 | 583 |
| 582 profile->SetupChromeOSEnterpriseExtensionObserver(); | 584 profile->SetupChromeOSEnterpriseExtensionObserver(); |
| 583 } | 585 } |
| 584 #endif | 586 #endif |
| 585 return true; | 587 return true; |
| 586 } | 588 } |
| 587 | 589 |
| 590 // static | |
| 591 bool BrowserInit::WasRestarted() { | |
| 592 if (!was_restarted_read_) { | |
| 593 PrefService* pref_service = g_browser_process->local_state(); | |
| 594 was_restarted_ = pref_service->GetBoolean(prefs::kWasRestarted); | |
| 595 pref_service->SetBoolean(prefs::kWasRestarted, false); | |
| 596 pref_service->ScheduleSavePersistentPrefs(); | |
| 597 was_restarted_read_ = true; | |
| 598 } | |
| 599 return was_restarted_; | |
| 600 } | |
| 588 | 601 |
| 589 // BrowserInit::LaunchWithProfile::Tab ---------------------------------------- | 602 // BrowserInit::LaunchWithProfile::Tab ---------------------------------------- |
| 590 | 603 |
| 591 BrowserInit::LaunchWithProfile::Tab::Tab() : is_app(false), is_pinned(true) {} | 604 BrowserInit::LaunchWithProfile::Tab::Tab() : is_app(false), is_pinned(true) {} |
| 592 | 605 |
| 593 BrowserInit::LaunchWithProfile::Tab::~Tab() {} | 606 BrowserInit::LaunchWithProfile::Tab::~Tab() {} |
| 594 | 607 |
| 595 | 608 |
| 596 // BrowserInit::LaunchWithProfile --------------------------------------------- | 609 // BrowserInit::LaunchWithProfile --------------------------------------------- |
| 597 | 610 |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1525 | 1538 |
| 1526 Profile* profile = ProfileManager::GetLastUsedProfile(); | 1539 Profile* profile = ProfileManager::GetLastUsedProfile(); |
| 1527 if (!profile) { | 1540 if (!profile) { |
| 1528 // We should only be able to get here if the profile already exists and | 1541 // We should only be able to get here if the profile already exists and |
| 1529 // has been created. | 1542 // has been created. |
| 1530 NOTREACHED(); | 1543 NOTREACHED(); |
| 1531 return; | 1544 return; |
| 1532 } | 1545 } |
| 1533 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, NULL, NULL); | 1546 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, NULL, NULL); |
| 1534 } | 1547 } |
| OLD | NEW |