Commit 78437f79 authored by lazyboy's avatar lazyboy Committed by Commit bot

Hide "Inspect Element" context menu item from <webview> when <webview>

    is embedded in WebUI.
This is no-op in CANARY or tott build.

BUG=469237
Test=launch chrome with --enable-inline-signin
Navigate a tab to sign in page: i.e. chrome://chrome-signin/
Right click on white background, you shouldn't see inpsect element.

Review URL: https://codereview.chromium.org/1024153002

Cr-Commit-Position: refs/heads/master@{#322040}
parent 4a892cc1
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/manifest.h" #include "extensions/common/manifest.h"
...@@ -33,10 +35,22 @@ bool ContextMenuContentTypeWebView::SupportsGroup(int group) { ...@@ -33,10 +35,22 @@ bool ContextMenuContentTypeWebView::SupportsGroup(int group) {
// Show contextMenus API items. // Show contextMenus API items.
return true; return true;
case ITEM_GROUP_DEVELOPER: case ITEM_GROUP_DEVELOPER:
// TODO(lazyboy): Enable this for mac too when http://crbug.com/380405 is
// fixed.
#if !defined(OS_MACOSX)
{ {
if (chrome::VersionInfo::GetChannel() >=
chrome::VersionInfo::CHANNEL_DEV) {
// Hide dev tools items in guests inside WebUI if we are not running
// canary or tott.
auto web_view_guest =
extensions::WebViewGuest::FromWebContents(source_web_contents());
if (web_view_guest &&
web_view_guest->owner_web_contents()->GetWebUI()) {
return false;
}
}
// TODO(lazyboy): Enable this for mac too when http://crbug.com/380405
// is fixed.
#if !defined(OS_MACOSX)
// Add dev tools for unpacked extensions. // Add dev tools for unpacked extensions.
const extensions::Extension* embedder_platform_app = GetExtension(); const extensions::Extension* embedder_platform_app = GetExtension();
return !embedder_platform_app || return !embedder_platform_app ||
...@@ -44,10 +58,10 @@ bool ContextMenuContentTypeWebView::SupportsGroup(int group) { ...@@ -44,10 +58,10 @@ bool ContextMenuContentTypeWebView::SupportsGroup(int group) {
embedder_platform_app->location()) || embedder_platform_app->location()) ||
base::CommandLine::ForCurrentProcess()->HasSwitch( base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDebugPackedApps); switches::kDebugPackedApps);
}
#else #else
return ContextMenuContentType::SupportsGroup(group); return ContextMenuContentType::SupportsGroup(group);
#endif #endif
}
default: default:
return ContextMenuContentType::SupportsGroup(group); return ContextMenuContentType::SupportsGroup(group);
} }
......
...@@ -70,6 +70,10 @@ class ContextMenuContentType { ...@@ -70,6 +70,10 @@ class ContextMenuContentType {
const extensions::Extension* GetExtension() const; const extensions::Extension* GetExtension() const;
const content::WebContents* source_web_contents() const {
return source_web_contents_;
}
private: private:
bool SupportsGroupInternal(int group); bool SupportsGroupInternal(int group);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment