OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/extensions/devtools_util.h" |
| 6 |
| 7 #include "chrome/browser/devtools/devtools_window.h" |
| 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/browser/extensions/extension_process_manager.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" |
| 11 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
| 12 #include "chrome/common/extensions/extension.h" |
| 13 |
| 14 namespace extensions { |
| 15 namespace devtools_util { |
| 16 |
| 17 namespace { |
| 18 |
| 19 // Helper to inspect an ExtensionHost after it has been loaded. |
| 20 void InspectExtensionHost(ExtensionHost* host) { |
| 21 if (host) |
| 22 DevToolsWindow::OpenDevToolsWindow(host->render_view_host()); |
| 23 } |
| 24 |
| 25 } // namespace |
| 26 |
| 27 void InspectBackgroundPage(const Extension* extension, Profile* profile) { |
| 28 DCHECK(extension); |
| 29 ExtensionSystem* system = ExtensionSystem::Get(profile); |
| 30 ExtensionHost* host = |
| 31 system->process_manager()->GetBackgroundHostForExtension(extension->id()); |
| 32 if (host) { |
| 33 InspectExtensionHost(host); |
| 34 } else { |
| 35 system->lazy_background_task_queue()->AddPendingTask( |
| 36 profile, |
| 37 extension->id(), |
| 38 base::Bind(&InspectExtensionHost)); |
| 39 } |
| 40 } |
| 41 |
| 42 } // namespace devtools_util |
| 43 } // namespace extensions |
OLD | NEW |