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

Side by Side Diff: chrome/browser/renderer_context_menu/render_view_context_menu.cc

Issue 1181263007: WebView context menu cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments by lazyboy@. Rebased. Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 false); // is_action_menu 510 false); // is_action_menu
511 } 511 }
512 } 512 }
513 } 513 }
514 514
515 void RenderViewContextMenu::AppendCurrentExtensionItems() { 515 void RenderViewContextMenu::AppendCurrentExtensionItems() {
516 // Avoid appending extension related items when |extension| is null. 516 // Avoid appending extension related items when |extension| is null.
517 // For Panel, this happens when the panel is navigated to a url outside of the 517 // For Panel, this happens when the panel is navigated to a url outside of the
518 // extension's package. 518 // extension's package.
519 const Extension* extension = GetExtension(); 519 const Extension* extension = GetExtension();
520 if (extension) { 520 if (!extension)
521 // Only add extension items from this extension. 521 return;
522 int index = 0; 522
523 MenuItem::ExtensionKey key( 523 extensions::WebViewGuest* web_view_guest =
524 extension->id(), 524 extensions::WebViewGuest::FromWebContents(source_web_contents_);
525 extensions::WebViewGuest::GetViewInstanceId(source_web_contents_)); 525 MenuItem::ExtensionKey key;
526 extension_items_.AppendExtensionItems(key, 526 if (web_view_guest) {
527 PrintableSelectionText(), 527 key = MenuItem::ExtensionKey(
528 &index, 528 web_view_guest->owner_web_contents()->GetRenderProcessHost()->GetID(),
529 false); // is_action_menu 529 web_view_guest->view_instance_id());
530 } else {
531 key = MenuItem::ExtensionKey(extension->id());
530 } 532 }
533
534 // Only add extension items from this extension.
535 int index = 0;
536 extension_items_.AppendExtensionItems(key, PrintableSelectionText(), &index,
537 false /* is_action_menu */);
531 } 538 }
532 #endif // defined(ENABLE_EXTENSIONS) 539 #endif // defined(ENABLE_EXTENSIONS)
533 540
534 void RenderViewContextMenu::InitMenu() { 541 void RenderViewContextMenu::InitMenu() {
535 RenderViewContextMenuBase::InitMenu(); 542 RenderViewContextMenuBase::InitMenu();
536 543
537 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE)) 544 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE))
538 AppendPageItems(); 545 AppendPageItems();
539 546
540 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_FRAME)) { 547 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_FRAME)) {
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 source_web_contents_->GetRenderViewHost()-> 1917 source_web_contents_->GetRenderViewHost()->
1911 ExecuteMediaPlayerActionAtLocation(location, action); 1918 ExecuteMediaPlayerActionAtLocation(location, action);
1912 } 1919 }
1913 1920
1914 void RenderViewContextMenu::PluginActionAt( 1921 void RenderViewContextMenu::PluginActionAt(
1915 const gfx::Point& location, 1922 const gfx::Point& location,
1916 const WebPluginAction& action) { 1923 const WebPluginAction& action) {
1917 source_web_contents_->GetRenderViewHost()-> 1924 source_web_contents_->GetRenderViewHost()->
1918 ExecutePluginActionAtLocation(location, action); 1925 ExecutePluginActionAtLocation(location, action);
1919 } 1926 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698