| OLD | NEW |
| 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 Loading... |
| 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 int webview_embedder_process_id = 0; |
| 524 extension->id(), | 524 int webview_instance_id = 0; |
| 525 extensions::WebViewGuest::GetViewInstanceId(source_web_contents_)); | 525 auto web_view_guest = |
| 526 extension_items_.AppendExtensionItems(key, | 526 extensions::WebViewGuest::FromWebContents(source_web_contents_); |
| 527 PrintableSelectionText(), | 527 if (web_view_guest) { |
| 528 &index, | 528 webview_embedder_process_id = |
| 529 false); // is_action_menu | 529 web_view_guest->owner_web_contents()->GetRenderProcessHost()->GetID(); |
| 530 webview_instance_id = web_view_guest->view_instance_id(); |
| 530 } | 531 } |
| 532 |
| 533 // Only add extension items from this extension. |
| 534 int index = 0; |
| 535 MenuItem::ExtensionKey key(extension->id(), webview_embedder_process_id, |
| 536 webview_instance_id); |
| 537 extension_items_.AppendExtensionItems(key, PrintableSelectionText(), &index, |
| 538 false /* is_action_menu */); |
| 531 } | 539 } |
| 532 #endif // defined(ENABLE_EXTENSIONS) | 540 #endif // defined(ENABLE_EXTENSIONS) |
| 533 | 541 |
| 534 void RenderViewContextMenu::InitMenu() { | 542 void RenderViewContextMenu::InitMenu() { |
| 535 RenderViewContextMenuBase::InitMenu(); | 543 RenderViewContextMenuBase::InitMenu(); |
| 536 | 544 |
| 537 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE)) | 545 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE)) |
| 538 AppendPageItems(); | 546 AppendPageItems(); |
| 539 | 547 |
| 540 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_FRAME)) { | 548 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_FRAME)) { |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 source_web_contents_->GetRenderViewHost()-> | 1918 source_web_contents_->GetRenderViewHost()-> |
| 1911 ExecuteMediaPlayerActionAtLocation(location, action); | 1919 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1912 } | 1920 } |
| 1913 | 1921 |
| 1914 void RenderViewContextMenu::PluginActionAt( | 1922 void RenderViewContextMenu::PluginActionAt( |
| 1915 const gfx::Point& location, | 1923 const gfx::Point& location, |
| 1916 const WebPluginAction& action) { | 1924 const WebPluginAction& action) { |
| 1917 source_web_contents_->GetRenderViewHost()-> | 1925 source_web_contents_->GetRenderViewHost()-> |
| 1918 ExecutePluginActionAtLocation(location, action); | 1926 ExecutePluginActionAtLocation(location, action); |
| 1919 } | 1927 } |
| OLD | NEW |