Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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. | |
| 125 const bool no_first_run = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 126 switches::kNoFirstRun); | |
|
Greg Levin
2016/11/22 00:13:40
I'm not sure about all the use cases of this flag,
achuithb
2016/11/22 00:38:47
Done.
Greg Levin
2016/11/22 16:57:29
Sorry, didn't mean to imply that you *should* swit
achuithb
2016/11/22 21:37:43
Done.
| |
| 127 | |
| 128 if (!enterprise_managed && !no_first_run) | |
| 122 chrome::AddTabAt(browser, GURL(kGoodiesURL), 2, false); | 129 chrome::AddTabAt(browser, GURL(kGoodiesURL), 2, false); |
| 123 | 130 |
| 124 // Set to |false| whether enterprise enrolled or Goodies shown. | 131 // Set to |false| whether enterprise enrolled or Goodies shown. |
| 125 local_state->SetBoolean(prefs::kCanShowOobeGoodiesPage, false); | 132 local_state->SetBoolean(prefs::kCanShowOobeGoodiesPage, false); |
| 126 } | 133 } |
| 127 | 134 |
| 128 // Regardless of how we got here, we don't henceforth need to show Goodies. | 135 // Regardless of how we got here, we don't henceforth need to show Goodies. |
| 129 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::Bind(&Delete)); | 136 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::Bind(&Delete)); |
| 130 } | 137 } |
| 131 | 138 |
| 132 GoodiesDisplayerTestInfo::GoodiesDisplayerTestInfo() | 139 GoodiesDisplayerTestInfo::GoodiesDisplayerTestInfo() |
| 133 : days_since_oobe(0), setup_complete(false) {} | 140 : days_since_oobe(0), setup_complete(false) {} |
| 134 | 141 |
| 135 GoodiesDisplayerTestInfo::~GoodiesDisplayerTestInfo() {} | 142 GoodiesDisplayerTestInfo::~GoodiesDisplayerTestInfo() {} |
| 136 | 143 |
| 137 } // namespace first_run | 144 } // namespace first_run |
| 138 } // namespace chromeos | 145 } // namespace chromeos |
| OLD | NEW |