Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / devtools_util.cc
blob21e5fe8a02cd7edd0eb24e45e306662ea912dc38
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.
5 #include "chrome/browser/extensions/devtools_util.h"
7 #include "chrome/browser/devtools/devtools_window.h"
8 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "extensions/browser/lazy_background_task_queue.h"
12 #include "extensions/browser/process_manager.h"
13 #include "extensions/common/extension.h"
15 namespace extensions {
16 namespace devtools_util {
18 namespace {
20 // Helper to inspect an ExtensionHost after it has been loaded.
21 void InspectExtensionHost(ExtensionHost* host) {
22 if (host)
23 DevToolsWindow::OpenDevToolsWindow(host->render_view_host());
26 } // namespace
28 void InspectBackgroundPage(const Extension* extension, Profile* profile) {
29 DCHECK(extension);
30 ExtensionSystem* system = ExtensionSystem::Get(profile);
31 ExtensionHost* host =
32 system->process_manager()->GetBackgroundHostForExtension(extension->id());
33 if (host) {
34 InspectExtensionHost(host);
35 } else {
36 system->lazy_background_task_queue()->AddPendingTask(
37 profile,
38 extension->id(),
39 base::Bind(&InspectExtensionHost));
43 } // namespace devtools_util
44 } // namespace extensions