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 2fd71bb145dac9c151497cc18109e55d7b925948..65c04b2dca99ae548e09f5a6c11ed1dca0ec8329 100644 |
--- a/chrome/browser/tab_contents/render_view_context_menu.cc |
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc |
@@ -525,8 +525,9 @@ void RenderViewContextMenu::AppendAllExtensionItems() { |
} |
void RenderViewContextMenu::InitMenu() { |
- if (GetPlatformApp()) { |
- AppendPlatformAppItems(); |
+ const Extension* extension = GetExtension(); |
+ if (extension && extension->is_platform_app()) { |
+ AppendPlatformAppItems(extension); |
return; |
} |
@@ -630,7 +631,7 @@ void RenderViewContextMenu::InitMenu() { |
observers_.AddObserver(print_preview_menu_observer_.get()); |
} |
-const Extension* RenderViewContextMenu::GetPlatformApp() const { |
+const Extension* RenderViewContextMenu::GetExtension() const { |
ExtensionProcessManager* process_manager = |
profile_->GetExtensionProcessManager(); |
// There is no process manager in some tests. |
@@ -643,20 +644,25 @@ const Extension* RenderViewContextMenu::GetPlatformApp() const { |
++iter) { |
ExtensionHost* host = *iter; |
if (host->host_contents() == source_web_contents_) { |
- if (host->extension() && host->extension()->is_platform_app()) { |
- return host->extension(); |
- } |
+ const Extension* extension = host->extension(); |
+ if (extension) |
+ return extension; |
+ return NULL; |
} |
} |
return NULL; |
} |
-void RenderViewContextMenu::AppendPlatformAppItems() { |
- const Extension* platform_app = GetPlatformApp(); |
+void RenderViewContextMenu::AppendPlatformAppItems( |
+ const Extension* platform_app) { |
DCHECK(platform_app); |
int index = 0; |
AppendExtensionItems(platform_app->id(), &index); |
+ |
+ // Add dev tools for unpacked extensions. |
+ if (platform_app->location() == Extension::LOAD) |
+ AppendDeveloperItems(); |
} |
void RenderViewContextMenu::LookUpInDictionary() { |
@@ -1862,17 +1868,23 @@ void RenderViewContextMenu::MenuClosed(ui::SimpleMenuModel* source) { |
bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { |
if (id == IDC_CONTENT_CONTEXT_INSPECTELEMENT) { |
- const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
- TabContentsWrapper* tab_contents_wrapper = |
- TabContentsWrapper::GetCurrentWrapperForContents( |
- source_web_contents_); |
- if (!tab_contents_wrapper) |
- return false; |
- // Don't enable the web inspector if JavaScript is disabled. |
- if (!tab_contents_wrapper->prefs_tab_helper()->per_tab_prefs()->GetBoolean( |
- prefs::kWebKitJavascriptEnabled) || |
- command_line.HasSwitch(switches::kDisableJavaScript)) |
- return false; |
+ // Don't enable the web inspector if JavaScript is disabled. We don't |
+ // check this when this is the web contents of an extension (e.g. |
+ // for a popup extension or a platform app) as they have javascript |
Mihai Parparita -not on Chrome
2012/01/23 23:17:29
Nit: Capitalize JavaScript.
benwells
2012/01/27 07:15:58
Done.
|
+ // always enabled. |
+ if (!GetExtension()) { |
+ TabContentsWrapper* contents_wrapper = |
+ TabContentsWrapper::GetCurrentWrapperForContents( |
+ source_web_contents_); |
+ if (!contents_wrapper) |
+ return false; |
+ const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
+ if (!contents_wrapper->prefs_tab_helper()->per_tab_prefs()->GetBoolean( |
+ prefs::kWebKitJavascriptEnabled) || |
+ command_line->HasSwitch(switches::kDisableJavaScript)) |
+ return false; |
+ } |
+ |
// Don't enable the web inspector if the developer tools are disabled via |
// the preference dev-tools-disabled. |
if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) |