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