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

Side by Side Diff: chrome/browser/chromeos/system/device_disabling_manager.cc

Issue 819133004: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/system/device_disabling_manager.h" 5 #include "chrome/browser/chromeos/system/device_disabling_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 void DeviceDisablingManager::AddObserver(Observer* observer) { 52 void DeviceDisablingManager::AddObserver(Observer* observer) {
53 observers_.AddObserver(observer); 53 observers_.AddObserver(observer);
54 } 54 }
55 55
56 void DeviceDisablingManager::RemoveObserver(Observer* observer) { 56 void DeviceDisablingManager::RemoveObserver(Observer* observer) {
57 observers_.RemoveObserver(observer); 57 observers_.RemoveObserver(observer);
58 } 58 }
59 59
60 void DeviceDisablingManager::Init() { 60 void DeviceDisablingManager::Init() {
61 if (CommandLine::ForCurrentProcess()->HasSwitch( 61 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
62 switches::kDisableDeviceDisabling)) { 62 switches::kDisableDeviceDisabling)) {
63 // If device disabling is turned off by flags, do not start monitoring cros 63 // If device disabling is turned off by flags, do not start monitoring cros
64 // settings. 64 // settings.
65 return; 65 return;
66 } 66 }
67 67
68 device_disabled_subscription_ = cros_settings_->AddSettingsObserver( 68 device_disabled_subscription_ = cros_settings_->AddSettingsObserver(
69 kDeviceDisabled, 69 kDeviceDisabled,
70 base::Bind(&DeviceDisablingManager::UpdateFromCrosSettings, 70 base::Bind(&DeviceDisablingManager::UpdateFromCrosSettings,
71 weak_factory_.GetWeakPtr())); 71 weak_factory_.GetWeakPtr()));
(...skipping 12 matching lines...) Expand all
84 84
85 disabled_message_ = disabled_message; 85 disabled_message_ = disabled_message;
86 FOR_EACH_OBSERVER(Observer, 86 FOR_EACH_OBSERVER(Observer,
87 observers_, 87 observers_,
88 OnDisabledMessageChanged(disabled_message_)); 88 OnDisabledMessageChanged(disabled_message_));
89 } 89 }
90 90
91 void DeviceDisablingManager::CheckWhetherDeviceDisabledDuringOOBE( 91 void DeviceDisablingManager::CheckWhetherDeviceDisabledDuringOOBE(
92 const DeviceDisabledCheckCallback& callback) { 92 const DeviceDisabledCheckCallback& callback) {
93 if (policy::GetRestoreMode() != policy::RESTORE_MODE_DISABLED || 93 if (policy::GetRestoreMode() != policy::RESTORE_MODE_DISABLED ||
94 CommandLine::ForCurrentProcess()->HasSwitch( 94 base::CommandLine::ForCurrentProcess()->HasSwitch(
95 switches::kDisableDeviceDisabling)) { 95 switches::kDisableDeviceDisabling)) {
96 // Indicate that the device is not disabled if it is not marked as such in 96 // Indicate that the device is not disabled if it is not marked as such in
97 // local state or device disabling has been turned off by flag. 97 // local state or device disabling has been turned off by flag.
98 callback.Run(false); 98 callback.Run(false);
99 return; 99 return;
100 } 100 }
101 101
102 if (browser_policy_connector_->GetDeviceMode() == 102 if (browser_policy_connector_->GetDeviceMode() ==
103 policy::DEVICE_MODE_PENDING) { 103 policy::DEVICE_MODE_PENDING) {
104 // If the device mode is not known yet, request to be called back once it 104 // If the device mode is not known yet, request to be called back once it
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 CacheDisabledMessageAndNotify(disabled_message); 143 CacheDisabledMessageAndNotify(disabled_message);
144 144
145 // Indicate that the device is disabled. 145 // Indicate that the device is disabled.
146 callback.Run(true); 146 callback.Run(true);
147 } 147 }
148 148
149 // static 149 // static
150 bool DeviceDisablingManager::HonorDeviceDisablingDuringNormalOperation() { 150 bool DeviceDisablingManager::HonorDeviceDisablingDuringNormalOperation() {
151 // Device disabling should be honored when the device is enterprise managed 151 // Device disabling should be honored when the device is enterprise managed
152 // and device disabling has not been turned off by flag. 152 // and device disabling has not been turned off by flag.
153 return g_browser_process->platform_part()-> 153 return g_browser_process->platform_part()
154 browser_policy_connector_chromeos()->IsEnterpriseManaged() && 154 ->browser_policy_connector_chromeos()
155 !CommandLine::ForCurrentProcess()->HasSwitch( 155 ->IsEnterpriseManaged() &&
156 switches::kDisableDeviceDisabling); 156 !base::CommandLine::ForCurrentProcess()->HasSwitch(
157 switches::kDisableDeviceDisabling);
157 } 158 }
158 159
159 void DeviceDisablingManager::UpdateFromCrosSettings() { 160 void DeviceDisablingManager::UpdateFromCrosSettings() {
160 if (cros_settings_->PrepareTrustedValues(base::Bind( 161 if (cros_settings_->PrepareTrustedValues(base::Bind(
161 &DeviceDisablingManager::UpdateFromCrosSettings, 162 &DeviceDisablingManager::UpdateFromCrosSettings,
162 weak_factory_.GetWeakPtr())) != CrosSettingsProvider::TRUSTED) { 163 weak_factory_.GetWeakPtr())) != CrosSettingsProvider::TRUSTED) {
163 // If the cros settings are not trusted yet, request to be called back 164 // If the cros settings are not trusted yet, request to be called back
164 // later. 165 // later.
165 return; 166 return;
166 } 167 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 216
216 // Cache the enrollment domain. 217 // Cache the enrollment domain.
217 enrollment_domain_ = browser_policy_connector_->GetEnterpriseDomain(); 218 enrollment_domain_ = browser_policy_connector_->GetEnterpriseDomain();
218 219
219 // If no session or login is in progress, show the device disabled screen. 220 // If no session or login is in progress, show the device disabled screen.
220 delegate_->ShowDeviceDisabledScreen(); 221 delegate_->ShowDeviceDisabledScreen();
221 } 222 }
222 223
223 } // namespace system 224 } // namespace system
224 } // namespace chromeos 225 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698