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

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

Issue 10827216: Don't run BrowserPolicyConnector::Init from TestingBrowserProcess by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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/browser_policy_connector.h" 5 #include "chrome/browser/policy/browser_policy_connector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 user_cloud_policy_subsystem_.reset(); 121 user_cloud_policy_subsystem_.reset();
122 user_policy_token_cache_.reset(); 122 user_policy_token_cache_.reset();
123 user_data_store_.reset(); 123 user_data_store_.reset();
124 124
125 device_management_service_.reset(); 125 device_management_service_.reset();
126 } 126 }
127 127
128 void BrowserPolicyConnector::Init() { 128 void BrowserPolicyConnector::Init() {
129 DCHECK(!device_management_service_.get()) << 129 DCHECK(!device_management_service_.get()) <<
130 "BrowserPolicyConnector::Init() called twice."; 130 "BrowserPolicyConnector::Init() called twice.";
131 // Don't create platform providers if running in a unit test, since 131 platform_provider_.reset(CreatePlatformProvider());
132 // AsyncPlatformLoader requires deletion on the FILE thread.
133 if (MessageLoop::current())
134 platform_provider_.reset(CreatePlatformProvider());
135 132
136 device_management_service_.reset( 133 device_management_service_.reset(
137 new DeviceManagementService(GetDeviceManagementUrl())); 134 new DeviceManagementService(GetDeviceManagementUrl()));
138 135
139 #if defined(OS_CHROMEOS) 136 #if defined(OS_CHROMEOS)
140 CommandLine* command_line = CommandLine::ForCurrentProcess(); 137 CommandLine* command_line = CommandLine::ForCurrentProcess();
141 if (!command_line->HasSwitch(switches::kEnableCloudPolicyService)) { 138 if (!command_line->HasSwitch(switches::kEnableCloudPolicyService)) {
142 managed_cloud_provider_.reset(new CloudPolicyProvider( 139 managed_cloud_provider_.reset(new CloudPolicyProvider(
143 this, 140 this,
144 POLICY_LEVEL_MANDATORY)); 141 POLICY_LEVEL_MANDATORY));
145 recommended_cloud_provider_.reset(new CloudPolicyProvider( 142 recommended_cloud_provider_.reset(new CloudPolicyProvider(
146 this, 143 this,
147 POLICY_LEVEL_RECOMMENDED)); 144 POLICY_LEVEL_RECOMMENDED));
148 } 145 }
149 146
150 InitializeDevicePolicy(); 147 InitializeDevicePolicy();
151 148
152 // Don't bother updating the cache if this is a unit test.
153 if (!MessageLoop::current())
154 return;
155
156 // Create the AppPackUpdater to start updating the cache. It requires the 149 // Create the AppPackUpdater to start updating the cache. It requires the
157 // system request context, which isn't available yet; therefore it is 150 // system request context, which isn't available yet; therefore it is
158 // created only once the loops are running. 151 // created only once the loops are running.
159 MessageLoop::current()->PostTask( 152 MessageLoop::current()->PostTask(
160 FROM_HERE, 153 FROM_HERE,
161 base::Bind(base::IgnoreResult(&BrowserPolicyConnector::GetAppPackUpdater), 154 base::Bind(base::IgnoreResult(&BrowserPolicyConnector::GetAppPackUpdater),
162 weak_ptr_factory_.GetWeakPtr())); 155 weak_ptr_factory_.GetWeakPtr()));
163 #endif 156 #endif
164 } 157 }
165 158
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 install_attributes_.get()); 532 install_attributes_.get());
540 533
541 managed_cloud_provider_->SetDevicePolicyCache(device_policy_cache); 534 managed_cloud_provider_->SetDevicePolicyCache(device_policy_cache);
542 recommended_cloud_provider_->SetDevicePolicyCache(device_policy_cache); 535 recommended_cloud_provider_->SetDevicePolicyCache(device_policy_cache);
543 536
544 device_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( 537 device_cloud_policy_subsystem_.reset(new CloudPolicySubsystem(
545 device_data_store_.get(), 538 device_data_store_.get(),
546 device_policy_cache, 539 device_policy_cache,
547 GetDeviceManagementUrl())); 540 GetDeviceManagementUrl()));
548 541
549 // Skip the final initialization if this is a unit test.
550 if (!MessageLoop::current())
551 return;
552
553 // Initialize the subsystem once the message loops are spinning. 542 // Initialize the subsystem once the message loops are spinning.
554 MessageLoop::current()->PostTask( 543 MessageLoop::current()->PostTask(
555 FROM_HERE, 544 FROM_HERE,
556 base::Bind(&BrowserPolicyConnector::CompleteInitialization, 545 base::Bind(&BrowserPolicyConnector::CompleteInitialization,
557 weak_ptr_factory_.GetWeakPtr())); 546 weak_ptr_factory_.GetWeakPtr()));
558 } 547 }
559 } 548 }
560 #endif 549 #endif
561 } 550 }
562 551
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 return new AsyncPolicyProvider(loader.Pass()); 605 return new AsyncPolicyProvider(loader.Pass());
617 } else { 606 } else {
618 return NULL; 607 return NULL;
619 } 608 }
620 #else 609 #else
621 return NULL; 610 return NULL;
622 #endif 611 #endif
623 } 612 }
624 613
625 } // namespace policy 614 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_utils_browsertest.cc ('k') | chrome/browser/policy/config_dir_policy_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698