OLD | NEW |
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 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/prefs/pref_value_map.h" | 17 #include "base/prefs/pref_value_map.h" |
18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
19 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 19 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
20 #include "chromeos/settings/cros_settings_provider.h" | 20 #include "chromeos/settings/cros_settings_provider.h" |
| 21 #include "components/ownership/owner_settings_service.h" |
21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 22 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
22 | 23 |
23 namespace base { | 24 namespace base { |
24 class Value; | 25 class Value; |
25 } | 26 } |
26 | 27 |
27 namespace enterprise_management { | 28 namespace enterprise_management { |
28 class ChromeDeviceSettingsProto; | 29 class ChromeDeviceSettingsProto; |
29 } // namespace enterprise_management | 30 } // namespace enterprise_management |
30 | 31 |
31 namespace chromeos { | 32 namespace chromeos { |
32 | 33 |
33 // CrosSettingsProvider implementation that works with device settings. | 34 // CrosSettingsProvider implementation that works with device settings. |
34 class DeviceSettingsProvider : public CrosSettingsProvider, | 35 // |
35 public DeviceSettingsService::Observer { | 36 // Note that the write path is in the process of being migrated to |
| 37 // OwnerSettingsServiceChromeOS (crbug.com/230018). |
| 38 class DeviceSettingsProvider |
| 39 : public CrosSettingsProvider, |
| 40 public DeviceSettingsService::Observer, |
| 41 public ownership::OwnerSettingsService::Observer { |
36 public: | 42 public: |
37 // The callback type that is called to get the device mode. | 43 // The callback type that is called to get the device mode. |
38 typedef base::Callback<policy::DeviceMode(void)> GetDeviceModeCallback; | 44 typedef base::Callback<policy::DeviceMode(void)> GetDeviceModeCallback; |
39 | 45 |
40 DeviceSettingsProvider(const NotifyObserversCallback& notify_cb, | 46 DeviceSettingsProvider(const NotifyObserversCallback& notify_cb, |
41 DeviceSettingsService* device_settings_service); | 47 DeviceSettingsService* device_settings_service); |
42 virtual ~DeviceSettingsProvider(); | 48 virtual ~DeviceSettingsProvider(); |
43 | 49 |
44 // Returns true if |path| is handled by this provider. | 50 // Returns true if |path| is handled by this provider. |
45 static bool IsDeviceSetting(const std::string& name); | 51 static bool IsDeviceSetting(const std::string& name); |
46 | 52 |
47 // CrosSettingsProvider implementation. | 53 // CrosSettingsProvider implementation. |
48 virtual const base::Value* Get(const std::string& path) const override; | 54 virtual const base::Value* Get(const std::string& path) const override; |
49 virtual TrustedStatus PrepareTrustedValues( | 55 virtual TrustedStatus PrepareTrustedValues( |
50 const base::Closure& callback) override; | 56 const base::Closure& callback) override; |
51 virtual bool HandlesSetting(const std::string& path) const override; | 57 virtual bool HandlesSetting(const std::string& path) const override; |
52 | 58 |
53 private: | 59 private: |
54 // CrosSettingsProvider implementation: | 60 // CrosSettingsProvider implementation: |
55 virtual void DoSet(const std::string& path, | 61 virtual void DoSet(const std::string& path, |
56 const base::Value& value) override; | 62 const base::Value& value) override; |
57 | 63 |
58 // DeviceSettingsService::Observer implementation: | 64 // DeviceSettingsService::Observer implementation: |
59 virtual void OwnershipStatusChanged() override; | 65 virtual void OwnershipStatusChanged() override; |
60 virtual void DeviceSettingsUpdated() override; | 66 virtual void DeviceSettingsUpdated() override; |
61 | 67 |
| 68 // ownership::OwnerSettingsService::Observer implementation: |
| 69 virtual void OnTentativeChangesInPolicy( |
| 70 const enterprise_management::PolicyData& policy_data) override; |
| 71 |
62 // Populates in-memory cache from the local_state cache that is used to store | 72 // Populates in-memory cache from the local_state cache that is used to store |
63 // device settings before the device is owned and to speed up policy | 73 // device settings before the device is owned and to speed up policy |
64 // availability before the policy blob is fetched on boot. | 74 // availability before the policy blob is fetched on boot. |
65 void RetrieveCachedData(); | 75 void RetrieveCachedData(); |
66 | 76 |
67 // Stores a value from the |pending_changes_| queue in the device settings. | 77 // Stores a value from the |pending_changes_| queue in the device settings. |
68 // If the device is not owned yet the data ends up only in the local_state | 78 // If the device is not owned yet the data ends up only in the local_state |
69 // cache and is serialized once ownership is acquired. | 79 // cache and is serialized once ownership is acquired. |
70 void SetInPolicy(); | 80 void SetInPolicy(); |
71 | 81 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 InitializationTestUnowned); | 159 InitializationTestUnowned); |
150 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, | 160 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, |
151 PolicyFailedPermanentlyNotification); | 161 PolicyFailedPermanentlyNotification); |
152 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, PolicyLoadNotification); | 162 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, PolicyLoadNotification); |
153 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider); | 163 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider); |
154 }; | 164 }; |
155 | 165 |
156 } // namespace chromeos | 166 } // namespace chromeos |
157 | 167 |
158 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ | 168 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ |
OLD | NEW |