| 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); | 688 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); |
| 689 } | 689 } |
| 690 | 690 |
| 691 void RenderViewContextMenu::AppendImageItems() { | 691 void RenderViewContextMenu::AppendImageItems() { |
| 692 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, | 692 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, |
| 693 IDS_CONTENT_CONTEXT_SAVEIMAGEAS); | 693 IDS_CONTENT_CONTEXT_SAVEIMAGEAS); |
| 694 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, | 694 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, |
| 695 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION); | 695 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION); |
| 696 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, | 696 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, |
| 697 IDS_CONTENT_CONTEXT_COPYIMAGE); | 697 IDS_CONTENT_CONTEXT_COPYIMAGE); |
| 698 if (!browser_context_->IsOffTheRecord() && | 698 DataReductionProxyChromeSettings* settings = |
| 699 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 699 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 700 browser_context_)->CanUseDataReductionProxy(params_.src_url)) { | 700 browser_context_); |
| 701 if (settings && settings->CanUseDataReductionProxy(params_.src_url)) { |
| 701 menu_model_.AddItemWithStringId( | 702 menu_model_.AddItemWithStringId( |
| 702 IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB, | 703 IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB, |
| 703 IDS_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB); | 704 IDS_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB); |
| 704 } else { | 705 } else { |
| 705 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, | 706 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, |
| 706 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); | 707 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); |
| 707 } | 708 } |
| 708 } | 709 } |
| 709 | 710 |
| 710 void RenderViewContextMenu::AppendSearchWebForImageItems() { | 711 void RenderViewContextMenu::AppendSearchWebForImageItems() { |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 params_.src_url.is_empty(); | 1384 params_.src_url.is_empty(); |
| 1384 if (params_.media_type == WebContextMenuData::MediaTypeCanvas || | 1385 if (params_.media_type == WebContextMenuData::MediaTypeCanvas || |
| 1385 (params_.media_type == WebContextMenuData::MediaTypeImage && | 1386 (params_.media_type == WebContextMenuData::MediaTypeImage && |
| 1386 is_large_data_url)) { | 1387 is_large_data_url)) { |
| 1387 source_web_contents_->GetRenderViewHost()->SaveImageAt( | 1388 source_web_contents_->GetRenderViewHost()->SaveImageAt( |
| 1388 params_.x, params_.y); | 1389 params_.x, params_.y); |
| 1389 } else { | 1390 } else { |
| 1390 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); | 1391 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); |
| 1391 const GURL& url = params_.src_url; | 1392 const GURL& url = params_.src_url; |
| 1392 content::Referrer referrer = CreateSaveAsReferrer(url, params_); | 1393 content::Referrer referrer = CreateSaveAsReferrer(url, params_); |
| 1393 source_web_contents_->SaveFrame(url, referrer); | 1394 |
| 1395 std::string headers; |
| 1396 DataReductionProxyChromeSettings* settings = |
| 1397 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 1398 browser_context_); |
| 1399 if (params_.media_type == WebContextMenuData::MediaTypeImage && |
| 1400 settings && settings->CanUseDataReductionProxy(params_.src_url)) { |
| 1401 headers = data_reduction_proxy::kDataReductionPassThroughHeader; |
| 1402 } |
| 1403 |
| 1404 source_web_contents_->SaveFrameWithHeaders(url, referrer, headers); |
| 1394 } | 1405 } |
| 1395 break; | 1406 break; |
| 1396 } | 1407 } |
| 1397 | 1408 |
| 1398 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: | 1409 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: |
| 1399 WriteURLToClipboard(params_.unfiltered_link_url); | 1410 WriteURLToClipboard(params_.unfiltered_link_url); |
| 1400 break; | 1411 break; |
| 1401 | 1412 |
| 1402 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: | 1413 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: |
| 1403 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: | 1414 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 source_web_contents_->GetRenderViewHost()-> | 1815 source_web_contents_->GetRenderViewHost()-> |
| 1805 ExecuteMediaPlayerActionAtLocation(location, action); | 1816 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1806 } | 1817 } |
| 1807 | 1818 |
| 1808 void RenderViewContextMenu::PluginActionAt( | 1819 void RenderViewContextMenu::PluginActionAt( |
| 1809 const gfx::Point& location, | 1820 const gfx::Point& location, |
| 1810 const WebPluginAction& action) { | 1821 const WebPluginAction& action) { |
| 1811 source_web_contents_->GetRenderViewHost()-> | 1822 source_web_contents_->GetRenderViewHost()-> |
| 1812 ExecutePluginActionAtLocation(location, action); | 1823 ExecutePluginActionAtLocation(location, action); |
| 1813 } | 1824 } |
| OLD | NEW |