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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator.cc

Issue 10417032: Disable sync promo when RestoreOnStartupURLs policy is used (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Nit addressed. Created 8 years, 7 months 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
« no previous file with comments | « chrome/browser/prefs/session_startup_pref.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/startup/startup_browser_creator.h" 5 #include "chrome/browser/ui/startup/startup_browser_creator.h"
6 6
7 #include <algorithm> // For max(). 7 #include <algorithm> // For max().
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/environment.h" 14 #include "base/environment.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
18 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
19 #include "base/path_service.h" 20 #include "base/path_service.h"
20 #include "base/string_number_conversions.h" 21 #include "base/string_number_conversions.h"
21 #include "base/string_split.h" 22 #include "base/string_split.h"
22 #include "base/threading/thread_restrictions.h" 23 #include "base/threading/thread_restrictions.h"
23 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
24 #include "chrome/browser/auto_launch_trial.h" 25 #include "chrome/browser/auto_launch_trial.h"
25 #include "chrome/browser/automation/automation_provider.h" 26 #include "chrome/browser/automation/automation_provider.h"
26 #include "chrome/browser/automation/automation_provider_list.h" 27 #include "chrome/browser/automation/automation_provider_list.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 pref_service->SetBoolean(prefs::kWasRestarted, false); 224 pref_service->SetBoolean(prefs::kWasRestarted, false);
224 was_restarted_read_ = true; 225 was_restarted_read_ = true;
225 } 226 }
226 return was_restarted; 227 return was_restarted;
227 } 228 }
228 229
229 // static 230 // static
230 SessionStartupPref StartupBrowserCreator::GetSessionStartupPref( 231 SessionStartupPref StartupBrowserCreator::GetSessionStartupPref(
231 const CommandLine& command_line, 232 const CommandLine& command_line,
232 Profile* profile) { 233 Profile* profile) {
233 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); 234 DCHECK(profile);
235 PrefService* prefs = profile->GetPrefs();
236 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs);
234 237
235 // Session restore should be avoided on the first run. 238 // The pref has an OS-dependent default value. For the first run only, this
236 if (first_run::IsChromeFirstRun()) 239 // default is overridden with SessionStartupPref::DEFAULT so that first run
240 // behavior (sync promo, welcome page) is consistently invoked.
241 // This applies only if the pref is still at its default and has not been
242 // set by the user, managed prefs or policy.
243 if (first_run::IsChromeFirstRun() && SessionStartupPref::TypeIsDefault(prefs))
237 pref.type = SessionStartupPref::DEFAULT; 244 pref.type = SessionStartupPref::DEFAULT;
238 245
239 if (command_line.HasSwitch(switches::kRestoreLastSession) || 246 if (command_line.HasSwitch(switches::kRestoreLastSession) ||
240 StartupBrowserCreator::WasRestarted()) { 247 StartupBrowserCreator::WasRestarted()) {
241 pref.type = SessionStartupPref::LAST; 248 pref.type = SessionStartupPref::LAST;
242 } 249 }
243 if (pref.type == SessionStartupPref::LAST && 250 if (pref.type == SessionStartupPref::LAST &&
244 IncognitoModePrefs::ShouldLaunchIncognito(command_line, 251 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) {
245 profile->GetPrefs())) {
246 // We don't store session information when incognito. If the user has 252 // We don't store session information when incognito. If the user has
247 // chosen to restore last session and launched incognito, fallback to 253 // chosen to restore last session and launched incognito, fallback to
248 // default launch behavior. 254 // default launch behavior.
249 pref.type = SessionStartupPref::DEFAULT; 255 pref.type = SessionStartupPref::DEFAULT;
250 } 256 }
251 return pref; 257 return pref;
252 } 258 }
253 259
254 std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine( 260 std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine(
255 const CommandLine& command_line, 261 const CommandLine& command_line,
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return; 575 return;
570 } 576 }
571 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); 577 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL);
572 } 578 }
573 579
574 bool HasPendingUncleanExit(Profile* profile) { 580 bool HasPendingUncleanExit(Profile* profile) {
575 return !profile->DidLastSessionExitCleanly() && 581 return !profile->DidLastSessionExitCleanly() &&
576 !profile_launch_observer.Get().HasBeenLaunched(profile); 582 !profile_launch_observer.Get().HasBeenLaunched(profile);
577 } 583 }
578 584
OLDNEW
« no previous file with comments | « chrome/browser/prefs/session_startup_pref.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698