Chromium Code Reviews| Index: chrome/browser/tab_contents/render_view_context_menu.cc |
| diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc |
| index fc46a87e243e3fdebf7492a7ab6460f6f9fc0f97..8430c139f9f517be89ab2a0cb31681d54820dbde 100644 |
| --- a/chrome/browser/tab_contents/render_view_context_menu.cc |
| +++ b/chrome/browser/tab_contents/render_view_context_menu.cc |
| @@ -25,6 +25,7 @@ |
| #include "chrome/browser/download/download_service.h" |
| #include "chrome/browser/download/download_service_factory.h" |
| #include "chrome/browser/download/download_util.h" |
| +#include "chrome/browser/extensions/extension_host.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/extensions/extension_system.h" |
| #include "chrome/browser/google/google_util.h" |
| @@ -674,6 +675,8 @@ void RenderViewContextMenu::AppendPlatformAppItems() { |
| if (platform_app->location() == Extension::LOAD) { |
| menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); |
| AppendDeveloperItems(); |
| + menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE, |
| + IDS_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE); |
| } |
| } |
| @@ -1163,6 +1166,7 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { |
| return source_web_contents_->GetController().CanViewSource(); |
| case IDC_CONTENT_CONTEXT_INSPECTELEMENT: |
| + case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: |
| return IsDevCommandEnabled(id); |
| case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: |
| @@ -1732,6 +1736,19 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { |
| Inspect(params_.x, params_.y); |
| break; |
| + case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: { |
| + const Extension* platform_app = GetExtension(); |
| + DCHECK(platform_app); |
| + DCHECK(platform_app->is_platform_app()); |
| + |
| + extensions::ExtensionHost* host = profile_->GetExtensionProcessManager()-> |
| + GetBackgroundHostForExtension(platform_app->id()); |
| + DCHECK(host); |
|
Marijn Kruisselbrink
2012/09/14 21:15:18
Antony: is this safe, or are there possible situat
asargent_no_longer_on_chrome
2012/09/14 21:57:41
Let's refactor out the C++ code that the chrome://
|
| + |
| + DevToolsWindow::OpenDevToolsWindow(host->render_view_host()); |
| + break; |
| + } |
| + |
| case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: { |
| NavigationController* controller = &source_web_contents_->GetController(); |
| NavigationEntry* nav_entry = controller->GetActiveEntry(); |
| @@ -1956,7 +1973,8 @@ void RenderViewContextMenu::MenuClosed(ui::SimpleMenuModel* source) { |
| } |
| bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { |
| - if (id == IDC_CONTENT_CONTEXT_INSPECTELEMENT) { |
| + if (id == IDC_CONTENT_CONTEXT_INSPECTELEMENT || |
| + id == IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE) { |
| const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| if (!profile_->GetPrefs()->GetBoolean(prefs::kWebKitJavascriptEnabled) || |
| command_line->HasSwitch(switches::kDisableJavaScript)) |