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

Side by Side Diff: chrome/browser/policy/cloud/policy_header_service.cc

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 #include "chrome/browser/policy/cloud/policy_header_service.h"
6
7 #include "components/policy/core/browser/policy_header_io_helper.h"
8 #include "components/policy/core/common/cloud/cloud_policy_store.h"
9
10 namespace policy {
11
12 PolicyHeaderService::PolicyHeaderService(const std::string& server_url,
13 CloudPolicyStore* user_policy_store,
14 CloudPolicyStore* device_policy_store)
15 : server_url_(server_url),
16 user_policy_store_(user_policy_store),
17 device_policy_store_(device_policy_store) {
18 user_policy_store_->AddObserver(this);
19 if (device_policy_store_)
20 device_policy_store_->AddObserver(this);
21 }
22
23 PolicyHeaderService::~PolicyHeaderService() {
24 user_policy_store_->RemoveObserver(this);
25 if (device_policy_store_)
26 device_policy_store_->RemoveObserver(this);
27 }
28
29 scoped_ptr<PolicyHeaderIOHelper>
30 PolicyHeaderService::CreatePolicyHeaderIOHelper(
31 scoped_refptr<base::SequencedTaskRunner> task_runner) {
32 std::string initial_header_value = CreateHeaderValue();
33 scoped_ptr<PolicyHeaderIOHelper> helper = make_scoped_ptr(
34 new PolicyHeaderIOHelper(server_url_, initial_header_value, task_runner));
35 helpers_.push_back(helper.get());
36 return helper.Pass();
37 }
38
39 std::string PolicyHeaderService::CreateHeaderValue() {
40 // TODO(atwilson): Extract policy information and generate correct header.
41 return "";
42 }
43
44 void PolicyHeaderService::OnStoreLoaded(CloudPolicyStore* store) {
45 // If we have a PolicyHeaderIOHelper, notify it of the new header value.
46 if (!helpers_.empty()) {
47 std::string new_header = CreateHeaderValue();
48 for (std::vector<PolicyHeaderIOHelper*>::const_iterator it =
49 helpers_.begin(); it != helpers_.end(); ++it) {
50 (*it)->UpdateHeader(new_header);
51 }
52 }
53 }
54
55 void PolicyHeaderService::OnStoreError(CloudPolicyStore* store) {
56 // Do nothing on errors.
57 }
58
59 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/policy_header_service.h ('k') | chrome/browser/policy/cloud/policy_header_service_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698