Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/renderer_context_menu/render_view_context_menu.cc

Issue 1105263004: "Load image" context menu item to reload a LoFi image. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 {56, IDC_SPELLCHECK_LANGUAGES_FIRST}, 209 {56, IDC_SPELLCHECK_LANGUAGES_FIRST},
210 {57, IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE}, 210 {57, IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE},
211 {58, IDC_SPELLCHECK_SUGGESTION_0}, 211 {58, IDC_SPELLCHECK_SUGGESTION_0},
212 {59, IDC_SPELLCHECK_ADD_TO_DICTIONARY}, 212 {59, IDC_SPELLCHECK_ADD_TO_DICTIONARY},
213 {60, IDC_SPELLPANEL_TOGGLE}, 213 {60, IDC_SPELLPANEL_TOGGLE},
214 {61, IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB}, 214 {61, IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB},
215 {62, IDC_WRITING_DIRECTION_MENU}, 215 {62, IDC_WRITING_DIRECTION_MENU},
216 {63, IDC_WRITING_DIRECTION_DEFAULT}, 216 {63, IDC_WRITING_DIRECTION_DEFAULT},
217 {64, IDC_WRITING_DIRECTION_LTR}, 217 {64, IDC_WRITING_DIRECTION_LTR},
218 {65, IDC_WRITING_DIRECTION_RTL}, 218 {65, IDC_WRITING_DIRECTION_RTL},
219 {66, IDC_CONTENT_CONTEXT_RELOAD_ORIGINAL_IMAGE},
Lei Zhang 2015/05/11 20:16:53 You need to update tools/metrics/histograms/histog
megjablon 2015/05/11 22:58:40 Done.
219 // Add new items here and use |enum_id| from the next line. 220 // Add new items here and use |enum_id| from the next line.
220 {66, 0}, // Must be the last. Increment |enum_id| when new IDC was added. 221 {67, 0}, // Must be the last. Increment |enum_id| when new IDC was added.
221 }; 222 };
222 223
223 // Collapses large ranges of ids before looking for UMA enum. 224 // Collapses large ranges of ids before looking for UMA enum.
224 int CollapseCommandsForUMA(int id) { 225 int CollapseCommandsForUMA(int id) {
225 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); 226 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id));
226 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); 227 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id));
227 228
228 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 229 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
229 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 230 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
230 return IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; 231 return IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST;
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); 692 IDS_CONTENT_CONTEXT_COPYLINKLOCATION);
692 } 693 }
693 694
694 void RenderViewContextMenu::AppendImageItems() { 695 void RenderViewContextMenu::AppendImageItems() {
695 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, 696 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS,
696 IDS_CONTENT_CONTEXT_SAVEIMAGEAS); 697 IDS_CONTENT_CONTEXT_SAVEIMAGEAS);
697 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, 698 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION,
698 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION); 699 IDS_CONTENT_CONTEXT_COPYIMAGELOCATION);
699 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, 700 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE,
700 IDS_CONTENT_CONTEXT_COPYIMAGE); 701 IDS_CONTENT_CONTEXT_COPYIMAGE);
702 if (params_.has_image_contents && params_.image_was_fetched_lo_fi) {
703 menu_model_.AddItemWithStringId(
704 IDC_CONTENT_CONTEXT_RELOAD_ORIGINAL_IMAGE,
705 IDS_CONTENT_CONTEXT_RELOAD_ORIGINAL_IMAGE);
706 }
701 DataReductionProxyChromeSettings* settings = 707 DataReductionProxyChromeSettings* settings =
702 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( 708 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
703 browser_context_); 709 browser_context_);
704 if (settings && settings->CanUseDataReductionProxy(params_.src_url)) { 710 if (settings && settings->CanUseDataReductionProxy(params_.src_url)) {
705 menu_model_.AddItemWithStringId( 711 menu_model_.AddItemWithStringId(
706 IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB, 712 IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB,
707 IDS_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB); 713 IDS_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB);
708 } else { 714 } else {
709 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, 715 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB,
710 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); 716 IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB);
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 // Test if file-selection dialogs are forbidden by policy. 1117 // Test if file-selection dialogs are forbidden by policy.
1112 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) 1118 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs))
1113 return false; 1119 return false;
1114 1120
1115 return params_.has_image_contents; 1121 return params_.has_image_contents;
1116 } 1122 }
1117 1123
1118 // The images shown in the most visited thumbnails can't be opened or 1124 // The images shown in the most visited thumbnails can't be opened or
1119 // searched for conventionally. 1125 // searched for conventionally.
1120 case IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB: 1126 case IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB:
1127 case IDC_CONTENT_CONTEXT_RELOAD_ORIGINAL_IMAGE:
1121 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: 1128 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB:
1122 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: 1129 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE:
1123 return params_.src_url.is_valid() && 1130 return params_.src_url.is_valid() &&
1124 (params_.src_url.scheme() != content::kChromeUIScheme); 1131 (params_.src_url.scheme() != content::kChromeUIScheme);
1125 1132
1126 case IDC_CONTENT_CONTEXT_COPYIMAGE: 1133 case IDC_CONTENT_CONTEXT_COPYIMAGE:
1127 return params_.has_image_contents; 1134 return params_.has_image_contents;
1128 1135
1129 // Media control commands should all be disabled if the player is in an 1136 // Media control commands should all be disabled if the player is in an
1130 // error state. 1137 // error state.
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 GetImageThumbnailForSearch(); 1433 GetImageThumbnailForSearch();
1427 break; 1434 break;
1428 1435
1429 case IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB: 1436 case IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB:
1430 OpenURLWithExtraHeaders( 1437 OpenURLWithExtraHeaders(
1431 params_.src_url, GetDocumentURL(params_), NEW_BACKGROUND_TAB, 1438 params_.src_url, GetDocumentURL(params_), NEW_BACKGROUND_TAB,
1432 ui::PAGE_TRANSITION_LINK, 1439 ui::PAGE_TRANSITION_LINK,
1433 data_reduction_proxy::kDataReductionPassThroughHeader); 1440 data_reduction_proxy::kDataReductionPassThroughHeader);
1434 break; 1441 break;
1435 1442
1443 case IDC_CONTENT_CONTEXT_RELOAD_ORIGINAL_IMAGE:
1444 ReloadOriginalImage();
1445 break;
1446
1436 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: 1447 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB:
1437 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: 1448 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB:
1438 OpenURL(params_.src_url, 1449 OpenURL(params_.src_url,
1439 GetDocumentURL(params_), 1450 GetDocumentURL(params_),
1440 NEW_BACKGROUND_TAB, 1451 NEW_BACKGROUND_TAB,
1441 ui::PAGE_TRANSITION_LINK); 1452 ui::PAGE_TRANSITION_LINK);
1442 break; 1453 break;
1443 1454
1444 case IDC_CONTENT_CONTEXT_PLAYPAUSE: { 1455 case IDC_CONTENT_CONTEXT_PLAYPAUSE: {
1445 bool play = !!(params_.media_flags & WebContextMenuData::MediaPaused); 1456 bool play = !!(params_.media_flags & WebContextMenuData::MediaPaused);
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 kMaxSelectionTextLength, 1791 kMaxSelectionTextLength,
1781 gfx::WORD_BREAK); 1792 gfx::WORD_BREAK);
1782 } 1793 }
1783 1794
1784 // Controller functions -------------------------------------------------------- 1795 // Controller functions --------------------------------------------------------
1785 1796
1786 void RenderViewContextMenu::CopyImageAt(int x, int y) { 1797 void RenderViewContextMenu::CopyImageAt(int x, int y) {
1787 source_web_contents_->GetRenderViewHost()->CopyImageAt(x, y); 1798 source_web_contents_->GetRenderViewHost()->CopyImageAt(x, y);
1788 } 1799 }
1789 1800
1801 void RenderViewContextMenu::ReloadOriginalImage() {
1802 RenderFrameHost* render_frame_host = GetRenderFrameHost();
1803 if (!render_frame_host)
1804 return;
1805 render_frame_host->Send(new ChromeViewMsg_RequestReloadImageForContextNode(
1806 render_frame_host->GetRoutingID()));
1807 }
1808
1790 void RenderViewContextMenu::GetImageThumbnailForSearch() { 1809 void RenderViewContextMenu::GetImageThumbnailForSearch() {
1791 RenderFrameHost* render_frame_host = GetRenderFrameHost(); 1810 RenderFrameHost* render_frame_host = GetRenderFrameHost();
1792 if (!render_frame_host) 1811 if (!render_frame_host)
1793 return; 1812 return;
1794 render_frame_host->Send(new ChromeViewMsg_RequestThumbnailForContextNode( 1813 render_frame_host->Send(new ChromeViewMsg_RequestThumbnailForContextNode(
1795 render_frame_host->GetRoutingID(), 1814 render_frame_host->GetRoutingID(),
1796 kImageSearchThumbnailMinSize, 1815 kImageSearchThumbnailMinSize,
1797 gfx::Size(kImageSearchThumbnailMaxWidth, 1816 gfx::Size(kImageSearchThumbnailMaxWidth,
1798 kImageSearchThumbnailMaxHeight))); 1817 kImageSearchThumbnailMaxHeight)));
1799 } 1818 }
(...skipping 18 matching lines...) Expand all
1818 source_web_contents_->GetRenderViewHost()-> 1837 source_web_contents_->GetRenderViewHost()->
1819 ExecuteMediaPlayerActionAtLocation(location, action); 1838 ExecuteMediaPlayerActionAtLocation(location, action);
1820 } 1839 }
1821 1840
1822 void RenderViewContextMenu::PluginActionAt( 1841 void RenderViewContextMenu::PluginActionAt(
1823 const gfx::Point& location, 1842 const gfx::Point& location,
1824 const WebPluginAction& action) { 1843 const WebPluginAction& action) {
1825 source_web_contents_->GetRenderViewHost()-> 1844 source_web_contents_->GetRenderViewHost()->
1826 ExecutePluginActionAtLocation(location, action); 1845 ExecutePluginActionAtLocation(location, action);
1827 } 1846 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698