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

Side by Side Diff: chrome/browser/chromeos/first_run/goodies_displayer.cc

Issue 2519173003: Do not display goodies with --no-first-run. (Closed)
Patch Set: Use kNoFirstRun and kForceFirstRun. Created 4 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/first_run/goodies_displayer_browsertest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chromeos/first_run/goodies_displayer.h" 5 #include "chrome/browser/chromeos/first_run/goodies_displayer.h"
6 6
7 #include "base/command_line.h"
7 #include "base/location.h" 8 #include "base/location.h"
8 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
9 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chromeos/login/startup_utils.h" 12 #include "chrome/browser/chromeos/login/startup_utils.h"
12 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 13 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/browser_tabstrip.h" 17 #include "chrome/browser/ui/browser_tabstrip.h"
18 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
18 #include "components/prefs/pref_service.h" 20 #include "components/prefs/pref_service.h"
19 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
20 22
21 namespace chromeos { 23 namespace chromeos {
22 namespace first_run { 24 namespace first_run {
23 25
24 namespace { 26 namespace {
25 27
26 GoodiesDisplayer* g_goodies_displayer = nullptr; 28 GoodiesDisplayer* g_goodies_displayer = nullptr;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return; 111 return;
110 112
111 // 2. Not guest or incognito session (keep observing). 113 // 2. Not guest or incognito session (keep observing).
112 if (browser->profile()->IsOffTheRecord()) 114 if (browser->profile()->IsOffTheRecord())
113 return; 115 return;
114 116
115 PrefService* local_state = g_browser_process->local_state(); 117 PrefService* local_state = g_browser_process->local_state();
116 // 3. Not previously shown, or otherwise marked as unavailable. 118 // 3. Not previously shown, or otherwise marked as unavailable.
117 if (local_state->GetBoolean(prefs::kCanShowOobeGoodiesPage)) { 119 if (local_state->GetBoolean(prefs::kCanShowOobeGoodiesPage)) {
118 // 4. Device not enterprise enrolled. 120 // 4. Device not enterprise enrolled.
119 if (!g_browser_process->platform_part() 121 const bool enterprise_managed = g_browser_process->platform_part()
120 ->browser_policy_connector_chromeos() 122 ->browser_policy_connector_chromeos()
121 ->IsEnterpriseManaged()) 123 ->IsEnterpriseManaged();
124 // 5. --no-first-run not specified, as it is for tests. --force-run takes
125 // precedence over --no-first-run.
126 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
127 const bool is_first_run =
Greg Levin 2016/11/22 21:49:21 Looks good. One last optional nit, totally at you
achuithb 2016/11/22 22:08:25 I've renamed this. This variable exists purely so
128 command_line->HasSwitch(switches::kForceFirstRun) ||
129 !command_line->HasSwitch(switches::kNoFirstRun);
130
131 if (!enterprise_managed && is_first_run)
122 chrome::AddTabAt(browser, GURL(kGoodiesURL), 2, false); 132 chrome::AddTabAt(browser, GURL(kGoodiesURL), 2, false);
123 133
124 // Set to |false| whether enterprise enrolled or Goodies shown. 134 // Set to |false| whether enterprise enrolled or Goodies shown.
125 local_state->SetBoolean(prefs::kCanShowOobeGoodiesPage, false); 135 local_state->SetBoolean(prefs::kCanShowOobeGoodiesPage, false);
126 } 136 }
127 137
128 // Regardless of how we got here, we don't henceforth need to show Goodies. 138 // Regardless of how we got here, we don't henceforth need to show Goodies.
129 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::Bind(&Delete)); 139 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::Bind(&Delete));
130 } 140 }
131 141
132 GoodiesDisplayerTestInfo::GoodiesDisplayerTestInfo() 142 GoodiesDisplayerTestInfo::GoodiesDisplayerTestInfo()
133 : days_since_oobe(0), setup_complete(false) {} 143 : days_since_oobe(0), setup_complete(false) {}
134 144
135 GoodiesDisplayerTestInfo::~GoodiesDisplayerTestInfo() {} 145 GoodiesDisplayerTestInfo::~GoodiesDisplayerTestInfo() {}
136 146
137 } // namespace first_run 147 } // namespace first_run
138 } // namespace chromeos 148 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/first_run/goodies_displayer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698