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

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

Issue 6869042: Add immutable settings checks when handling policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, address comments Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser_policy_connector.h" 5 #include "chrome/browser/policy/browser_policy_connector.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/policy/cloud_policy_subsystem.h" 10 #include "chrome/browser/policy/cloud_policy_subsystem.h"
11 #include "chrome/browser/policy/configuration_policy_pref_store.h" 11 #include "chrome/browser/policy/configuration_policy_pref_store.h"
12 #include "chrome/browser/policy/configuration_policy_provider.h" 12 #include "chrome/browser/policy/configuration_policy_provider.h"
13 #include "chrome/browser/policy/dummy_configuration_policy_provider.h" 13 #include "chrome/browser/policy/dummy_configuration_policy_provider.h"
14 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 16
17 #if defined(OS_WIN) 17 #if defined(OS_WIN)
18 #include "chrome/browser/policy/configuration_policy_provider_win.h" 18 #include "chrome/browser/policy/configuration_policy_provider_win.h"
19 #elif defined(OS_MACOSX) 19 #elif defined(OS_MACOSX)
20 #include "chrome/browser/policy/configuration_policy_provider_mac.h" 20 #include "chrome/browser/policy/configuration_policy_provider_mac.h"
21 #elif defined(OS_POSIX) 21 #elif defined(OS_POSIX)
22 #include "chrome/browser/policy/config_dir_policy_provider.h" 22 #include "chrome/browser/policy/config_dir_policy_provider.h"
23 #endif 23 #endif
24 24
25 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
26 #include "chrome/browser/chromeos/cros/cros_library.h"
26 #include "chrome/browser/policy/device_policy_cache.h" 27 #include "chrome/browser/policy/device_policy_cache.h"
27 #include "chrome/browser/policy/device_policy_identity_strategy.h" 28 #include "chrome/browser/policy/device_policy_identity_strategy.h"
29 #include "chrome/browser/policy/enterprise_install_attributes.h"
28 #endif 30 #endif
29 31
30 namespace policy { 32 namespace policy {
31 33
32 BrowserPolicyConnector::BrowserPolicyConnector() 34 BrowserPolicyConnector::BrowserPolicyConnector()
33 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 35 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
34 managed_platform_provider_.reset(CreateManagedPlatformProvider()); 36 managed_platform_provider_.reset(CreateManagedPlatformProvider());
35 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); 37 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider());
36 38
37 #if defined(OS_CHROMEOS) 39 #if defined(OS_CHROMEOS)
38 CommandLine* command_line = CommandLine::ForCurrentProcess(); 40 CommandLine* command_line = CommandLine::ForCurrentProcess();
39 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) { 41 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) {
40 identity_strategy_.reset(new DevicePolicyIdentityStrategy()); 42 identity_strategy_.reset(new DevicePolicyIdentityStrategy());
43 install_attributes_.reset(new EnterpriseInstallAttributes(
44 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()));
41 cloud_policy_subsystem_.reset(new CloudPolicySubsystem( 45 cloud_policy_subsystem_.reset(new CloudPolicySubsystem(
42 identity_strategy_.get(), 46 identity_strategy_.get(),
43 new DevicePolicyCache(identity_strategy_.get()))); 47 new DevicePolicyCache(identity_strategy_.get(),
48 install_attributes_.get())));
44 49
45 // Initialize the subsystem once the message loops are spinning. 50 // Initialize the subsystem once the message loops are spinning.
46 MessageLoop::current()->PostTask( 51 MessageLoop::current()->PostTask(
47 FROM_HERE, 52 FROM_HERE,
48 method_factory_.NewRunnableMethod(&BrowserPolicyConnector::Initialize)); 53 method_factory_.NewRunnableMethod(&BrowserPolicyConnector::Initialize));
49 } 54 }
50 #endif 55 #endif
51 } 56 }
52 57
53 BrowserPolicyConnector::BrowserPolicyConnector( 58 BrowserPolicyConnector::BrowserPolicyConnector(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 147
143 bool BrowserPolicyConnector::IsEnterpriseManaged() { 148 bool BrowserPolicyConnector::IsEnterpriseManaged() {
144 #if defined(OS_CHROMEOS) 149 #if defined(OS_CHROMEOS)
145 return (identity_strategy_.get() && 150 return (identity_strategy_.get() &&
146 !identity_strategy_->GetDeviceToken().empty()); 151 !identity_strategy_->GetDeviceToken().empty());
147 #else 152 #else
148 return false; 153 return false;
149 #endif 154 #endif
150 } 155 }
151 156
152 std::string BrowserPolicyConnector::GetEnterpriseDomain() { 157 EnterpriseInstallAttributes::LockResult
153 std::string domain; 158 BrowserPolicyConnector::LockDevice(const std::string& user) {
154
155 #if defined(OS_CHROMEOS) 159 #if defined(OS_CHROMEOS)
156 // TODO(xiyuan): Find a better way to get enterprise domain. 160 if (install_attributes_.get())
157 std::string username; 161 return install_attributes_->LockDevice(user);
158 std::string auth_token;
159 if (identity_strategy_.get() &&
160 identity_strategy_->GetCredentials(&username, &auth_token)) {
161 size_t pos = username.find('@');
162 if (pos != std::string::npos)
163 domain = username.substr(pos + 1);
164 }
165 #endif 162 #endif
166 163
167 return domain; 164 return EnterpriseInstallAttributes::LOCK_BACKEND_ERROR;
165 }
166
167 std::string BrowserPolicyConnector::GetEnterpriseDomain() {
168 #if defined(OS_CHROMEOS)
169 if (install_attributes_.get())
170 return install_attributes_->GetDomain();
171 #endif
172
173 return std::string();
168 } 174 }
169 175
170 void BrowserPolicyConnector::StopAutoRetry() { 176 void BrowserPolicyConnector::StopAutoRetry() {
171 if (cloud_policy_subsystem_.get()) 177 if (cloud_policy_subsystem_.get())
172 cloud_policy_subsystem_->StopAutoRetry(); 178 cloud_policy_subsystem_->StopAutoRetry();
173 } 179 }
174 180
175 void BrowserPolicyConnector::Initialize() { 181 void BrowserPolicyConnector::Initialize() {
176 // TODO(jkummerow, mnissler): Move this out of the browser startup path. 182 // TODO(jkummerow, mnissler): Move this out of the browser startup path.
177 if (cloud_policy_subsystem_.get()) { 183 if (cloud_policy_subsystem_.get()) {
178 cloud_policy_subsystem_->Initialize( 184 cloud_policy_subsystem_->Initialize(
179 g_browser_process->local_state(), 185 g_browser_process->local_state(),
180 g_browser_process->system_request_context()); 186 g_browser_process->system_request_context());
181 } 187 }
182 } 188 }
183 189
184 } // namespace 190 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.h ('k') | chrome/browser/policy/device_policy_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698