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

Unified Diff: chrome/browser/policy/cloud/policy_header_service.h

Issue 99433004: Add a header when fetching pages under the DMServer URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed per willchan's feedback Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/cloud/DEPS ('k') | chrome/browser/policy/cloud/policy_header_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/cloud/policy_header_service.h
diff --git a/chrome/browser/policy/cloud/policy_header_service.h b/chrome/browser/policy/cloud/policy_header_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..b1e01ea6488d675e36fcd728f0dd1912886722d6
--- /dev/null
+++ b/chrome/browser/policy/cloud/policy_header_service.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_HEADER_SERVICE_H_
+#define CHROME_BROWSER_POLICY_CLOUD_POLICY_HEADER_SERVICE_H_
+
+#include <string>
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "components/policy/core/common/cloud/cloud_policy_store.h"
+
+namespace base {
+class SequencedTaskRunner;
+}
+
+namespace policy {
+
+class PolicyHeaderIOHelper;
+
+// Per-profile service used to generate PolicyHeaderIOHelper objects, and
+// keep them up-to-date as policy changes.
+// TODO(atwilson): Move to components/policy once CloudPolicyStore is moved.
+class PolicyHeaderService : public CloudPolicyStore::Observer {
+ public:
+ // |device_policy_store| can be null on platforms that do not support
+ // device policy. Both |user_policy_store| and |device_policy_store| must
+ // outlive this object.
+ PolicyHeaderService(const std::string& server_url,
+ CloudPolicyStore* user_policy_store,
+ CloudPolicyStore* device_policy_store);
+ virtual ~PolicyHeaderService();
+
+ // Creates a PolicyHeaderIOHelper object to be run on the IO thread and
+ // add policy headers to outgoing requests. The caller takes ownership of
+ // this object and must ensure it outlives ProfileHeaderService (in practice,
+ // this is called by ProfileIOData, which is shutdown *after* all
+ // ProfileKeyedServices are shutdown).
+ scoped_ptr<PolicyHeaderIOHelper> CreatePolicyHeaderIOHelper(
+ scoped_refptr<base::SequencedTaskRunner> task_runner);
+
+ // Overridden CloudPolicyStore::Observer methods:
+ virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
+ virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
+
+ protected:
+ // Generate a policy header based on the currently loaded policy.
+ // Virtual to allow mocking in tests.
+ virtual std::string CreateHeaderValue();
+
+ private:
+ // Weak pointer to created PolicyHeaderIOHelper objects.
+ std::vector<PolicyHeaderIOHelper*> helpers_;
+
+ // URL of the policy server.
+ std::string server_url_;
+
+ // Weak pointers to User-/Device-level policy stores.
+ CloudPolicyStore* user_policy_store_;
+ CloudPolicyStore* device_policy_store_;
+
+ DISALLOW_COPY_AND_ASSIGN(PolicyHeaderService);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_HEADER_SERVICE_H_
« no previous file with comments | « chrome/browser/policy/cloud/DEPS ('k') | chrome/browser/policy/cloud/policy_header_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698