Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / device_local_account_policy_store.h
blobe6e021b680be3dc9df83bc1542727ae61beba057
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_STORE_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_STORE_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/chromeos/settings/device_settings_service.h"
16 #include "components/policy/core/common/cloud/cloud_policy_validator.h"
17 #include "components/policy/core/common/cloud/user_cloud_policy_store_base.h"
19 namespace base {
20 class SequencedTaskRunner;
23 namespace chromeos {
24 class DeviceSettingsService;
25 class SessionManagerClient;
28 namespace enterprise_management {
29 class PolicyFetchResponse;
32 namespace policy {
34 class DeviceLocalAccountPolicyBroker;
36 // CloudPolicyStore implementation for device-local account policy. Stores/loads
37 // policy to/from session_manager.
38 class DeviceLocalAccountPolicyStore
39 : public UserCloudPolicyStoreBase {
40 public:
41 DeviceLocalAccountPolicyStore(
42 const std::string& account_id,
43 chromeos::SessionManagerClient* client,
44 chromeos::DeviceSettingsService* device_settings_service,
45 scoped_refptr<base::SequencedTaskRunner> background_task_runner);
46 ~DeviceLocalAccountPolicyStore() override;
48 const std::string& account_id() const { return account_id_; }
50 // CloudPolicyStore:
51 void Store(const enterprise_management::PolicyFetchResponse& policy) override;
52 void Load() override;
54 private:
55 // Called back by |session_manager_client_| after policy retrieval. Checks for
56 // success and triggers policy validation.
57 void ValidateLoadedPolicyBlob(const std::string& policy_blob);
59 // Updates state after validation and notifies observers.
60 void UpdatePolicy(UserCloudPolicyValidator* validator);
62 // Sends the policy blob to session_manager for storing after validation.
63 void StoreValidatedPolicy(UserCloudPolicyValidator* validator);
65 // Called back when a store operation completes, updates state and reloads the
66 // policy if applicable.
67 void HandleStoreResult(bool result);
69 // Gets the owner key and triggers policy validation.
70 void CheckKeyAndValidate(
71 bool valid_timestamp_required,
72 scoped_ptr<enterprise_management::PolicyFetchResponse> policy,
73 const UserCloudPolicyValidator::CompletionCallback& callback);
75 // Triggers policy validation.
76 void Validate(
77 bool valid_timestamp_required,
78 scoped_ptr<enterprise_management::PolicyFetchResponse> policy,
79 const UserCloudPolicyValidator::CompletionCallback& callback,
80 chromeos::DeviceSettingsService::OwnershipStatus ownership_status);
82 const std::string account_id_;
83 chromeos::SessionManagerClient* session_manager_client_;
84 chromeos::DeviceSettingsService* device_settings_service_;
86 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
88 base::WeakPtrFactory<DeviceLocalAccountPolicyStore> weak_factory_;
90 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStore);
93 } // namespace policy
95 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_STORE_H_