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

Side by Side Diff: chrome/test/base/testing_browser_process.cc

Issue 1786263002: Remove uses of ENABLE_CONFIGURATION_POLICY from src/chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sort Created 4 years, 9 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
« no previous file with comments | « chrome/test/base/testing_browser_process.h ('k') | chrome/test/base/testing_profile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/time/default_clock.h" 8 #include "base/time/default_clock.h"
9 #include "base/time/default_tick_clock.h" 9 #include "base/time/default_tick_clock.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/browser_process_impl.h" 12 #include "chrome/browser/browser_process_impl.h"
13 #include "chrome/browser/notifications/notification_ui_manager.h" 13 #include "chrome/browser/notifications/notification_ui_manager.h"
14 #include "chrome/browser/printing/print_job_manager.h" 14 #include "chrome/browser/printing/print_job_manager.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 "chrome/common/features.h" 17 #include "chrome/common/features.h"
18 #include "chrome/test/base/testing_browser_process_platform_part.h" 18 #include "chrome/test/base/testing_browser_process_platform_part.h"
19 #include "components/network_time/network_time_tracker.h" 19 #include "components/network_time/network_time_tracker.h"
20 #include "components/policy/core/browser/browser_policy_connector.h"
20 #include "components/prefs/pref_service.h" 21 #include "components/prefs/pref_service.h"
21 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
22 #include "net/url_request/url_request_context_getter.h" 23 #include "net/url_request/url_request_context_getter.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 #include "ui/message_center/message_center.h" 25 #include "ui/message_center/message_center.h"
25 26
26
27 #if BUILDFLAG(ENABLE_BACKGROUND) 27 #if BUILDFLAG(ENABLE_BACKGROUND)
28 #include "chrome/browser/background/background_mode_manager.h" 28 #include "chrome/browser/background/background_mode_manager.h"
29 #endif 29 #endif
30 30
31 #if defined(ENABLE_CONFIGURATION_POLICY)
32 #include "components/policy/core/browser/browser_policy_connector.h"
33 #else
34 #include "components/policy/core/common/policy_service_stub.h"
35 #endif // defined(ENABLE_CONFIGURATION_POLICY)
36
37 #if defined(ENABLE_EXTENSIONS) 31 #if defined(ENABLE_EXTENSIONS)
38 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" 32 #include "chrome/browser/extensions/chrome_extensions_browser_client.h"
39 #include "chrome/browser/media_galleries/media_file_system_registry.h" 33 #include "chrome/browser/media_galleries/media_file_system_registry.h"
40 #include "chrome/browser/ui/apps/chrome_app_window_client.h" 34 #include "chrome/browser/ui/apps/chrome_app_window_client.h"
41 #include "components/storage_monitor/storage_monitor.h" 35 #include "components/storage_monitor/storage_monitor.h"
42 #include "components/storage_monitor/test_storage_monitor.h" 36 #include "components/storage_monitor/test_storage_monitor.h"
43 #endif 37 #endif
44 38
45 #if defined(ENABLE_PRINT_PREVIEW) 39 #if defined(ENABLE_PRINT_PREVIEW)
46 #include "chrome/browser/printing/background_printing_manager.h" 40 #include "chrome/browser/printing/background_printing_manager.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #if defined(ENABLE_EXTENSIONS) 72 #if defined(ENABLE_EXTENSIONS)
79 extensions_browser_client_.reset( 73 extensions_browser_client_.reset(
80 new extensions::ChromeExtensionsBrowserClient); 74 new extensions::ChromeExtensionsBrowserClient);
81 extensions::AppWindowClient::Set(ChromeAppWindowClient::GetInstance()); 75 extensions::AppWindowClient::Set(ChromeAppWindowClient::GetInstance());
82 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); 76 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
83 #endif 77 #endif
84 } 78 }
85 79
86 TestingBrowserProcess::~TestingBrowserProcess() { 80 TestingBrowserProcess::~TestingBrowserProcess() {
87 EXPECT_FALSE(local_state_); 81 EXPECT_FALSE(local_state_);
88 #if defined(ENABLE_CONFIGURATION_POLICY)
89 ShutdownBrowserPolicyConnector(); 82 ShutdownBrowserPolicyConnector();
90 #endif
91 #if defined(ENABLE_EXTENSIONS) 83 #if defined(ENABLE_EXTENSIONS)
92 extensions::ExtensionsBrowserClient::Set(nullptr); 84 extensions::ExtensionsBrowserClient::Set(nullptr);
93 #endif 85 #endif
94 86
95 // Destructors for some objects owned by TestingBrowserProcess will use 87 // Destructors for some objects owned by TestingBrowserProcess will use
96 // g_browser_process if it is not null, so it must be null before proceeding. 88 // g_browser_process if it is not null, so it must be null before proceeding.
97 DCHECK_EQ(static_cast<BrowserProcess*>(nullptr), g_browser_process); 89 DCHECK_EQ(static_cast<BrowserProcess*>(nullptr), g_browser_process);
98 } 90 }
99 91
100 void TestingBrowserProcess::ResourceDispatcherHostCreated() { 92 void TestingBrowserProcess::ResourceDispatcherHostCreated() {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return nullptr; 139 return nullptr;
148 } 140 }
149 141
150 web_resource::PromoResourceService* 142 web_resource::PromoResourceService*
151 TestingBrowserProcess::promo_resource_service() { 143 TestingBrowserProcess::promo_resource_service() {
152 return nullptr; 144 return nullptr;
153 } 145 }
154 146
155 policy::BrowserPolicyConnector* 147 policy::BrowserPolicyConnector*
156 TestingBrowserProcess::browser_policy_connector() { 148 TestingBrowserProcess::browser_policy_connector() {
157 #if defined(ENABLE_CONFIGURATION_POLICY)
158 if (!browser_policy_connector_) { 149 if (!browser_policy_connector_) {
159 EXPECT_FALSE(created_browser_policy_connector_); 150 EXPECT_FALSE(created_browser_policy_connector_);
160 created_browser_policy_connector_ = true; 151 created_browser_policy_connector_ = true;
161 browser_policy_connector_ = platform_part_->CreateBrowserPolicyConnector(); 152 browser_policy_connector_ = platform_part_->CreateBrowserPolicyConnector();
162 } 153 }
163 return browser_policy_connector_.get(); 154 return browser_policy_connector_.get();
164 #else
165 return nullptr;
166 #endif
167 } 155 }
168 156
169 policy::PolicyService* TestingBrowserProcess::policy_service() { 157 policy::PolicyService* TestingBrowserProcess::policy_service() {
170 #if defined(ENABLE_CONFIGURATION_POLICY)
171 return browser_policy_connector()->GetPolicyService(); 158 return browser_policy_connector()->GetPolicyService();
172 #else
173 if (!policy_service_)
174 policy_service_.reset(new policy::PolicyServiceStub());
175 return policy_service_.get();
176 #endif
177 } 159 }
178 160
179 IconManager* TestingBrowserProcess::icon_manager() { 161 IconManager* TestingBrowserProcess::icon_manager() {
180 return nullptr; 162 return nullptr;
181 } 163 }
182 164
183 GLStringManager* TestingBrowserProcess::gl_string_manager() { 165 GLStringManager* TestingBrowserProcess::gl_string_manager() {
184 return nullptr; 166 return nullptr;
185 } 167 }
186 168
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // but some of the members of TestingBrowserProcess hold references to it 386 // but some of the members of TestingBrowserProcess hold references to it
405 // (for example, via PrefNotifier members). But given our test 387 // (for example, via PrefNotifier members). But given our test
406 // infrastructure which tears down individual tests before freeing the 388 // infrastructure which tears down individual tests before freeing the
407 // TestingBrowserProcess, there's not a good way to make local_state outlive 389 // TestingBrowserProcess, there's not a good way to make local_state outlive
408 // these dependencies. As a workaround, whenever local_state_ is cleared 390 // these dependencies. As a workaround, whenever local_state_ is cleared
409 // (assumedly as part of exiting the test and freeing TestingBrowserProcess) 391 // (assumedly as part of exiting the test and freeing TestingBrowserProcess)
410 // any components owned by TestingBrowserProcess that depend on local_state 392 // any components owned by TestingBrowserProcess that depend on local_state
411 // are also freed. 393 // are also freed.
412 network_time_tracker_.reset(); 394 network_time_tracker_.reset();
413 notification_ui_manager_.reset(); 395 notification_ui_manager_.reset();
414 #if defined(ENABLE_CONFIGURATION_POLICY)
415 ShutdownBrowserPolicyConnector(); 396 ShutdownBrowserPolicyConnector();
416 created_browser_policy_connector_ = false; 397 created_browser_policy_connector_ = false;
417 #endif
418 } 398 }
419 local_state_ = local_state; 399 local_state_ = local_state;
420 } 400 }
421 401
422 void TestingBrowserProcess::SetIOThread(IOThread* io_thread) { 402 void TestingBrowserProcess::SetIOThread(IOThread* io_thread) {
423 io_thread_ = io_thread; 403 io_thread_ = io_thread;
424 } 404 }
425 405
426 void TestingBrowserProcess::ShutdownBrowserPolicyConnector() { 406 void TestingBrowserProcess::ShutdownBrowserPolicyConnector() {
427 #if defined(ENABLE_CONFIGURATION_POLICY)
428 if (browser_policy_connector_) 407 if (browser_policy_connector_)
429 browser_policy_connector_->Shutdown(); 408 browser_policy_connector_->Shutdown();
430 browser_policy_connector_.reset(); 409 browser_policy_connector_.reset();
431 #else
432 CHECK(false);
433 #endif
434 } 410 }
435 411
436 void TestingBrowserProcess::SetSafeBrowsingService( 412 void TestingBrowserProcess::SetSafeBrowsingService(
437 safe_browsing::SafeBrowsingService* sb_service) { 413 safe_browsing::SafeBrowsingService* sb_service) {
438 sb_service_ = sb_service; 414 sb_service_ = sb_service;
439 } 415 }
440 416
441 void TestingBrowserProcess::SetRapporService( 417 void TestingBrowserProcess::SetRapporService(
442 rappor::RapporService* rappor_service) { 418 rappor::RapporService* rappor_service) {
443 rappor_service_ = rappor_service; 419 rappor_service_ = rappor_service;
444 } 420 }
445 421
446 /////////////////////////////////////////////////////////////////////////////// 422 ///////////////////////////////////////////////////////////////////////////////
447 423
448 TestingBrowserProcessInitializer::TestingBrowserProcessInitializer() { 424 TestingBrowserProcessInitializer::TestingBrowserProcessInitializer() {
449 TestingBrowserProcess::CreateInstance(); 425 TestingBrowserProcess::CreateInstance();
450 } 426 }
451 427
452 TestingBrowserProcessInitializer::~TestingBrowserProcessInitializer() { 428 TestingBrowserProcessInitializer::~TestingBrowserProcessInitializer() {
453 TestingBrowserProcess::DeleteInstance(); 429 TestingBrowserProcess::DeleteInstance();
454 } 430 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_browser_process.h ('k') | chrome/test/base/testing_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698