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

Side by Side Diff: chrome/test/base/testing_browser_process.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/test/base/testing_browser_process.h" 5 #include "chrome/test/base/testing_browser_process.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/notifications/notification_ui_manager.h" 8 #include "chrome/browser/notifications/notification_ui_manager.h"
9 #include "chrome/browser/policy/browser_policy_connector.h" 9 #include "chrome/browser/policy/browser_policy_connector.h"
10 #include "chrome/browser/policy/policy_service.h" 10 #include "chrome/browser/policy/policy_service.h"
11 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/prerender/prerender_tracker.h" 12 #include "chrome/browser/prerender/prerender_tracker.h"
13 #include "chrome/browser/printing/background_printing_manager.h" 13 #include "chrome/browser/printing/background_printing_manager.h"
14 #include "chrome/browser/printing/print_preview_tab_controller.h" 14 #include "chrome/browser/printing/print_preview_tab_controller.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 16 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
17 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "net/url_request/url_request_context_getter.h" 18 #include "net/url_request/url_request_context_getter.h"
19 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/base/clipboard/clipboard.h" 20 #include "ui/base/clipboard/clipboard.h"
20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 #if !defined(ENABLE_CONFIGURATION_POLICY) 22 #if !defined(ENABLE_CONFIGURATION_POLICY)
23 #include "chrome/browser/policy/policy_service_stub.h" 23 #include "chrome/browser/policy/policy_service_stub.h"
24 #endif // defined(ENABLE_CONFIGURATION_POLICY) 24 #endif // defined(ENABLE_CONFIGURATION_POLICY)
25 25
26 TestingBrowserProcess::TestingBrowserProcess() 26 TestingBrowserProcess::TestingBrowserProcess()
27 : notification_service_(content::NotificationService::Create()), 27 : notification_service_(content::NotificationService::Create()),
28 module_ref_count_(0), 28 module_ref_count_(0),
29 app_locale_("en"), 29 app_locale_("en"),
30 local_state_(NULL), 30 local_state_(NULL),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 chrome_variations::VariationsService* 68 chrome_variations::VariationsService*
69 TestingBrowserProcess::variations_service() { 69 TestingBrowserProcess::variations_service() {
70 return NULL; 70 return NULL;
71 } 71 }
72 72
73 policy::BrowserPolicyConnector* 73 policy::BrowserPolicyConnector*
74 TestingBrowserProcess::browser_policy_connector() { 74 TestingBrowserProcess::browser_policy_connector() {
75 #if defined(ENABLE_CONFIGURATION_POLICY) 75 #if defined(ENABLE_CONFIGURATION_POLICY)
76 if (!browser_policy_connector_.get()) 76 if (!browser_policy_connector_.get()) {
77 browser_policy_connector_.reset(new policy::BrowserPolicyConnector()); 77 browser_policy_connector_.reset(new policy::BrowserPolicyConnector());
78 browser_policy_connector_->Init();
79 }
78 #endif 80 #endif
79 return browser_policy_connector_.get(); 81 return browser_policy_connector_.get();
80 } 82 }
81 83
82 policy::PolicyService* TestingBrowserProcess::policy_service() { 84 policy::PolicyService* TestingBrowserProcess::policy_service() {
83 if (!policy_service_.get()) { 85 if (!policy_service_.get()) {
84 #if defined(ENABLE_CONFIGURATION_POLICY) 86 #if defined(ENABLE_CONFIGURATION_POLICY)
85 policy_service_.reset( 87 policy_service_ = browser_policy_connector()->CreatePolicyService(NULL);
86 browser_policy_connector()->CreatePolicyService(NULL));
87 #else 88 #else
88 policy_service_.reset(new policy::PolicyServiceStub()); 89 policy_service_.reset(new policy::PolicyServiceStub());
89 #endif 90 #endif
90 } 91 }
91 return policy_service_.get(); 92 return policy_service_.get();
92 } 93 }
93 94
94 IconManager* TestingBrowserProcess::icon_manager() { 95 IconManager* TestingBrowserProcess::icon_manager() {
95 return NULL; 96 return NULL;
96 } 97 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 243
243 ComponentUpdateService* TestingBrowserProcess::component_updater() { 244 ComponentUpdateService* TestingBrowserProcess::component_updater() {
244 return NULL; 245 return NULL;
245 } 246 }
246 247
247 CRLSetFetcher* TestingBrowserProcess::crl_set_fetcher() { 248 CRLSetFetcher* TestingBrowserProcess::crl_set_fetcher() {
248 return NULL; 249 return NULL;
249 } 250 }
250 251
251 void TestingBrowserProcess::SetLocalState(PrefService* local_state) { 252 void TestingBrowserProcess::SetLocalState(PrefService* local_state) {
252 if (!local_state && notification_ui_manager_.get()) 253 if (!local_state) {
253 notification_ui_manager_.reset(); // Used local_state_. 254 // The local_state_ PrefService is owned outside of TestingBrowserProcess,
255 // but some of the members of TestingBrowserProcess hold references to it
256 // (for example, via PrefNotifier members). But given our test
257 // infrastructure which tears down individual tests before freeing the
258 // TestingBrowserProcess, there's not a good way to make local_state outlive
259 // these dependencies. As a workaround, whenever local_state_ is cleared
260 // (assumedly as part of exiting the test and freeing TestingBrowserProcess)
261 // any components owned by TestingBrowserProcess that depend on local_state
262 // are also freed.
263 notification_ui_manager_.reset();
264 browser_policy_connector_.reset();
265 }
254 local_state_ = local_state; 266 local_state_ = local_state;
255 } 267 }
256 268
257 void TestingBrowserProcess::SetIOThread(IOThread* io_thread) { 269 void TestingBrowserProcess::SetIOThread(IOThread* io_thread) {
258 io_thread_ = io_thread; 270 io_thread_ = io_thread;
259 } 271 }
260 272
261 void TestingBrowserProcess::SetBrowserPolicyConnector( 273 void TestingBrowserProcess::SetBrowserPolicyConnector(
262 policy::BrowserPolicyConnector* connector) { 274 policy::BrowserPolicyConnector* connector) {
263 browser_policy_connector_.reset(connector); 275 browser_policy_connector_.reset(connector);
264 } 276 }
265 277
266 void TestingBrowserProcess::SetSafeBrowsingService( 278 void TestingBrowserProcess::SetSafeBrowsingService(
267 SafeBrowsingService* sb_service) { 279 SafeBrowsingService* sb_service) {
268 sb_service_ = sb_service; 280 sb_service_ = sb_service;
269 } 281 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698