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