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

Side by Side Diff: chrome/browser/chromeos/device_settings_provider.h

Issue 8727037: Signed settings refactoring: Proper caching and more tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to ToT and removed some debug output left. Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_
6 #define CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "base/callback.h"
14 #include "base/hash_tables.h"
15 #include "chrome/browser/chromeos/cros_settings_provider.h"
16 #include "chrome/browser/chromeos/login/signed_settings_helper.h"
17 #include "chrome/browser/chromeos/signed_settings_migration_helper.h"
18 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
19 #include "content/public/browser/notification_registrar.h"
20
21 namespace em = enterprise_management;
22
23 class PrefService;
24
25 namespace base {
26 class ListValue;
27 }
28
29 namespace chromeos {
30
31 class OwnershipService;
32
33 // CrosSettingsProvider implementation that works with SignedSettings.
34 // TODO(nkostylev): Rename this class to indicate that it is
35 // SignedSettings specific.
36 class DeviceSettingsProvider : public CrosSettingsProvider,
37 public content::NotificationObserver {
38 public:
39 DeviceSettingsProvider();
40 virtual ~DeviceSettingsProvider() {}
41
42 // CrosSettingsProvider implementation.
43 virtual base::Value* Get(const std::string& path) const OVERRIDE;
44 virtual bool GetTrusted(const std::string& path,
45 const base::Closure& callback) OVERRIDE;
46 virtual bool HandlesSetting(const std::string& path) const OVERRIDE;
47 virtual void Reload() OVERRIDE;
48
49 private:
50 // CrosSettingsProvider implementation:
51 virtual void DoSet(const std::string& path,
52 const base::Value& value) OVERRIDE;
53
54 // content::NotificationObserver implementation:
55 virtual void Observe(int type,
56 const content::NotificationSource& source,
57 const content::NotificationDetails& details) OVERRIDE;
58
59 const em::PolicyData get_policy() const;
60
61 void RetrieveCachedData();
62
63 void SetInPolicy(const std::string& prop, const base::Value& value);
64
65 // Finalizes stores to the policy file if the cache is dirt
66 void FinishSetInPolicy(const std::string& prop,
67 const base::Value* value,
68 SignedSettings::ReturnCode code,
69 const em::PolicyFetchResponse& policy);
70
71 // Parses the policy cache and returns specific entry as a base::Value.
72 base::Value* LookUpInPolicy(const std::string& prop) const;
73
74 // Applies the metrics policy and if not set migrates the legacy file.
75 void ApplyMetricsSetting(bool use_file, bool new_value) const;
76
77 // Applies the data roaming policy.
78 void ApplyRoamingSetting(bool new_value) const;
79
80 // Applies any changes of the policies that are not handled by the respective
81 // subsystms.
82 void ApplySideEffects() const;
83
84 // Called right before boolean property is changed.
85 void OnBooleanPropertyChange(const std::string& path, bool new_value);
86
87 // Checks if the current cache value can be trusted for being representative
88 // for the disk cache.
89 bool RequestTrustedEntity();
90
91 // Serializes the temp store to the policy if ownership is taken.
92 void FinalizeTempStorage(SignedSettings::ReturnCode code,
93 const em::PolicyFetchResponse& policy);
94
95 // Called right after signed value was checked.
96 void OnPropertyRetrieve(const std::string& path,
97 const base::Value* value,
98 bool use_default_value);
99
100 // Callback of StorePolicyOp for ordinary policy stores.
101 void OnStorePolicyCompleted(SignedSettings::ReturnCode code);
102
103 // Callback of RetrievePolicyOp for ordinary policy [re]loads.
104 void OnRetrievePolicyCompleted(SignedSettings::ReturnCode code,
105 const em::PolicyFetchResponse& policy);
106
107 // Pending callbacks that need to be invoked after settings verification.
108 std::vector<base::Closure> callbacks_;
109
110 OwnershipService* ownership_service_;
111 mutable scoped_ptr<SignedSettingsMigrationHelper> migration_helper_;
112
113 content::NotificationRegistrar registrar_;
114
115 // In order to guard against occasional failure to fetch a property
116 // we allow for some number of retries.
117 int retries_left_;
118
119 em::PolicyData policy_;
120 bool trusted_;
121
122 friend class SignedSettingsHelper;
123
124 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider);
125 };
126
127 } // namespace chromeos
128
129 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698