| 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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); | 1442 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); |
| 1443 RenderViewContextMenuObserver* observer; | 1443 RenderViewContextMenuObserver* observer; |
| 1444 while ((observer = it.GetNext()) != NULL) { | 1444 while ((observer = it.GetNext()) != NULL) { |
| 1445 if (observer->IsCommandIdSupported(id)) | 1445 if (observer->IsCommandIdSupported(id)) |
| 1446 return observer->ExecuteCommand(id); | 1446 return observer->ExecuteCommand(id); |
| 1447 } | 1447 } |
| 1448 | 1448 |
| 1449 RecordUsedItem(id); | 1449 RecordUsedItem(id); |
| 1450 | 1450 |
| 1451 RenderViewHost* rvh = source_web_contents_->GetRenderViewHost(); | 1451 RenderViewHost* rvh = source_web_contents_->GetRenderViewHost(); |
| 1452 RenderFrameHost* render_frame_host = |
| 1453 RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 1452 | 1454 |
| 1453 // Process custom actions range. | 1455 // Process custom actions range. |
| 1454 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && | 1456 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && |
| 1455 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { | 1457 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { |
| 1456 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; | 1458 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; |
| 1457 const content::CustomContextMenuContext& context = params_.custom_context; | 1459 const content::CustomContextMenuContext& context = params_.custom_context; |
| 1458 #if defined(ENABLE_PLUGINS) | 1460 #if defined(ENABLE_PLUGINS) |
| 1459 if (context.request_id && !context.is_pepper_menu) { | 1461 if (context.request_id && !context.is_pepper_menu) { |
| 1460 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( | 1462 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
| 1461 source_web_contents_, false, std::string()); | 1463 source_web_contents_, false, std::string()); |
| 1462 } | 1464 } |
| 1463 #endif | 1465 #endif |
| 1464 RenderFrameHost* render_frame_host = | |
| 1465 RenderFrameHost::FromID(render_process_id_, render_frame_id_); | |
| 1466 if (render_frame_host) | 1466 if (render_frame_host) |
| 1467 render_frame_host->ExecuteCustomContextMenuCommand(action, context); | 1467 render_frame_host->ExecuteCustomContextMenuCommand(action, context); |
| 1468 return; | 1468 return; |
| 1469 } | 1469 } |
| 1470 | 1470 |
| 1471 // Process extension menu items. | 1471 // Process extension menu items. |
| 1472 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && | 1472 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
| 1473 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { | 1473 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { |
| 1474 extension_items_.ExecuteCommand(id, source_web_contents_, params_); | 1474 extension_items_.ExecuteCommand(id, source_web_contents_, params_); |
| 1475 return; | 1475 return; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 | 1795 |
| 1796 case IDC_CONTENT_CONTEXT_UNDO: | 1796 case IDC_CONTENT_CONTEXT_UNDO: |
| 1797 rvh->Undo(); | 1797 rvh->Undo(); |
| 1798 break; | 1798 break; |
| 1799 | 1799 |
| 1800 case IDC_CONTENT_CONTEXT_REDO: | 1800 case IDC_CONTENT_CONTEXT_REDO: |
| 1801 rvh->Redo(); | 1801 rvh->Redo(); |
| 1802 break; | 1802 break; |
| 1803 | 1803 |
| 1804 case IDC_CONTENT_CONTEXT_CUT: | 1804 case IDC_CONTENT_CONTEXT_CUT: |
| 1805 rvh->Cut(); | 1805 if (render_frame_host) |
| 1806 render_frame_host->Cut(); |
| 1806 break; | 1807 break; |
| 1807 | 1808 |
| 1808 case IDC_CONTENT_CONTEXT_COPY: | 1809 case IDC_CONTENT_CONTEXT_COPY: |
| 1809 rvh->Copy(); | 1810 if (render_frame_host) |
| 1811 render_frame_host->Copy(); |
| 1810 break; | 1812 break; |
| 1811 | 1813 |
| 1812 case IDC_CONTENT_CONTEXT_PASTE: | 1814 case IDC_CONTENT_CONTEXT_PASTE: |
| 1813 rvh->Paste(); | 1815 if (render_frame_host) |
| 1816 render_frame_host->Paste(); |
| 1814 break; | 1817 break; |
| 1815 | 1818 |
| 1816 case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE: | 1819 case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE: |
| 1817 rvh->PasteAndMatchStyle(); | 1820 rvh->PasteAndMatchStyle(); |
| 1818 break; | 1821 break; |
| 1819 | 1822 |
| 1820 case IDC_CONTENT_CONTEXT_DELETE: | 1823 case IDC_CONTENT_CONTEXT_DELETE: |
| 1821 rvh->Delete(); | 1824 rvh->Delete(); |
| 1822 break; | 1825 break; |
| 1823 | 1826 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 source_web_contents_->GetRenderViewHost()-> | 2053 source_web_contents_->GetRenderViewHost()-> |
| 2051 ExecuteMediaPlayerActionAtLocation(location, action); | 2054 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2052 } | 2055 } |
| 2053 | 2056 |
| 2054 void RenderViewContextMenu::PluginActionAt( | 2057 void RenderViewContextMenu::PluginActionAt( |
| 2055 const gfx::Point& location, | 2058 const gfx::Point& location, |
| 2056 const WebPluginAction& action) { | 2059 const WebPluginAction& action) { |
| 2057 source_web_contents_->GetRenderViewHost()-> | 2060 source_web_contents_->GetRenderViewHost()-> |
| 2058 ExecutePluginActionAtLocation(location, action); | 2061 ExecutePluginActionAtLocation(location, action); |
| 2059 } | 2062 } |
| OLD | NEW |