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

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

Issue 22314006: A few fixes for image search: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/tab_contents/render_view_context_menu.h" 5 #include "chrome/browser/tab_contents/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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 { 47, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS }, 183 { 47, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS },
184 { 48, IDC_CONTENT_CONTEXT_ADDSEARCHENGINE }, 184 { 48, IDC_CONTENT_CONTEXT_ADDSEARCHENGINE },
185 { 49, IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES }, 185 { 49, IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES },
186 { 50, IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT }, 186 { 50, IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT },
187 { 51, IDC_SPEECH_INPUT_MENU }, 187 { 51, IDC_SPEECH_INPUT_MENU },
188 { 52, IDC_CONTENT_CONTEXT_OPENLINKWITH }, 188 { 52, IDC_CONTENT_CONTEXT_OPENLINKWITH },
189 { 53, IDC_CHECK_SPELLING_WHILE_TYPING }, 189 { 53, IDC_CHECK_SPELLING_WHILE_TYPING },
190 { 54, IDC_SPELLCHECK_MENU }, 190 { 54, IDC_SPELLCHECK_MENU },
191 { 55, IDC_CONTENT_CONTEXT_SPELLING_TOGGLE }, 191 { 55, IDC_CONTENT_CONTEXT_SPELLING_TOGGLE },
192 { 56, IDC_SPELLCHECK_LANGUAGES_FIRST }, 192 { 56, IDC_SPELLCHECK_LANGUAGES_FIRST },
193 { 57, IDC_CONTENT_CONTEXT_SEARCHIMAGENEWTAB }, 193 { 57, IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE },
194 // Add new items here and use |enum_id| from the next line. 194 // Add new items here and use |enum_id| from the next line.
195 { 58, 0 }, // Must be the last. Increment |enum_id| when new IDC was added. 195 { 58, 0 }, // Must be the last. Increment |enum_id| when new IDC was added.
196 }; 196 };
197 197
198 // Collapses large ranges of ids before looking for UMA enum. 198 // Collapses large ranges of ids before looking for UMA enum.
199 int CollapleCommandsForUMA(int id) { 199 int CollapleCommandsForUMA(int id) {
200 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && 200 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST &&
201 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { 201 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) {
202 return IDC_CONTENT_CONTEXT_CUSTOM_FIRST; 202 return IDC_CONTENT_CONTEXT_CUSTOM_FIRST;
203 } 203 }
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 AppendPrintItem(); 855 AppendPrintItem();
856 const TemplateURL* const default_provider = 856 const TemplateURL* const default_provider =
857 TemplateURLServiceFactory::GetForProfile(profile_)-> 857 TemplateURLServiceFactory::GetForProfile(profile_)->
858 GetDefaultSearchProvider(); 858 GetDefaultSearchProvider();
859 if (!default_provider) 859 if (!default_provider)
860 return; 860 return;
861 SearchTermsData search_terms; 861 SearchTermsData search_terms;
862 if (!default_provider->image_url().empty() && 862 if (!default_provider->image_url().empty() &&
863 default_provider->image_url_ref().IsValidUsingTermsData(search_terms)) { 863 default_provider->image_url_ref().IsValidUsingTermsData(search_terms)) {
864 menu_model_.AddItem( 864 menu_model_.AddItem(
865 IDC_CONTENT_CONTEXT_SEARCHIMAGENEWTAB, 865 IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE,
866 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, 866 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFORIMAGE,
867 default_provider->short_name())); 867 default_provider->short_name()));
868 } 868 }
869 } 869 }
870 870
871 void RenderViewContextMenu::AppendAudioItems() { 871 void RenderViewContextMenu::AppendAudioItems() {
872 AppendMediaItems(); 872 AppendMediaItems();
873 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 873 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
874 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, 874 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS,
875 IDS_CONTENT_CONTEXT_SAVEAUDIOAS); 875 IDS_CONTENT_CONTEXT_SAVEAUDIOAS);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 PrefService* local_state = g_browser_process->local_state(); 1268 PrefService* local_state = g_browser_process->local_state();
1269 DCHECK(local_state); 1269 DCHECK(local_state);
1270 // Test if file-selection dialogs are forbidden by policy. 1270 // Test if file-selection dialogs are forbidden by policy.
1271 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) 1271 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs))
1272 return false; 1272 return false;
1273 1273
1274 return params_.src_url.is_valid() && 1274 return params_.src_url.is_valid() &&
1275 ProfileIOData::IsHandledProtocol(params_.src_url.scheme()); 1275 ProfileIOData::IsHandledProtocol(params_.src_url.scheme());
1276 } 1276 }
1277 1277
1278 // The images shown in the most visited thumbnails can't be opened or
1279 // searched for conventionally.
Avi (use Gerrit) 2013/08/06 02:29:41 crbug.com/2608 which was referenced earlier seems
Peter Kasting 2013/08/06 17:24:32 Yes, and I'm OK with that. Sid is no longer on th
1278 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: 1280 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB:
1279 case IDC_CONTENT_CONTEXT_SEARCHIMAGENEWTAB: 1281 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE:
1280 // The images shown in the most visited thumbnails do not currently open 1282 return params_.src_url.is_valid() &&
1281 // in a new tab as they should. Disabling this context menu option for 1283 (params_.src_url.scheme() != chrome::kChromeUIScheme);
1282 // now, as a quick hack, before we resolve this issue (Issue = 2608).
1283 // TODO(sidchat): Enable this option once this issue is resolved.
1284 if (params_.src_url.scheme() == chrome::kChromeUIScheme ||
1285 !params_.src_url.is_valid())
1286 return false;
1287 return true;
1288 1284
1289 case IDC_CONTENT_CONTEXT_COPYIMAGE: 1285 case IDC_CONTENT_CONTEXT_COPYIMAGE:
1290 return !params_.is_image_blocked; 1286 return !params_.is_image_blocked;
1291 1287
1292 // Media control commands should all be disabled if the player is in an 1288 // Media control commands should all be disabled if the player is in an
1293 // error state. 1289 // error state.
1294 case IDC_CONTENT_CONTEXT_PLAYPAUSE: 1290 case IDC_CONTENT_CONTEXT_PLAYPAUSE:
1295 case IDC_CONTENT_CONTEXT_LOOP: 1291 case IDC_CONTENT_CONTEXT_LOOP:
1296 return (params_.media_flags & 1292 return (params_.media_flags &
1297 WebContextMenuData::MediaInError) == 0; 1293 WebContextMenuData::MediaInError) == 0;
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 1619
1624 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: 1620 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION:
1625 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: 1621 case IDC_CONTENT_CONTEXT_COPYAVLOCATION:
1626 WriteURLToClipboard(params_.src_url); 1622 WriteURLToClipboard(params_.src_url);
1627 break; 1623 break;
1628 1624
1629 case IDC_CONTENT_CONTEXT_COPYIMAGE: 1625 case IDC_CONTENT_CONTEXT_COPYIMAGE:
1630 CopyImageAt(params_.x, params_.y); 1626 CopyImageAt(params_.x, params_.y);
1631 break; 1627 break;
1632 1628
1633 case IDC_CONTENT_CONTEXT_SEARCHIMAGENEWTAB: 1629 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE:
1634 GetImageThumbnailForSearch(); 1630 GetImageThumbnailForSearch();
1635 break; 1631 break;
1636 1632
1637 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: 1633 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB:
1638 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: 1634 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB:
1639 OpenURL( 1635 OpenURL(
1640 params_.src_url, 1636 params_.src_url,
1641 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1637 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url,
1642 params_.frame_id, 1638 params_.frame_id,
1643 NEW_BACKGROUND_TAB, content::PAGE_TRANSITION_LINK); 1639 NEW_BACKGROUND_TAB, content::PAGE_TRANSITION_LINK);
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 source_web_contents_->GetRenderViewHost()-> 2086 source_web_contents_->GetRenderViewHost()->
2091 ExecuteMediaPlayerActionAtLocation(location, action); 2087 ExecuteMediaPlayerActionAtLocation(location, action);
2092 } 2088 }
2093 2089
2094 void RenderViewContextMenu::PluginActionAt( 2090 void RenderViewContextMenu::PluginActionAt(
2095 const gfx::Point& location, 2091 const gfx::Point& location,
2096 const WebPluginAction& action) { 2092 const WebPluginAction& action) {
2097 source_web_contents_->GetRenderViewHost()-> 2093 source_web_contents_->GetRenderViewHost()->
2098 ExecutePluginActionAtLocation(location, action); 2094 ExecutePluginActionAtLocation(location, action);
2099 } 2095 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/chrome_render_view_host_observer.cc ('k') | chrome/browser/ui/gtk/menu_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698