Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Unified Diff: chrome/browser/renderer_context_menu/render_view_context_menu.cc

Issue 931073002: Fix for Incomplete context menu shown in PDF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/renderer_context_menu/render_view_context_menu_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_context_menu/render_view_context_menu.cc
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
index 708622d66249ab1b7a71847b7024da2eac65aab0..1f12cf9a83280e90d69e115349b1e0f87d555c09 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
@@ -87,6 +87,7 @@
#include "content/public/common/url_utils.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_system.h"
+#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/view_type_utils.h"
#include "extensions/common/extension.h"
@@ -296,6 +297,15 @@ content::Referrer CreateSaveAsReferrer(
content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy));
}
+content::WebContents* GetWebContentsToUse(content::WebContents* web_contents) {
+ // If we're viewing in a MimeHandlerViewGuest, use its embedder WebContents.
+ auto guest_view =
+ extensions::MimeHandlerViewGuest::FromWebContents(web_contents);
+ if (guest_view)
+ return guest_view->embedder_web_contents();
+ return web_contents;
+}
+
bool g_custom_id_ranges_initialized = false;
const int kSpellcheckRadioGroup = 1;
@@ -999,25 +1009,29 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
IncognitoModePrefs::GetAvailability(prefs);
switch (id) {
case IDC_BACK:
- return source_web_contents_->GetController().CanGoBack();
+ return GetWebContentsToUse(source_web_contents_)
Avi (use Gerrit) 2015/02/17 16:22:42 Can you pull GetWebContentsToUse(source_web_conten
+ ->GetController().CanGoBack();
case IDC_FORWARD:
- return source_web_contents_->GetController().CanGoForward();
+ return GetWebContentsToUse(source_web_contents_)
+ ->GetController().CanGoForward();
case IDC_RELOAD: {
- CoreTabHelper* core_tab_helper =
- CoreTabHelper::FromWebContents(source_web_contents_);
+ CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(
+ GetWebContentsToUse(source_web_contents_));
if (!core_tab_helper)
return false;
CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate();
return !core_delegate ||
- core_delegate->CanReloadContents(source_web_contents_);
+ core_delegate->CanReloadContents(
+ GetWebContentsToUse(source_web_contents_));
}
case IDC_VIEW_SOURCE:
case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE:
- return source_web_contents_->GetController().CanViewSource();
+ return GetWebContentsToUse(source_web_contents_)
+ ->GetController().CanViewSource();
case IDC_CONTENT_CONTEXT_INSPECTELEMENT:
case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE:
@@ -1026,11 +1040,15 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
return IsDevCommandEnabled(id);
case IDC_CONTENT_CONTEXT_VIEWPAGEINFO:
- if (source_web_contents_->GetController().GetVisibleEntry() == NULL)
+ if (GetWebContentsToUse(source_web_contents_)
+ ->GetController().GetVisibleEntry() == NULL) {
return false;
+ }
// Disabled if no browser is associated (e.g. desktop notifications).
- if (chrome::FindBrowserWithWebContents(source_web_contents_) == NULL)
+ if (chrome::FindBrowserWithWebContents(
+ GetWebContentsToUse(source_web_contents_)) == NULL) {
return false;
+ }
return true;
case IDC_CONTENT_CONTEXT_TRANSLATE: {
@@ -1150,15 +1168,16 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
return !!(params_.media_flags & WebContextMenuData::MediaCanSave);
case IDC_SAVE_PAGE: {
- CoreTabHelper* core_tab_helper =
- CoreTabHelper::FromWebContents(source_web_contents_);
+ CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(
+ GetWebContentsToUse(source_web_contents_));
if (!core_tab_helper)
return false;
CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate();
- if (core_delegate &&
- !core_delegate->CanSaveContents(source_web_contents_))
+ if (core_delegate && !core_delegate->CanSaveContents(
+ GetWebContentsToUse(source_web_contents_))) {
return false;
+ }
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);
@@ -1168,8 +1187,8 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
// We save the last committed entry (which the user is looking at), as
// opposed to any pending URL that hasn't committed yet.
- NavigationEntry* entry =
- source_web_contents_->GetController().GetLastCommittedEntry();
+ NavigationEntry* entry = GetWebContentsToUse(source_web_contents_)
+ ->GetController().GetLastCommittedEntry();
return content::IsSavableURL(entry ? entry->GetURL() : GURL());
}
@@ -1455,19 +1474,19 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
break;
case IDC_BACK:
- source_web_contents_->GetController().GoBack();
+ GetWebContentsToUse(source_web_contents_)->GetController().GoBack();
break;
case IDC_FORWARD:
- source_web_contents_->GetController().GoForward();
+ GetWebContentsToUse(source_web_contents_)->GetController().GoForward();
break;
case IDC_SAVE_PAGE:
- source_web_contents_->OnSavePage();
+ GetWebContentsToUse(source_web_contents_)->OnSavePage();
break;
case IDC_RELOAD:
- source_web_contents_->GetController().Reload(true);
+ GetWebContentsToUse(source_web_contents_)->GetController().Reload(true);
break;
case IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP: {
@@ -1510,7 +1529,7 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
}
case IDC_VIEW_SOURCE:
- source_web_contents_->ViewSource();
+ GetWebContentsToUse(source_web_contents_)->ViewSource();
break;
case IDC_CONTENT_CONTEXT_INSPECTELEMENT:
@@ -1528,15 +1547,17 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
}
case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: {
- NavigationController* controller = &source_web_contents_->GetController();
+ NavigationController* controller =
+ &GetWebContentsToUse(source_web_contents_)->GetController();
// Important to use GetVisibleEntry to match what's showing in the
// omnibox. This may return null.
NavigationEntry* nav_entry = controller->GetVisibleEntry();
if (!nav_entry)
return;
- Browser* browser =
- chrome::FindBrowserWithWebContents(source_web_contents_);
- chrome::ShowWebsiteSettings(browser, source_web_contents_,
+ Browser* browser = chrome::FindBrowserWithWebContents(
+ GetWebContentsToUse(source_web_contents_));
+ chrome::ShowWebsiteSettings(browser,
+ GetWebContentsToUse(source_web_contents_),
nav_entry->GetURL(), nav_entry->GetSSL());
break;
}
@@ -1775,9 +1796,6 @@ void RenderViewContextMenu::MediaPlayerActionAt(
void RenderViewContextMenu::PluginActionAt(
const gfx::Point& location,
const WebPluginAction& action) {
- RenderFrameHost* render_frame_host = GetRenderFrameHost();
- if (!render_frame_host)
- return;
- WebContents::FromRenderFrameHost(render_frame_host)->GetRenderViewHost()
- ->ExecutePluginActionAtLocation(location, action);
+ source_web_contents_->GetRenderViewHost()->ExecutePluginActionAtLocation(
+ location, action);
}
« no previous file with comments | « no previous file | components/renderer_context_menu/render_view_context_menu_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698