Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: chrome/browser/ui/browser_init.cc

Issue 8907025: Merge 114213 - Fixes for the kWasRestarted pref. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/963/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser_init.h ('k') | chrome/browser/ui/browser_list.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 const PrefService* prefs) { 326 const PrefService* prefs) {
327 IncognitoModePrefs::Availability incognito_avail = 327 IncognitoModePrefs::Availability incognito_avail =
328 IncognitoModePrefs::GetAvailability(prefs); 328 IncognitoModePrefs::GetAvailability(prefs);
329 return incognito_avail != IncognitoModePrefs::DISABLED && 329 return incognito_avail != IncognitoModePrefs::DISABLED &&
330 (command_line.HasSwitch(switches::kIncognito) || 330 (command_line.HasSwitch(switches::kIncognito) ||
331 incognito_avail == IncognitoModePrefs::FORCED); 331 incognito_avail == IncognitoModePrefs::FORCED);
332 } 332 }
333 333
334 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, 334 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line,
335 Profile* profile) { 335 Profile* profile) {
336 PrefService* pref_service = g_browser_process->local_state();
337 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); 336 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile);
338 if (command_line.HasSwitch(switches::kRestoreLastSession) || 337 if (command_line.HasSwitch(switches::kRestoreLastSession) ||
339 pref_service->GetBoolean(prefs::kWasRestarted)) { 338 BrowserInit::WasRestarted()) {
340 pref.type = SessionStartupPref::LAST; 339 pref.type = SessionStartupPref::LAST;
341 } 340 }
342 if (pref.type == SessionStartupPref::LAST && 341 if (pref.type == SessionStartupPref::LAST &&
343 IncognitoIsForced(command_line, profile->GetPrefs())) { 342 IncognitoIsForced(command_line, profile->GetPrefs())) {
344 // We don't store session information when incognito. If the user has 343 // We don't store session information when incognito. If the user has
345 // chosen to restore last session and launched incognito, fallback to 344 // chosen to restore last session and launched incognito, fallback to
346 // default launch behavior. 345 // default launch behavior.
347 pref.type = SessionStartupPref::DEFAULT; 346 pref.type = SessionStartupPref::DEFAULT;
348 } 347 }
349 return pref; 348 return pref;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 g_browser_process->crl_set_fetcher()->StartInitialLoad(cus); 489 g_browser_process->crl_set_fetcher()->StartInitialLoad(cus);
491 490
492 cus->Start(); 491 cus->Start();
493 } 492 }
494 493
495 } // namespace 494 } // namespace
496 495
497 496
498 // BrowserInit ---------------------------------------------------------------- 497 // BrowserInit ----------------------------------------------------------------
499 498
499 bool BrowserInit::was_restarted_ = false;
500 bool BrowserInit::was_restarted_read_ = false;
501
500 BrowserInit::BrowserInit() {} 502 BrowserInit::BrowserInit() {}
501 503
502 BrowserInit::~BrowserInit() {} 504 BrowserInit::~BrowserInit() {}
503 505
504 void BrowserInit::AddFirstRunTab(const GURL& url) { 506 void BrowserInit::AddFirstRunTab(const GURL& url) {
505 first_run_tabs_.push_back(url); 507 first_run_tabs_.push_back(url);
506 } 508 }
507 509
508 // static 510 // static
509 bool BrowserInit::InProcessStartup() { 511 bool BrowserInit::InProcessStartup() {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 new chromeos::SmsObserver(profile); 578 new chromeos::SmsObserver(profile);
577 chromeos::CrosLibrary::Get()->GetNetworkLibrary() 579 chromeos::CrosLibrary::Get()->GetNetworkLibrary()
578 ->AddNetworkManagerObserver(sms_observer); 580 ->AddNetworkManagerObserver(sms_observer);
579 581
580 profile->SetupChromeOSEnterpriseExtensionObserver(); 582 profile->SetupChromeOSEnterpriseExtensionObserver();
581 } 583 }
582 #endif 584 #endif
583 return true; 585 return true;
584 } 586 }
585 587
588 // static
589 bool BrowserInit::WasRestarted() {
590 if (!was_restarted_read_) {
591 PrefService* pref_service = g_browser_process->local_state();
592 was_restarted_ = pref_service->GetBoolean(prefs::kWasRestarted);
593 pref_service->SetBoolean(prefs::kWasRestarted, false);
594 pref_service->ScheduleSavePersistentPrefs();
595 was_restarted_read_ = true;
596 }
597 return was_restarted_;
598 }
586 599
587 // BrowserInit::LaunchWithProfile::Tab ---------------------------------------- 600 // BrowserInit::LaunchWithProfile::Tab ----------------------------------------
588 601
589 BrowserInit::LaunchWithProfile::Tab::Tab() : is_app(false), is_pinned(true) {} 602 BrowserInit::LaunchWithProfile::Tab::Tab() : is_app(false), is_pinned(true) {}
590 603
591 BrowserInit::LaunchWithProfile::Tab::~Tab() {} 604 BrowserInit::LaunchWithProfile::Tab::~Tab() {}
592 605
593 606
594 // BrowserInit::LaunchWithProfile --------------------------------------------- 607 // BrowserInit::LaunchWithProfile ---------------------------------------------
595 608
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 1536
1524 Profile* profile = ProfileManager::GetLastUsedProfile(); 1537 Profile* profile = ProfileManager::GetLastUsedProfile();
1525 if (!profile) { 1538 if (!profile) {
1526 // We should only be able to get here if the profile already exists and 1539 // We should only be able to get here if the profile already exists and
1527 // has been created. 1540 // has been created.
1528 NOTREACHED(); 1541 NOTREACHED();
1529 return; 1542 return;
1530 } 1543 }
1531 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, NULL, NULL); 1544 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, NULL, NULL);
1532 } 1545 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_init.h ('k') | chrome/browser/ui/browser_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698