| 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/location.h" |
| 9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 11 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
| 18 #include "base/thread_task_runner_handle.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/devtools/device/self_device_provider.h" | 20 #include "chrome/browser/devtools/device/self_device_provider.h" |
| 18 #include "chrome/browser/devtools/devtools_window_testing.h" | 21 #include "chrome/browser/devtools/devtools_window_testing.h" |
| 19 #include "chrome/browser/extensions/extension_apitest.h" | 22 #include "chrome/browser/extensions/extension_apitest.h" |
| 20 #include "chrome/browser/extensions/extension_browsertest.h" | 23 #include "chrome/browser/extensions/extension_browsertest.h" |
| 21 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
| 22 #include "chrome/browser/extensions/unpacked_installer.h" | 25 #include "chrome/browser/extensions/unpacked_installer.h" |
| 23 #include "chrome/browser/lifetime/application_lifetime.h" | 26 #include "chrome/browser/lifetime/application_lifetime.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 extensions::ExtensionRegistry* registry = | 325 extensions::ExtensionRegistry* registry = |
| 323 extensions::ExtensionRegistry::Get(browser()->profile()); | 326 extensions::ExtensionRegistry::Get(browser()->profile()); |
| 324 size_t num_before = registry->enabled_extensions().size(); | 327 size_t num_before = registry->enabled_extensions().size(); |
| 325 { | 328 { |
| 326 content::NotificationRegistrar registrar; | 329 content::NotificationRegistrar registrar; |
| 327 registrar.Add(this, | 330 registrar.Add(this, |
| 328 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 331 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 329 content::NotificationService::AllSources()); | 332 content::NotificationService::AllSources()); |
| 330 base::CancelableClosure timeout( | 333 base::CancelableClosure timeout( |
| 331 base::Bind(&TimeoutCallback, "Extension load timed out.")); | 334 base::Bind(&TimeoutCallback, "Extension load timed out.")); |
| 332 base::MessageLoop::current()->PostDelayedTask( | 335 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 333 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); | 336 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); |
| 334 extensions::UnpackedInstaller::Create(service)->Load(path); | 337 extensions::UnpackedInstaller::Create(service)->Load(path); |
| 335 content::RunMessageLoop(); | 338 content::RunMessageLoop(); |
| 336 timeout.Cancel(); | 339 timeout.Cancel(); |
| 337 } | 340 } |
| 338 size_t num_after = registry->enabled_extensions().size(); | 341 size_t num_after = registry->enabled_extensions().size(); |
| 339 if (num_after != (num_before + 1)) | 342 if (num_after != (num_before + 1)) |
| 340 return false; | 343 return false; |
| 341 | 344 |
| 342 return WaitForExtensionViewsToLoad(); | 345 return WaitForExtensionViewsToLoad(); |
| 343 } | 346 } |
| 344 | 347 |
| 345 bool WaitForExtensionViewsToLoad() { | 348 bool WaitForExtensionViewsToLoad() { |
| 346 // Wait for all the extension render views that exist to finish loading. | 349 // Wait for all the extension render views that exist to finish loading. |
| 347 // NOTE: This assumes that the extension views list is not changing while | 350 // NOTE: This assumes that the extension views list is not changing while |
| 348 // this method is running. | 351 // this method is running. |
| 349 | 352 |
| 350 content::NotificationRegistrar registrar; | 353 content::NotificationRegistrar registrar; |
| 351 registrar.Add(this, | 354 registrar.Add(this, |
| 352 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, | 355 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, |
| 353 content::NotificationService::AllSources()); | 356 content::NotificationService::AllSources()); |
| 354 base::CancelableClosure timeout( | 357 base::CancelableClosure timeout( |
| 355 base::Bind(&TimeoutCallback, "Extension host load timed out.")); | 358 base::Bind(&TimeoutCallback, "Extension host load timed out.")); |
| 356 base::MessageLoop::current()->PostDelayedTask( | 359 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 357 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); | 360 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); |
| 358 | 361 |
| 359 extensions::ProcessManager* manager = | 362 extensions::ProcessManager* manager = |
| 360 extensions::ProcessManager::Get(browser()->profile()); | 363 extensions::ProcessManager::Get(browser()->profile()); |
| 361 extensions::ProcessManager::FrameSet all_frames = manager->GetAllFrames(); | 364 extensions::ProcessManager::FrameSet all_frames = manager->GetAllFrames(); |
| 362 for (extensions::ProcessManager::FrameSet::const_iterator iter = | 365 for (extensions::ProcessManager::FrameSet::const_iterator iter = |
| 363 all_frames.begin(); | 366 all_frames.begin(); |
| 364 iter != all_frames.end();) { | 367 iter != all_frames.end();) { |
| 365 if (!content::WebContents::FromRenderFrameHost(*iter)->IsLoading()) | 368 if (!content::WebContents::FromRenderFrameHost(*iter)->IsLoading()) |
| 366 ++iter; | 369 ++iter; |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsDisabled, true); | 969 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsDisabled, true); |
| 967 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 970 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 968 content::WebContents* web_contents = | 971 content::WebContents* web_contents = |
| 969 browser()->tab_strip_model()->GetWebContentsAt(0); | 972 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 970 scoped_refptr<content::DevToolsAgentHost> agent( | 973 scoped_refptr<content::DevToolsAgentHost> agent( |
| 971 content::DevToolsAgentHost::GetOrCreateFor(web_contents)); | 974 content::DevToolsAgentHost::GetOrCreateFor(web_contents)); |
| 972 DevToolsWindow::OpenDevToolsWindow(web_contents); | 975 DevToolsWindow::OpenDevToolsWindow(web_contents); |
| 973 DevToolsWindow* window = DevToolsWindow::FindDevToolsWindow(agent.get()); | 976 DevToolsWindow* window = DevToolsWindow::FindDevToolsWindow(agent.get()); |
| 974 ASSERT_FALSE(window); | 977 ASSERT_FALSE(window); |
| 975 } | 978 } |
| OLD | NEW |