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

Side by Side Diff: chrome/browser/policy/cloud_policy_provider.cc

Issue 10693022: Add support for loading user cloud policy on desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaked some comments after self-review. Created 8 years, 4 months 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/policy/cloud_policy_provider.h" 5 #include "chrome/browser/policy/cloud_policy_provider.h"
6 6
7 #include "base/command_line.h"
7 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/policy/browser_policy_connector.h" 9 #include "chrome/browser/policy/browser_policy_connector.h"
9 #include "chrome/browser/policy/policy_bundle.h" 10 #include "chrome/browser/policy/policy_bundle.h"
10 #include "chrome/browser/policy/policy_map.h" 11 #include "chrome/browser/policy/policy_map.h"
12 #include "chrome/common/chrome_switches.h"
11 13
12 namespace policy { 14 namespace policy {
13 15
14 CloudPolicyProvider::CloudPolicyProvider( 16 CloudPolicyProvider::CloudPolicyProvider(
15 BrowserPolicyConnector* browser_policy_connector, 17 BrowserPolicyConnector* browser_policy_connector,
16 PolicyLevel level) 18 PolicyLevel level)
17 : browser_policy_connector_(browser_policy_connector), 19 : browser_policy_connector_(browser_policy_connector),
18 level_(level), 20 level_(level),
19 initialization_complete_(false) { 21 initialization_complete_(false) {
20 for (size_t i = 0; i < CACHE_SIZE; ++i) 22 for (size_t i = 0; i < CACHE_SIZE; ++i)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 78 }
77 } 79 }
78 NOTREACHED(); 80 NOTREACHED();
79 } 81 }
80 82
81 void CloudPolicyProvider::Merge() { 83 void CloudPolicyProvider::Merge() {
82 // Re-check whether all caches are ready. 84 // Re-check whether all caches are ready.
83 if (!initialization_complete_) { 85 if (!initialization_complete_) {
84 initialization_complete_ = true; 86 initialization_complete_ = true;
85 for (size_t i = 0; i < CACHE_SIZE; ++i) { 87 for (size_t i = 0; i < CACHE_SIZE; ++i) {
88 #if defined(OS_CHROMEOS)
89 // Ignore the device policy cache if device policy is not enabled.
90 if (i == CACHE_DEVICE &&
91 !CommandLine::ForCurrentProcess()->HasSwitch(
92 switches::kEnableDevicePolicy)) {
93 continue;
94 }
95 #endif
86 if (caches_[i] == NULL || !caches_[i]->IsReady()) { 96 if (caches_[i] == NULL || !caches_[i]->IsReady()) {
87 initialization_complete_ = false; 97 initialization_complete_ = false;
88 break; 98 break;
89 } 99 }
90 } 100 }
91 } 101 }
92 102
93 PolicyMap combined; 103 PolicyMap combined;
94 for (size_t i = 0; i < CACHE_SIZE; ++i) { 104 for (size_t i = 0; i < CACHE_SIZE; ++i) {
95 if (caches_[i] && caches_[i]->IsReady()) 105 if (caches_[i] && caches_[i]->IsReady())
96 combined.MergeFrom(*caches_[i]->policy()); 106 combined.MergeFrom(*caches_[i]->policy());
97 } 107 }
98 combined.FilterLevel(level_); 108 combined.FilterLevel(level_);
99 109
100 scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); 110 scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
101 bundle->Get(POLICY_DOMAIN_CHROME, std::string()).Swap(&combined); 111 bundle->Get(POLICY_DOMAIN_CHROME, std::string()).Swap(&combined);
102 UpdatePolicy(bundle.Pass()); 112 UpdatePolicy(bundle.Pass());
103 } 113 }
104 114
105 } // namespace policy 115 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698