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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/cancelable_callback.h" | 6 #include "base/cancelable_callback.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "content/public/browser/devtools_agent_host.h" | 38 #include "content/public/browser/devtools_agent_host.h" |
39 #include "content/public/browser/devtools_http_handler.h" | 39 #include "content/public/browser/devtools_http_handler.h" |
40 #include "content/public/browser/notification_registrar.h" | 40 #include "content/public/browser/notification_registrar.h" |
41 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
42 #include "content/public/browser/render_view_host.h" | 42 #include "content/public/browser/render_view_host.h" |
43 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
44 #include "content/public/browser/worker_service.h" | 44 #include "content/public/browser/worker_service.h" |
45 #include "content/public/browser/worker_service_observer.h" | 45 #include "content/public/browser/worker_service_observer.h" |
46 #include "content/public/common/content_switches.h" | 46 #include "content/public/common/content_switches.h" |
47 #include "content/public/test/browser_test_utils.h" | 47 #include "content/public/test/browser_test_utils.h" |
| 48 #include "extensions/browser/extension_registry.h" |
48 #include "extensions/browser/extension_system.h" | 49 #include "extensions/browser/extension_system.h" |
49 #include "extensions/browser/notification_types.h" | 50 #include "extensions/browser/notification_types.h" |
50 #include "extensions/common/switches.h" | 51 #include "extensions/common/switches.h" |
51 #include "net/socket/tcp_listen_socket.h" | 52 #include "net/socket/tcp_listen_socket.h" |
52 #include "net/test/spawned_test_server/spawned_test_server.h" | 53 #include "net/test/spawned_test_server/spawned_test_server.h" |
53 | 54 |
54 using content::BrowserThread; | 55 using content::BrowserThread; |
55 using content::DevToolsAgentHost; | 56 using content::DevToolsAgentHost; |
56 using content::NavigationController; | 57 using content::NavigationController; |
57 using content::RenderViewHost; | 58 using content::RenderViewHost; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // Load an extension from test\data\devtools\extensions\<extension_name> | 309 // Load an extension from test\data\devtools\extensions\<extension_name> |
309 void LoadExtension(const char* extension_name) { | 310 void LoadExtension(const char* extension_name) { |
310 base::FilePath path = test_extensions_dir_.AppendASCII(extension_name); | 311 base::FilePath path = test_extensions_dir_.AppendASCII(extension_name); |
311 ASSERT_TRUE(LoadExtensionFromPath(path)) << "Failed to load extension."; | 312 ASSERT_TRUE(LoadExtensionFromPath(path)) << "Failed to load extension."; |
312 } | 313 } |
313 | 314 |
314 private: | 315 private: |
315 bool LoadExtensionFromPath(const base::FilePath& path) { | 316 bool LoadExtensionFromPath(const base::FilePath& path) { |
316 ExtensionService* service = extensions::ExtensionSystem::Get( | 317 ExtensionService* service = extensions::ExtensionSystem::Get( |
317 browser()->profile())->extension_service(); | 318 browser()->profile())->extension_service(); |
318 size_t num_before = service->extensions()->size(); | 319 extensions::ExtensionRegistry* registry = |
| 320 extensions::ExtensionRegistry::Get(browser()->profile()); |
| 321 size_t num_before = registry->enabled_extensions().size(); |
319 { | 322 { |
320 content::NotificationRegistrar registrar; | 323 content::NotificationRegistrar registrar; |
321 registrar.Add(this, | 324 registrar.Add(this, |
322 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 325 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
323 content::NotificationService::AllSources()); | 326 content::NotificationService::AllSources()); |
324 base::CancelableClosure timeout( | 327 base::CancelableClosure timeout( |
325 base::Bind(&TimeoutCallback, "Extension load timed out.")); | 328 base::Bind(&TimeoutCallback, "Extension load timed out.")); |
326 base::MessageLoop::current()->PostDelayedTask( | 329 base::MessageLoop::current()->PostDelayedTask( |
327 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); | 330 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); |
328 extensions::UnpackedInstaller::Create(service)->Load(path); | 331 extensions::UnpackedInstaller::Create(service)->Load(path); |
329 content::RunMessageLoop(); | 332 content::RunMessageLoop(); |
330 timeout.Cancel(); | 333 timeout.Cancel(); |
331 } | 334 } |
332 size_t num_after = service->extensions()->size(); | 335 size_t num_after = registry->enabled_extensions().size(); |
333 if (num_after != (num_before + 1)) | 336 if (num_after != (num_before + 1)) |
334 return false; | 337 return false; |
335 | 338 |
336 return WaitForExtensionViewsToLoad(); | 339 return WaitForExtensionViewsToLoad(); |
337 } | 340 } |
338 | 341 |
339 bool WaitForExtensionViewsToLoad() { | 342 bool WaitForExtensionViewsToLoad() { |
340 // Wait for all the extension render views that exist to finish loading. | 343 // Wait for all the extension render views that exist to finish loading. |
341 // NOTE: This assumes that the extension views list is not changing while | 344 // NOTE: This assumes that the extension views list is not changing while |
342 // this method is running. | 345 // this method is running. |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 #endif | 939 #endif |
937 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, MAYBE_RemoteDebugger) { | 940 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, MAYBE_RemoteDebugger) { |
938 #if defined(OS_WIN) && defined(USE_ASH) | 941 #if defined(OS_WIN) && defined(USE_ASH) |
939 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 942 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
940 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 943 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
941 return; | 944 return; |
942 #endif | 945 #endif |
943 | 946 |
944 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; | 947 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; |
945 } | 948 } |
OLD | NEW |