OLD | NEW |
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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.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/apps/chrome_apps_client.h" | |
12 #include "chrome/browser/background/background_mode_manager.h" | 11 #include "chrome/browser/background/background_mode_manager.h" |
13 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/browser_process_impl.h" | 13 #include "chrome/browser/browser_process_impl.h" |
15 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" | |
16 #include "chrome/browser/printing/print_job_manager.h" | 14 #include "chrome/browser/printing/print_job_manager.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/test/base/testing_browser_process_platform_part.h" | 16 #include "chrome/test/base/testing_browser_process_platform_part.h" |
19 #include "components/network_time/network_time_tracker.h" | 17 #include "components/network_time/network_time_tracker.h" |
20 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
21 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "ui/message_center/message_center.h" | 21 #include "ui/message_center/message_center.h" |
24 | 22 |
25 #if !defined(OS_IOS) | 23 #if !defined(OS_IOS) |
26 #include "chrome/browser/notifications/notification_ui_manager.h" | 24 #include "chrome/browser/notifications/notification_ui_manager.h" |
27 #include "chrome/browser/prerender/prerender_tracker.h" | 25 #include "chrome/browser/prerender/prerender_tracker.h" |
28 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
29 #endif | 27 #endif |
30 | 28 |
31 #if !defined(OS_IOS) && !defined(OS_ANDROID) | 29 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
32 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 30 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
33 #include "components/storage_monitor/storage_monitor.h" | 31 #include "components/storage_monitor/storage_monitor.h" |
34 #include "components/storage_monitor/test_storage_monitor.h" | 32 #include "components/storage_monitor/test_storage_monitor.h" |
35 #endif | 33 #endif |
36 | 34 |
37 #if defined(ENABLE_CONFIGURATION_POLICY) | 35 #if defined(ENABLE_CONFIGURATION_POLICY) |
38 #include "components/policy/core/browser/browser_policy_connector.h" | 36 #include "components/policy/core/browser/browser_policy_connector.h" |
39 #else | 37 #else |
40 #include "components/policy/core/common/policy_service_stub.h" | 38 #include "components/policy/core/common/policy_service_stub.h" |
41 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 39 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
42 | 40 |
| 41 #if defined(ENABLE_EXTENSIONS) |
| 42 #include "chrome/browser/apps/chrome_apps_client.h" |
| 43 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" |
| 44 #endif |
| 45 |
43 #if defined(ENABLE_FULL_PRINTING) | 46 #if defined(ENABLE_FULL_PRINTING) |
44 #include "chrome/browser/printing/background_printing_manager.h" | 47 #include "chrome/browser/printing/background_printing_manager.h" |
45 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 48 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
46 #endif | 49 #endif |
47 | 50 |
48 // static | 51 // static |
49 TestingBrowserProcess* TestingBrowserProcess::GetGlobal() { | 52 TestingBrowserProcess* TestingBrowserProcess::GetGlobal() { |
50 return static_cast<TestingBrowserProcess*>(g_browser_process); | 53 return static_cast<TestingBrowserProcess*>(g_browser_process); |
51 } | 54 } |
52 | 55 |
(...skipping 11 matching lines...) Expand all Loading... |
64 delete browser_process; | 67 delete browser_process; |
65 } | 68 } |
66 | 69 |
67 TestingBrowserProcess::TestingBrowserProcess() | 70 TestingBrowserProcess::TestingBrowserProcess() |
68 : notification_service_(content::NotificationService::Create()), | 71 : notification_service_(content::NotificationService::Create()), |
69 module_ref_count_(0), | 72 module_ref_count_(0), |
70 app_locale_("en"), | 73 app_locale_("en"), |
71 local_state_(NULL), | 74 local_state_(NULL), |
72 io_thread_(NULL), | 75 io_thread_(NULL), |
73 system_request_context_(NULL), | 76 system_request_context_(NULL), |
74 platform_part_(new TestingBrowserProcessPlatformPart()), | 77 platform_part_(new TestingBrowserProcessPlatformPart()) { |
75 extensions_browser_client_( | |
76 new extensions::ChromeExtensionsBrowserClient) { | |
77 #if defined(ENABLE_EXTENSIONS) | 78 #if defined(ENABLE_EXTENSIONS) |
78 apps::AppsClient::Set(ChromeAppsClient::GetInstance()); | 79 apps::AppsClient::Set(ChromeAppsClient::GetInstance()); |
| 80 extensions_browser_client_.reset( |
| 81 new extensions::ChromeExtensionsBrowserClient); |
| 82 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); |
79 #endif | 83 #endif |
80 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); | |
81 } | 84 } |
82 | 85 |
83 TestingBrowserProcess::~TestingBrowserProcess() { | 86 TestingBrowserProcess::~TestingBrowserProcess() { |
84 EXPECT_FALSE(local_state_); | 87 EXPECT_FALSE(local_state_); |
85 #if defined(ENABLE_CONFIGURATION_POLICY) | 88 #if defined(ENABLE_CONFIGURATION_POLICY) |
86 SetBrowserPolicyConnector(NULL); | 89 SetBrowserPolicyConnector(NULL); |
87 #endif | 90 #endif |
| 91 #if defined(ENABLE_EXTENSIONS) |
88 extensions::ExtensionsBrowserClient::Set(NULL); | 92 extensions::ExtensionsBrowserClient::Set(NULL); |
| 93 #endif |
89 | 94 |
90 // Destructors for some objects owned by TestingBrowserProcess will use | 95 // Destructors for some objects owned by TestingBrowserProcess will use |
91 // g_browser_process if it is not NULL, so it must be NULL before proceeding. | 96 // g_browser_process if it is not NULL, so it must be NULL before proceeding. |
92 DCHECK_EQ(static_cast<BrowserProcess*>(NULL), g_browser_process); | 97 DCHECK_EQ(static_cast<BrowserProcess*>(NULL), g_browser_process); |
93 } | 98 } |
94 | 99 |
95 void TestingBrowserProcess::ResourceDispatcherHostCreated() { | 100 void TestingBrowserProcess::ResourceDispatcherHostCreated() { |
96 } | 101 } |
97 | 102 |
98 void TestingBrowserProcess::EndSession() { | 103 void TestingBrowserProcess::EndSession() { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 441 |
437 /////////////////////////////////////////////////////////////////////////////// | 442 /////////////////////////////////////////////////////////////////////////////// |
438 | 443 |
439 TestingBrowserProcessInitializer::TestingBrowserProcessInitializer() { | 444 TestingBrowserProcessInitializer::TestingBrowserProcessInitializer() { |
440 TestingBrowserProcess::CreateInstance(); | 445 TestingBrowserProcess::CreateInstance(); |
441 } | 446 } |
442 | 447 |
443 TestingBrowserProcessInitializer::~TestingBrowserProcessInitializer() { | 448 TestingBrowserProcessInitializer::~TestingBrowserProcessInitializer() { |
444 TestingBrowserProcess::DeleteInstance(); | 449 TestingBrowserProcess::DeleteInstance(); |
445 } | 450 } |
OLD | NEW |