Skip to content

Commit

Permalink
Fix for incomplete context menu in pdf page.
Browse files Browse the repository at this point in the history
when we are viewing the PDF in a MimeHandlerViewGuest then we should
use its embedder WebContents.
Changes done to use the embedder WebContents if we have guest view.

BUG=449919

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

Cr-Commit-Position: refs/heads/master@{#316187}
  • Loading branch information
deepak.m1 authored and Commit bot committed Feb 13, 2015
1 parent fe39916 commit 0c66165
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
23 changes: 7 additions & 16 deletions chrome/browser/renderer_context_menu/render_view_context_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -762,20 +762,8 @@ void RenderViewContextMenu::AppendMediaItems() {
}

void RenderViewContextMenu::AppendPluginItems() {
if (params_.page_url == params_.src_url) {
// Full page plugin, so show page menu items.
if (params_.link_url.is_empty() && params_.selection_text.empty())
AppendPageItems();
} else {
menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS,
IDS_CONTENT_CONTEXT_SAVEPAGEAS);
// The "Print" menu item should always be included for plugins. If
// content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT)
// is true the item will be added inside AppendPrintItem(). Otherwise we
// add "Print" here.
if (!content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT))
menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT);
}
if (params_.link_url.is_empty() && params_.selection_text.empty())
AppendPageItems();
}

void RenderViewContextMenu::AppendPageItems() {
Expand Down Expand Up @@ -1787,6 +1775,9 @@ void RenderViewContextMenu::MediaPlayerActionAt(
void RenderViewContextMenu::PluginActionAt(
const gfx::Point& location,
const WebPluginAction& action) {
source_web_contents_->GetRenderViewHost()->
ExecutePluginActionAtLocation(location, action);
RenderFrameHost* render_frame_host = GetRenderFrameHost();
if (!render_frame_host)
return;
WebContents::FromRenderFrameHost(render_frame_host)->GetRenderViewHost()
->ExecutePluginActionAtLocation(location, action);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/menu_item.h"
#if defined(ENABLE_EXTENSIONS)
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
#endif
#include "third_party/WebKit/public/web/WebContextMenuData.h"

using blink::WebContextMenuData;
Expand Down Expand Up @@ -126,6 +129,17 @@ void AddCustomItemsToMenu(const std::vector<content::MenuItem>& items,
}
}

content::WebContents* GetWebContentsToUse(content::WebContents* web_contents) {
// If we're viewing in a MimeHandlerViewGuest, use its embedder WebContents.
#if defined(ENABLE_EXTENSIONS)
auto guest_view =
extensions::MimeHandlerViewGuest::FromWebContents(web_contents);
if (guest_view)
return guest_view->embedder_web_contents();
#endif
return web_contents;
}

} // namespace

// static
Expand Down Expand Up @@ -154,7 +168,8 @@ RenderViewContextMenuBase::RenderViewContextMenuBase(
content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params)
: params_(params),
source_web_contents_(WebContents::FromRenderFrameHost(render_frame_host)),
source_web_contents_(GetWebContentsToUse(
WebContents::FromRenderFrameHost(render_frame_host))),
browser_context_(source_web_contents_->GetBrowserContext()),
menu_model_(this),
render_frame_id_(render_frame_host->GetRoutingID()),
Expand Down

0 comments on commit 0c66165

Please sign in to comment.