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

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

Issue 468913003: Clean up RenderViewContextMenu a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 void EscapeAmpersands(base::string16* text) { 270 void EscapeAmpersands(base::string16* text) {
271 base::ReplaceChars(*text, base::ASCIIToUTF16("&"), base::ASCIIToUTF16("&&"), 271 base::ReplaceChars(*text, base::ASCIIToUTF16("&"), base::ASCIIToUTF16("&&"),
272 text); 272 text);
273 } 273 }
274 274
275 // Returns the preference of the profile represented by the |context|. 275 // Returns the preference of the profile represented by the |context|.
276 PrefService* GetPrefs(content::BrowserContext* context) { 276 PrefService* GetPrefs(content::BrowserContext* context) {
277 return user_prefs::UserPrefs::Get(context); 277 return user_prefs::UserPrefs::Get(context);
278 } 278 }
279 279
280 bool custom_id_ranges_initialized = false; 280 bool ExtensionPatternMatch(const extensions::URLPatternSet& patterns,
281 const GURL& url) {
282 // No patterns means no restriction, so that implicitly matches.
283 if (patterns.is_empty())
284 return true;
285 return patterns.MatchesURL(url);
286 }
287
288 const GURL& GetDocumentURL(const content::ContextMenuParams& params) {
289 return params.frame_url.is_empty() ? params.page_url : params.frame_url;
290 }
291
292 content::Referrer CreateSaveAsReferrer(
293 const content::ContextMenuParams& params) {
294 const GURL& url = params.link_url;
295 const GURL& referring_url = GetDocumentURL(params);
296 return content::Referrer::SanitizeForRequest(
297 url,
298 content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy));
299 }
300
301 bool g_custom_id_ranges_initialized = false;
lazyboy 2014/08/17 15:23:28 I think we should keep it as is since this is not
Lei Zhang 2014/08/18 22:56:25 File-level globals are still globals.
lazyboy 2014/08/21 18:24:56 OK.
302
303 const int kSpellcheckRadioGroup = 1;
281 304
282 } // namespace 305 } // namespace
283 306
284 // static 307 // static
285 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) { 308 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) {
286 return url.SchemeIs(content::kChromeDevToolsScheme); 309 return url.SchemeIs(content::kChromeDevToolsScheme);
287 } 310 }
288 311
289 // static 312 // static
290 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) { 313 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) {
291 if (!url.SchemeIs(content::kChromeUIScheme)) 314 if (!url.SchemeIs(content::kChromeUIScheme))
292 return false; 315 return false;
293 return url.host() == chrome::kChromeUISyncResourcesHost; 316 return url.host() == chrome::kChromeUISyncResourcesHost;
294 } 317 }
295 318
296 static const int kSpellcheckRadioGroup = 1;
297
298 RenderViewContextMenu::RenderViewContextMenu( 319 RenderViewContextMenu::RenderViewContextMenu(
299 content::RenderFrameHost* render_frame_host, 320 content::RenderFrameHost* render_frame_host,
300 const content::ContextMenuParams& params) 321 const content::ContextMenuParams& params)
301 : RenderViewContextMenuBase(render_frame_host, params), 322 : RenderViewContextMenuBase(render_frame_host, params),
302 extension_items_(browser_context_, 323 extension_items_(browser_context_,
303 this, 324 this,
304 &menu_model_, 325 &menu_model_,
305 base::Bind(MenuItemMatchesParams, params_)), 326 base::Bind(MenuItemMatchesParams, params_)),
306 protocol_handler_submenu_model_(this), 327 protocol_handler_submenu_model_(this),
307 protocol_handler_registry_( 328 protocol_handler_registry_(
308 ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())) { 329 ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())) {
309 if (!custom_id_ranges_initialized) { 330 if (!g_custom_id_ranges_initialized) {
310 custom_id_ranges_initialized = true; 331 g_custom_id_ranges_initialized = true;
311 SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST, 332 SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST,
312 IDC_CONTENT_CONTEXT_CUSTOM_LAST); 333 IDC_CONTENT_CONTEXT_CUSTOM_LAST);
313 } 334 }
314 set_content_type(ContextMenuContentTypeFactory::Create( 335 set_content_type(ContextMenuContentTypeFactory::Create(
315 source_web_contents_, params)); 336 source_web_contents_, params));
316 } 337 }
317 338
318 RenderViewContextMenu::~RenderViewContextMenu() { 339 RenderViewContextMenu::~RenderViewContextMenu() {
319 } 340 }
320 341
321 // Menu construction functions ------------------------------------------------- 342 // Menu construction functions -------------------------------------------------
322 343
323 static bool ExtensionPatternMatch(const extensions::URLPatternSet& patterns,
324 const GURL& url) {
325 // No patterns means no restriction, so that implicitly matches.
326 if (patterns.is_empty())
327 return true;
328 return patterns.MatchesURL(url);
329 }
330
331 // static 344 // static
332 bool RenderViewContextMenu::ExtensionContextAndPatternMatch( 345 bool RenderViewContextMenu::ExtensionContextAndPatternMatch(
333 const content::ContextMenuParams& params, 346 const content::ContextMenuParams& params,
334 MenuItem::ContextList contexts, 347 const MenuItem::ContextList& contexts,
lazyboy 2014/08/17 15:23:28 FYI, ContextList provides a copy constructor, this
Lei Zhang 2014/08/18 22:56:25 I don't see a reason to make a copy. Also, when we
335 const extensions::URLPatternSet& target_url_patterns) { 348 const extensions::URLPatternSet& target_url_patterns) {
336 const bool has_link = !params.link_url.is_empty(); 349 const bool has_link = !params.link_url.is_empty();
337 const bool has_selection = !params.selection_text.empty(); 350 const bool has_selection = !params.selection_text.empty();
338 const bool in_frame = !params.frame_url.is_empty(); 351 const bool in_frame = !params.frame_url.is_empty();
339 352
340 if (contexts.Contains(MenuItem::ALL) || 353 if (contexts.Contains(MenuItem::ALL) ||
341 (has_selection && contexts.Contains(MenuItem::SELECTION)) || 354 (has_selection && contexts.Contains(MenuItem::SELECTION)) ||
342 (params.is_editable && contexts.Contains(MenuItem::EDITABLE)) || 355 (params.is_editable && contexts.Contains(MenuItem::EDITABLE)) ||
343 (in_frame && contexts.Contains(MenuItem::FRAME))) 356 (in_frame && contexts.Contains(MenuItem::FRAME)))
344 return true; 357 return true;
(...skipping 29 matching lines...) Expand all
374 // other contexts apply (except for FRAME, which is included in PAGE for 387 // other contexts apply (except for FRAME, which is included in PAGE for
375 // backwards compatibility). 388 // backwards compatibility).
376 if (!has_link && !has_selection && !params.is_editable && 389 if (!has_link && !has_selection && !params.is_editable &&
377 params.media_type == WebContextMenuData::MediaTypeNone && 390 params.media_type == WebContextMenuData::MediaTypeNone &&
378 contexts.Contains(MenuItem::PAGE)) 391 contexts.Contains(MenuItem::PAGE))
379 return true; 392 return true;
380 393
381 return false; 394 return false;
382 } 395 }
383 396
384 static const GURL& GetDocumentURL(const content::ContextMenuParams& params) {
385 return params.frame_url.is_empty() ? params.page_url : params.frame_url;
386 }
387
388 // static 397 // static
389 bool RenderViewContextMenu::MenuItemMatchesParams( 398 bool RenderViewContextMenu::MenuItemMatchesParams(
390 const content::ContextMenuParams& params, 399 const content::ContextMenuParams& params,
391 const extensions::MenuItem* item) { 400 const extensions::MenuItem* item) {
392 bool match = ExtensionContextAndPatternMatch(params, item->contexts(), 401 bool match = ExtensionContextAndPatternMatch(params, item->contexts(),
393 item->target_url_patterns()); 402 item->target_url_patterns());
394 if (!match) 403 if (!match)
395 return false; 404 return false;
396 405
397 const GURL& document_url = GetDocumentURL(params); 406 const GURL& document_url = GetDocumentURL(params);
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 837
829 base::TrimWhitespace(params_.selection_text, base::TRIM_ALL, 838 base::TrimWhitespace(params_.selection_text, base::TRIM_ALL,
830 &params_.selection_text); 839 &params_.selection_text);
831 if (params_.selection_text.empty()) 840 if (params_.selection_text.empty())
832 return; 841 return;
833 842
834 base::ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars, 843 base::ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars,
835 base::ASCIIToUTF16(" "), &params_.selection_text); 844 base::ASCIIToUTF16(" "), &params_.selection_text);
836 845
837 AutocompleteMatch match; 846 AutocompleteMatch match;
838 AutocompleteClassifierFactory::GetForProfile(GetProfile()) 847 AutocompleteClassifierFactory::GetForProfile(GetProfile())->Classify(
839 ->Classify(params_.selection_text, 848 params_.selection_text,
840 false, 849 false,
841 false, 850 false,
842 metrics::OmniboxEventProto::INVALID_SPEC, 851 metrics::OmniboxEventProto::INVALID_SPEC,
843 &match, 852 &match,
844 NULL); 853 NULL);
845 selection_navigation_url_ = match.destination_url; 854 selection_navigation_url_ = match.destination_url;
846 if (!selection_navigation_url_.is_valid()) 855 if (!selection_navigation_url_.is_valid())
847 return; 856 return;
848 857
849 base::string16 printable_selection_text = PrintableSelectionText(); 858 base::string16 printable_selection_text = PrintableSelectionText();
850 EscapeAmpersands(&printable_selection_text); 859 EscapeAmpersands(&printable_selection_text);
851 860
852 if (AutocompleteMatch::IsSearchType(match.type)) { 861 if (AutocompleteMatch::IsSearchType(match.type)) {
853 const TemplateURL* const default_provider = 862 const TemplateURL* const default_provider =
854 TemplateURLServiceFactory::GetForProfile(GetProfile()) 863 TemplateURLServiceFactory::GetForProfile(GetProfile())
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 NOTREACHED(); 1251 NOTREACHED();
1243 return false; 1252 return false;
1244 } 1253 }
1245 } 1254 }
1246 1255
1247 bool RenderViewContextMenu::IsCommandIdChecked(int id) const { 1256 bool RenderViewContextMenu::IsCommandIdChecked(int id) const {
1248 if (RenderViewContextMenuBase::IsCommandIdChecked(id)) 1257 if (RenderViewContextMenuBase::IsCommandIdChecked(id))
1249 return true; 1258 return true;
1250 1259
1251 // See if the video is set to looping. 1260 // See if the video is set to looping.
1252 if (id == IDC_CONTENT_CONTEXT_LOOP) { 1261 if (id == IDC_CONTENT_CONTEXT_LOOP)
1253 return (params_.media_flags & 1262 return (params_.media_flags & WebContextMenuData::MediaLoop) != 0;
1254 WebContextMenuData::MediaLoop) != 0;
1255 }
1256 1263
1257 if (id == IDC_CONTENT_CONTEXT_CONTROLS) { 1264 if (id == IDC_CONTENT_CONTEXT_CONTROLS)
1258 return (params_.media_flags & 1265 return (params_.media_flags & WebContextMenuData::MediaControls) != 0;
1259 WebContextMenuData::MediaControls) != 0;
1260 }
1261 1266
1262 // Extension items. 1267 // Extension items.
1263 if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) 1268 if (ContextMenuMatcher::IsExtensionsCustomCommandId(id))
1264 return extension_items_.IsCommandIdChecked(id); 1269 return extension_items_.IsCommandIdChecked(id);
1265 1270
1266 return false; 1271 return false;
1267 } 1272 }
1268 1273
1269 void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { 1274 void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
1270 RenderViewContextMenuBase::ExecuteCommand(id, event_flags); 1275 RenderViewContextMenuBase::ExecuteCommand(id, event_flags);
1271 if (command_executed_) 1276 if (command_executed_)
1272 return; 1277 return;
1273 command_executed_ = true; 1278 command_executed_ = true;
1274 1279
1275 RenderFrameHost* render_frame_host = GetRenderFrameHost(); 1280 RenderFrameHost* render_frame_host = GetRenderFrameHost();
1276 1281
1277 // Process extension menu items. 1282 // Process extension menu items.
1278 if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) { 1283 if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) {
1279 extension_items_.ExecuteCommand(id, source_web_contents_, params_); 1284 extension_items_.ExecuteCommand(id, source_web_contents_, params_);
1280 return; 1285 return;
1281 } 1286 }
1282 1287
1283 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 1288 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
1284 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 1289 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
1285 ProtocolHandlerRegistry::ProtocolHandlerList handlers = 1290 ProtocolHandlerRegistry::ProtocolHandlerList handlers =
1286 GetHandlersForLinkUrl(); 1291 GetHandlersForLinkUrl();
1287 if (handlers.empty()) { 1292 if (handlers.empty())
1288 return; 1293 return;
1289 } 1294
1290 content::RecordAction( 1295 content::RecordAction(
1291 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Open")); 1296 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Open"));
1292 int handlerIndex = id - IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; 1297 int handlerIndex = id - IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST;
1293 WindowOpenDisposition disposition = 1298 WindowOpenDisposition disposition =
1294 ForceNewTabDispositionFromEventFlags(event_flags); 1299 ForceNewTabDispositionFromEventFlags(event_flags);
1295 OpenURL( 1300 OpenURL(handlers[handlerIndex].TranslateUrl(params_.link_url),
1296 handlers[handlerIndex].TranslateUrl(params_.link_url), 1301 GetDocumentURL(params_),
1297 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1302 disposition,
1298 disposition, content::PAGE_TRANSITION_LINK); 1303 content::PAGE_TRANSITION_LINK);
1299 return; 1304 return;
1300 } 1305 }
1301 1306
1302 switch (id) { 1307 switch (id) {
1303 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: { 1308 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: {
1304 Browser* browser = 1309 Browser* browser =
1305 chrome::FindBrowserWithWebContents(source_web_contents_); 1310 chrome::FindBrowserWithWebContents(source_web_contents_);
1306 OpenURL( 1311 OpenURL(params_.link_url,
1307 params_.link_url, 1312 GetDocumentURL(params_),
1308 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1313 !browser || browser->is_app() ?
1309 !browser || browser->is_app() ?
1310 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB, 1314 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB,
1311 content::PAGE_TRANSITION_LINK); 1315 content::PAGE_TRANSITION_LINK);
1312 break; 1316 break;
1313 } 1317 }
1314 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: 1318 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW:
1315 OpenURL( 1319 OpenURL(params_.link_url,
1316 params_.link_url, 1320 GetDocumentURL(params_),
1317 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1321 NEW_WINDOW,
1318 NEW_WINDOW, content::PAGE_TRANSITION_LINK); 1322 content::PAGE_TRANSITION_LINK);
1319 break; 1323 break;
1320 1324
1321 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: 1325 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD:
1322 OpenURL(params_.link_url, GURL(), OFF_THE_RECORD, 1326 OpenURL(params_.link_url, GURL(), OFF_THE_RECORD,
1323 content::PAGE_TRANSITION_LINK); 1327 content::PAGE_TRANSITION_LINK);
1324 break; 1328 break;
1325 1329
1326 case IDC_CONTENT_CONTEXT_SAVELINKAS: { 1330 case IDC_CONTENT_CONTEXT_SAVELINKAS: {
1327 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); 1331 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU);
1328 const GURL& url = params_.link_url; 1332 const GURL& url = params_.link_url;
1329 const GURL& referring_url = 1333 content::Referrer referrer = CreateSaveAsReferrer(params_);
1330 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1331 content::Referrer referrer = content::Referrer::SanitizeForRequest(
1332 url,
1333 content::Referrer(referring_url.GetAsReferrer(),
1334 params_.referrer_policy));
1335 DownloadManager* dlm = 1334 DownloadManager* dlm =
1336 BrowserContext::GetDownloadManager(browser_context_); 1335 BrowserContext::GetDownloadManager(browser_context_);
1337 scoped_ptr<DownloadUrlParameters> dl_params( 1336 scoped_ptr<DownloadUrlParameters> dl_params(
1338 DownloadUrlParameters::FromWebContents(source_web_contents_, url)); 1337 DownloadUrlParameters::FromWebContents(source_web_contents_, url));
1339 dl_params->set_referrer(referrer); 1338 dl_params->set_referrer(referrer);
1340 dl_params->set_referrer_encoding(params_.frame_charset); 1339 dl_params->set_referrer_encoding(params_.frame_charset);
1341 dl_params->set_suggested_name(params_.suggested_filename); 1340 dl_params->set_suggested_name(params_.suggested_filename);
1342 dl_params->set_prompt(true); 1341 dl_params->set_prompt(true);
1343 dlm->DownloadUrl(dl_params.Pass()); 1342 dlm->DownloadUrl(dl_params.Pass());
1344 break; 1343 break;
1345 } 1344 }
1346 1345
1347 case IDC_CONTENT_CONTEXT_SAVEAVAS: 1346 case IDC_CONTENT_CONTEXT_SAVEAVAS:
1348 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { 1347 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: {
1349 if (params_.media_type == WebContextMenuData::MediaTypeCanvas) { 1348 if (params_.media_type == WebContextMenuData::MediaTypeCanvas) {
1350 source_web_contents_->GetRenderViewHost()->SaveImageAt( 1349 source_web_contents_->GetRenderViewHost()->SaveImageAt(
1351 params_.x, params_.y); 1350 params_.x, params_.y);
1352 } else { 1351 } else {
1353 // TODO(zino): We can use SaveImageAt() like a case of canvas. 1352 // TODO(zino): We can use SaveImageAt() like a case of canvas.
1354 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); 1353 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU);
1355 const GURL& url = params_.src_url; 1354 const GURL& url = params_.link_url;
1356 const GURL& referring_url = 1355 content::Referrer referrer = CreateSaveAsReferrer(params_);
1357 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1358 content::Referrer referrer = content::Referrer::SanitizeForRequest(
1359 url,
1360 content::Referrer(referring_url.GetAsReferrer(),
1361 params_.referrer_policy));
1362 source_web_contents_->SaveFrame(url, referrer); 1356 source_web_contents_->SaveFrame(url, referrer);
1363 } 1357 }
1364 break; 1358 break;
1365 } 1359 }
1366 1360
1367 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: 1361 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION:
1368 WriteURLToClipboard(params_.unfiltered_link_url); 1362 WriteURLToClipboard(params_.unfiltered_link_url);
1369 break; 1363 break;
1370 1364
1371 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: 1365 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION:
1372 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: 1366 case IDC_CONTENT_CONTEXT_COPYAVLOCATION:
1373 WriteURLToClipboard(params_.src_url); 1367 WriteURLToClipboard(params_.src_url);
1374 break; 1368 break;
1375 1369
1376 case IDC_CONTENT_CONTEXT_COPYIMAGE: 1370 case IDC_CONTENT_CONTEXT_COPYIMAGE:
1377 CopyImageAt(params_.x, params_.y); 1371 CopyImageAt(params_.x, params_.y);
1378 break; 1372 break;
1379 1373
1380 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: 1374 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE:
1381 GetImageThumbnailForSearch(); 1375 GetImageThumbnailForSearch();
1382 break; 1376 break;
1383 1377
1384 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: 1378 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB:
1385 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: 1379 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB:
1386 OpenURL( 1380 OpenURL(params_.src_url,
1387 params_.src_url, 1381 GetDocumentURL(params_),
1388 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1382 NEW_BACKGROUND_TAB,
1389 NEW_BACKGROUND_TAB, content::PAGE_TRANSITION_LINK); 1383 content::PAGE_TRANSITION_LINK);
1390 break; 1384 break;
1391 1385
1392 case IDC_CONTENT_CONTEXT_PLAYPAUSE: { 1386 case IDC_CONTENT_CONTEXT_PLAYPAUSE: {
1393 bool play = !!(params_.media_flags & WebContextMenuData::MediaPaused); 1387 bool play = !!(params_.media_flags & WebContextMenuData::MediaPaused);
1394 if (play) { 1388 if (play) {
1395 content::RecordAction(UserMetricsAction("MediaContextMenu_Play")); 1389 content::RecordAction(UserMetricsAction("MediaContextMenu_Play"));
1396 } else { 1390 } else {
1397 content::RecordAction(UserMetricsAction("MediaContextMenu_Pause")); 1391 content::RecordAction(UserMetricsAction("MediaContextMenu_Pause"));
1398 } 1392 }
1399 MediaPlayerActionAt(gfx::Point(params_.x, params_.y), 1393 MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
(...skipping 30 matching lines...) Expand all
1430 WebMediaPlayerAction( 1424 WebMediaPlayerAction(
1431 WebMediaPlayerAction::Controls, 1425 WebMediaPlayerAction::Controls,
1432 !IsCommandIdChecked(IDC_CONTENT_CONTEXT_CONTROLS))); 1426 !IsCommandIdChecked(IDC_CONTENT_CONTEXT_CONTROLS)));
1433 break; 1427 break;
1434 1428
1435 case IDC_CONTENT_CONTEXT_ROTATECW: 1429 case IDC_CONTENT_CONTEXT_ROTATECW:
1436 content::RecordAction( 1430 content::RecordAction(
1437 UserMetricsAction("PluginContextMenu_RotateClockwise")); 1431 UserMetricsAction("PluginContextMenu_RotateClockwise"));
1438 PluginActionAt( 1432 PluginActionAt(
1439 gfx::Point(params_.x, params_.y), 1433 gfx::Point(params_.x, params_.y),
1440 WebPluginAction( 1434 WebPluginAction(WebPluginAction::Rotate90Clockwise, true));
1441 WebPluginAction::Rotate90Clockwise,
1442 true));
1443 break; 1435 break;
1444 1436
1445 case IDC_CONTENT_CONTEXT_ROTATECCW: 1437 case IDC_CONTENT_CONTEXT_ROTATECCW:
1446 content::RecordAction( 1438 content::RecordAction(
1447 UserMetricsAction("PluginContextMenu_RotateCounterclockwise")); 1439 UserMetricsAction("PluginContextMenu_RotateCounterclockwise"));
1448 PluginActionAt( 1440 PluginActionAt(
1449 gfx::Point(params_.x, params_.y), 1441 gfx::Point(params_.x, params_.y),
1450 WebPluginAction( 1442 WebPluginAction(WebPluginAction::Rotate90Counterclockwise, true));
1451 WebPluginAction::Rotate90Counterclockwise,
1452 true));
1453 break; 1443 break;
1454 1444
1455 case IDC_BACK: 1445 case IDC_BACK:
1456 source_web_contents_->GetController().GoBack(); 1446 source_web_contents_->GetController().GoBack();
1457 break; 1447 break;
1458 1448
1459 case IDC_FORWARD: 1449 case IDC_FORWARD:
1460 source_web_contents_->GetController().GoForward(); 1450 source_web_contents_->GetController().GoForward();
1461 break; 1451 break;
1462 1452
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 source_web_contents_->GetRenderViewHost()-> 1776 source_web_contents_->GetRenderViewHost()->
1787 ExecuteMediaPlayerActionAtLocation(location, action); 1777 ExecuteMediaPlayerActionAtLocation(location, action);
1788 } 1778 }
1789 1779
1790 void RenderViewContextMenu::PluginActionAt( 1780 void RenderViewContextMenu::PluginActionAt(
1791 const gfx::Point& location, 1781 const gfx::Point& location,
1792 const WebPluginAction& action) { 1782 const WebPluginAction& action) {
1793 source_web_contents_->GetRenderViewHost()-> 1783 source_web_contents_->GetRenderViewHost()->
1794 ExecutePluginActionAtLocation(location, action); 1784 ExecutePluginActionAtLocation(location, action);
1795 } 1785 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698