Chromium Code Reviews| Index: components/ownership/owner_settings_service.h |
| diff --git a/components/ownership/owner_settings_service.h b/components/ownership/owner_settings_service.h |
| index 19619757164d0afabd21f0e66f992d01f8e0720c..a642bf2870524200562d21c4d80ef95dbdb0b859 100644 |
| --- a/components/ownership/owner_settings_service.h |
| +++ b/components/ownership/owner_settings_service.h |
| @@ -13,6 +13,7 @@ |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/weak_ptr.h" |
| +#include "base/observer_list.h" |
| #include "base/threading/thread_checker.h" |
| #include "components/keyed_service/core/keyed_service.h" |
| #include "components/ownership/ownership_export.h" |
| @@ -20,6 +21,7 @@ |
| namespace base { |
| class TaskRunner; |
| +class Value; |
| } |
| namespace ownership { |
| @@ -31,19 +33,38 @@ class PublicKey; |
| // which deal with ownership, keypairs and owner-related settings. |
| class OWNERSHIP_EXPORT OwnerSettingsService : public KeyedService { |
| public: |
| - typedef base::Callback<void(std::string policy_blob)> |
| + class Observer { |
| + public: |
| + virtual ~Observer() {} |
| + |
| + // Called when signed policy was stored, or when an error happed during |
| + // policy storage.. |
| + virtual void OnSignedPolicyStored(bool success) {} |
| + |
| + // Called when tentative changes were made to policy, but the policy still |
| + // not signed and stored. |
|
Mattias Nissler (ping if slow)
2014/10/24 08:29:56
Can we rather invert the dependency here instead o
ygorshenin1
2014/10/24 10:33:01
How about to declare OwnerSettingsService::Delegat
Mattias Nissler (ping if slow)
2014/10/24 10:48:12
My goal would be to completely remove knowledge of
ygorshenin1
2014/10/24 12:10:00
Your proposal about making a copy of device settin
|
| + virtual void OnTentativeChangesInPolicy( |
| + const enterprise_management::PolicyData& policy_data) {} |
| + }; |
| + |
| + typedef base::Callback<void( |
| + scoped_ptr<enterprise_management::PolicyFetchResponse> policy_response)> |
| AssembleAndSignPolicyAsyncCallback; |
| typedef base::Callback<void(bool is_owner)> IsOwnerCallback; |
| explicit OwnerSettingsService( |
| const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util); |
| - ~OwnerSettingsService() override; |
| + virtual ~OwnerSettingsService(); |
| base::WeakPtr<OwnerSettingsService> as_weak_ptr() { |
| return weak_factory_.GetWeakPtr(); |
| } |
| + void AddObserver(Observer* observer); |
| + |
| + void RemoveObserver(Observer* observer); |
| + |
| // Returns whether current user is owner or not. When this method |
| // is called too early, incorrect result can be returned because |
| // private key loading may be in progress. |
| @@ -60,12 +81,16 @@ class OWNERSHIP_EXPORT OwnerSettingsService : public KeyedService { |
| scoped_ptr<enterprise_management::PolicyData> policy, |
| const AssembleAndSignPolicyAsyncCallback& callback); |
| - // Signs |settings| with the private half of the owner key and sends |
| - // the resulting policy blob for storage. The |
| - // result of the operation is reported through |callback|. |
| - virtual void SignAndStorePolicyAsync( |
| - scoped_ptr<enterprise_management::PolicyData> policy, |
| - const base::Closure& callback) = 0; |
| + // Checks whether |setting| is handled by OwnerSettingsService. |
| + virtual bool HandlesSetting(const std::string& setting) = 0; |
| + |
| + // Sets |setting| value to |value|. |
| + virtual bool Set(const std::string& setting, const base::Value& value) = 0; |
| + |
| + bool SetBoolean(const std::string& setting, bool value); |
| + bool SetInteger(const std::string& setting, int value); |
| + bool SetDouble(const std::string& setting, double value); |
| + bool SetString(const std::string& setting, const std::string& value); |
| protected: |
| void ReloadKeypair(); |
| @@ -89,6 +114,8 @@ class OWNERSHIP_EXPORT OwnerSettingsService : public KeyedService { |
| std::vector<IsOwnerCallback> pending_is_owner_callbacks_; |
| + ObserverList<Observer> observers_; |
| + |
| base::ThreadChecker thread_checker_; |
| private: |