Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/browser_process_platform_part.h" | 12 #include "chrome/browser/browser_process_platform_part.h" |
| 13 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 13 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 14 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 14 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 15 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" | 15 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" |
| 16 #include "chrome/browser/chromeos/settings/install_attributes.h" | 16 #include "chrome/browser/chromeos/settings/install_attributes.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "chromeos/chromeos_switches.h" | 18 #include "chromeos/chromeos_switches.h" |
| 19 #include "chromeos/settings/cros_settings_names.h" | 19 #include "chromeos/settings/cros_settings_names.h" |
| 20 #include "chromeos/settings/cros_settings_provider.h" | 20 #include "chromeos/settings/cros_settings_provider.h" |
| 21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 22 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
| 23 #include "components/user_manager/user_manager.h" | 23 #include "components/user_manager/user_manager.h" |
| 24 #include "content/public/browser/browser_thread.h" | |
| 25 | |
| 26 using content::BrowserThread; | |
| 24 | 27 |
| 25 namespace chromeos { | 28 namespace chromeos { |
| 26 namespace system { | 29 namespace system { |
| 27 | 30 |
| 28 DeviceDisablingManager::Observer::~Observer() { | 31 DeviceDisablingManager::Observer::~Observer() { |
| 29 } | 32 } |
| 30 | 33 |
| 31 DeviceDisablingManager::Delegate::~Delegate() { | 34 DeviceDisablingManager::Delegate::~Delegate() { |
| 32 } | 35 } |
| 33 | 36 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 70 |
| 68 device_disabled_subscription_ = cros_settings_->AddSettingsObserver( | 71 device_disabled_subscription_ = cros_settings_->AddSettingsObserver( |
| 69 kDeviceDisabled, | 72 kDeviceDisabled, |
| 70 base::Bind(&DeviceDisablingManager::UpdateFromCrosSettings, | 73 base::Bind(&DeviceDisablingManager::UpdateFromCrosSettings, |
| 71 weak_factory_.GetWeakPtr())); | 74 weak_factory_.GetWeakPtr())); |
| 72 disabled_message_subscription_ = cros_settings_->AddSettingsObserver( | 75 disabled_message_subscription_ = cros_settings_->AddSettingsObserver( |
| 73 kDeviceDisabledMessage, | 76 kDeviceDisabledMessage, |
| 74 base::Bind(&DeviceDisablingManager::UpdateFromCrosSettings, | 77 base::Bind(&DeviceDisablingManager::UpdateFromCrosSettings, |
| 75 weak_factory_.GetWeakPtr())); | 78 weak_factory_.GetWeakPtr())); |
| 76 | 79 |
| 77 UpdateFromCrosSettings(); | 80 auto callback = |
|
emaxx
2017/04/12 17:05:49
nit: Storing the callback in a variable seems to b
Ivan Šandrk
2017/04/13 13:38:00
Done. Should I maybe cleanup the code a bit? Use a
| |
| 81 base::BindOnce(&DeviceDisablingManager::UpdateFromCrosSettings, | |
| 82 weak_factory_.GetWeakPtr()); | |
| 83 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | |
|
emaxx
2017/04/12 17:05:49
I think the following way of posting tasks is pref
emaxx
2017/04/12 17:05:49
nit: Please add a comment why the deferring is per
Ivan Šandrk
2017/04/13 13:37:59
Done.
Ivan Šandrk
2017/04/13 13:38:00
Done.
| |
| 78 } | 84 } |
| 79 | 85 |
| 80 void DeviceDisablingManager::CacheDisabledMessageAndNotify( | 86 void DeviceDisablingManager::CacheDisabledMessageAndNotify( |
| 81 const std::string& disabled_message) { | 87 const std::string& disabled_message) { |
| 82 if (disabled_message == disabled_message_) | 88 if (disabled_message == disabled_message_) |
| 83 return; | 89 return; |
| 84 | 90 |
| 85 disabled_message_ = disabled_message; | 91 disabled_message_ = disabled_message; |
| 86 for (auto& observer : observers_) | 92 for (auto& observer : observers_) |
| 87 observer.OnDisabledMessageChanged(disabled_message_); | 93 observer.OnDisabledMessageChanged(disabled_message_); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 | 225 |
| 220 // Cache the enrollment domain. | 226 // Cache the enrollment domain. |
| 221 enrollment_domain_ = browser_policy_connector_->GetEnterpriseDomain(); | 227 enrollment_domain_ = browser_policy_connector_->GetEnterpriseDomain(); |
| 222 | 228 |
| 223 // If no session or login is in progress, show the device disabled screen. | 229 // If no session or login is in progress, show the device disabled screen. |
| 224 delegate_->ShowDeviceDisabledScreen(); | 230 delegate_->ShowDeviceDisabledScreen(); |
| 225 } | 231 } |
| 226 | 232 |
| 227 } // namespace system | 233 } // namespace system |
| 228 } // namespace chromeos | 234 } // namespace chromeos |
| OLD | NEW |