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