| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 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_POLICY_CLOUD_POLICY_HEADER_SERVICE_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_HEADER_SERVICE_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 14 |
| 15 namespace base { |
| 16 class SequencedTaskRunner; |
| 17 } |
| 18 |
| 19 namespace policy { |
| 20 |
| 21 class PolicyHeaderIOHelper; |
| 22 |
| 23 // Per-profile service used to generate PolicyHeaderIOHelper objects, and |
| 24 // keep them up-to-date as policy changes. |
| 25 // TODO(atwilson): Move to components/policy once CloudPolicyStore is moved. |
| 26 class PolicyHeaderService : public CloudPolicyStore::Observer { |
| 27 public: |
| 28 // |device_policy_store| can be null on platforms that do not support |
| 29 // device policy. Both |user_policy_store| and |device_policy_store| must |
| 30 // outlive this object. |
| 31 PolicyHeaderService(const std::string& server_url, |
| 32 CloudPolicyStore* user_policy_store, |
| 33 CloudPolicyStore* device_policy_store); |
| 34 virtual ~PolicyHeaderService(); |
| 35 |
| 36 // Creates a PolicyHeaderIOHelper object to be run on the IO thread and |
| 37 // add policy headers to outgoing requests. The caller takes ownership of |
| 38 // this object and must ensure it outlives ProfileHeaderService (in practice, |
| 39 // this is called by ProfileIOData, which is shutdown *after* all |
| 40 // ProfileKeyedServices are shutdown). |
| 41 scoped_ptr<PolicyHeaderIOHelper> CreatePolicyHeaderIOHelper( |
| 42 scoped_refptr<base::SequencedTaskRunner> task_runner); |
| 43 |
| 44 // Overridden CloudPolicyStore::Observer methods: |
| 45 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; |
| 46 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; |
| 47 |
| 48 protected: |
| 49 // Generate a policy header based on the currently loaded policy. |
| 50 // Virtual to allow mocking in tests. |
| 51 virtual std::string CreateHeaderValue(); |
| 52 |
| 53 private: |
| 54 // Weak pointer to created PolicyHeaderIOHelper objects. |
| 55 std::vector<PolicyHeaderIOHelper*> helpers_; |
| 56 |
| 57 // URL of the policy server. |
| 58 std::string server_url_; |
| 59 |
| 60 // Weak pointers to User-/Device-level policy stores. |
| 61 CloudPolicyStore* user_policy_store_; |
| 62 CloudPolicyStore* device_policy_store_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(PolicyHeaderService); |
| 65 }; |
| 66 |
| 67 } // namespace policy |
| 68 |
| 69 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_HEADER_SERVICE_H_ |
| OLD | NEW |