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/browser/extensions/test_extension_system.h" | 5 #include "chrome/browser/extensions/test_extension_system.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" | 7 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" |
8 #include "chrome/browser/extensions/event_router.h" | 8 #include "chrome/browser/extensions/event_router.h" |
9 #include "chrome/browser/extensions/extension_devtools_manager.h" | 9 #include "chrome/browser/extensions/extension_devtools_manager.h" |
10 #include "chrome/browser/extensions/extension_info_map.h" | 10 #include "chrome/browser/extensions/extension_info_map.h" |
11 #include "chrome/browser/extensions/extension_pref_value_map.h" | 11 #include "chrome/browser/extensions/extension_pref_value_map.h" |
12 #include "chrome/browser/extensions/extension_pref_value_map_factory.h" | 12 #include "chrome/browser/extensions/extension_pref_value_map_factory.h" |
13 #include "chrome/browser/extensions/extension_process_manager.h" | 13 #include "chrome/browser/extensions/extension_process_manager.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
16 #include "chrome/browser/extensions/message_service.h" | 16 #include "chrome/browser/extensions/message_service.h" |
17 #include "chrome/browser/extensions/state_store.h" | 17 #include "chrome/browser/extensions/state_store.h" |
18 #include "chrome/browser/extensions/user_script_master.h" | 18 #include "chrome/browser/extensions/user_script_master.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/value_store/testing_value_store.h" | 20 #include "chrome/browser/value_store/testing_value_store.h" |
21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
22 #include "content/public/browser/browser_thread.h" | |
23 | |
24 using content::BrowserThread; | |
25 | 22 |
26 namespace extensions { | 23 namespace extensions { |
27 | 24 |
28 TestExtensionSystem::TestExtensionSystem(Profile* profile) | 25 TestExtensionSystem::TestExtensionSystem(Profile* profile) |
29 : profile_(profile), | 26 : profile_(profile), |
30 info_map_(new ExtensionInfoMap()) { | 27 info_map_(new ExtensionInfoMap()) { |
31 } | 28 } |
32 | 29 |
33 TestExtensionSystem::~TestExtensionSystem() { | 30 TestExtensionSystem::~TestExtensionSystem() { |
34 } | 31 } |
35 | 32 |
36 void TestExtensionSystem::Shutdown() { | 33 void TestExtensionSystem::Shutdown() { |
37 extension_process_manager_.reset(); | 34 extension_process_manager_.reset(); |
38 } | 35 } |
39 | 36 |
40 void TestExtensionSystem::CreateExtensionProcessManager() { | 37 void TestExtensionSystem::CreateExtensionProcessManager() { |
41 extension_process_manager_.reset(ExtensionProcessManager::Create(profile_)); | 38 extension_process_manager_.reset(ExtensionProcessManager::Create(profile_)); |
42 } | 39 } |
43 | 40 |
44 void TestExtensionSystem::CreateAlarmManager( | 41 void TestExtensionSystem::CreateAlarmManager( |
45 AlarmManager::TimeProvider now) { | 42 AlarmManager::TimeProvider now) { |
46 alarm_manager_.reset(new AlarmManager(profile_, now)); | 43 alarm_manager_.reset(new AlarmManager(profile_, now)); |
47 } | 44 } |
48 | 45 |
49 void TestExtensionSystem::CreateSocketManager() { | |
50 // Note that we're intentionally creating the socket manager on the wrong | |
51 // thread (not the IO thread). This is because we don't want to presume or | |
52 // require that there be an IO thread in a lightweight test context. If we do | |
53 // need thread-specific behavior someday, we'll probably need something like | |
54 // CreateSocketManagerOnThreadForTesting(thread_id). But not today. | |
55 BrowserThread::ID id; | |
56 DCHECK(BrowserThread::GetCurrentThreadIdentifier(&id)); | |
57 socket_manager_.reset(new ApiResourceManager<Socket>(id)); | |
58 } | |
59 | |
60 ExtensionService* TestExtensionSystem::CreateExtensionService( | 46 ExtensionService* TestExtensionSystem::CreateExtensionService( |
61 const CommandLine* command_line, | 47 const CommandLine* command_line, |
62 const FilePath& install_directory, | 48 const FilePath& install_directory, |
63 bool autoupdate_enabled) { | 49 bool autoupdate_enabled) { |
64 bool extensions_disabled = | 50 bool extensions_disabled = |
65 command_line && command_line->HasSwitch(switches::kDisableExtensions); | 51 command_line && command_line->HasSwitch(switches::kDisableExtensions); |
66 | 52 |
67 // Note that the GetPrefs() creates a TestingPrefService, therefore | 53 // Note that the GetPrefs() creates a TestingPrefService, therefore |
68 // the extension controlled pref values set in extension_prefs_ | 54 // the extension controlled pref values set in extension_prefs_ |
69 // are not reflected in the pref service. One would need to | 55 // are not reflected in the pref service. One would need to |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 RulesRegistryService* TestExtensionSystem::rules_registry_service() { | 131 RulesRegistryService* TestExtensionSystem::rules_registry_service() { |
146 return NULL; | 132 return NULL; |
147 } | 133 } |
148 | 134 |
149 ApiResourceManager<SerialConnection>* | 135 ApiResourceManager<SerialConnection>* |
150 TestExtensionSystem::serial_connection_manager() { | 136 TestExtensionSystem::serial_connection_manager() { |
151 return NULL; | 137 return NULL; |
152 } | 138 } |
153 | 139 |
154 ApiResourceManager<Socket>*TestExtensionSystem::socket_manager() { | 140 ApiResourceManager<Socket>*TestExtensionSystem::socket_manager() { |
155 return socket_manager_.get(); | 141 return NULL; |
156 } | 142 } |
157 | 143 |
158 ApiResourceManager<UsbDeviceResource>* | 144 ApiResourceManager<UsbDeviceResource>* |
159 TestExtensionSystem::usb_device_resource_manager() { | 145 TestExtensionSystem::usb_device_resource_manager() { |
160 return NULL; | 146 return NULL; |
161 } | 147 } |
162 | 148 |
163 // static | 149 // static |
164 ProfileKeyedService* TestExtensionSystem::Build(Profile* profile) { | 150 ProfileKeyedService* TestExtensionSystem::Build(Profile* profile) { |
165 return new TestExtensionSystem(profile); | 151 return new TestExtensionSystem(profile); |
166 } | 152 } |
167 | 153 |
168 } // namespace extensions | 154 } // namespace extensions |
OLD | NEW |