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

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

Issue 10984034: Revert 158691 - Give platform apps control over launcher right-click context menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <utility> 7 #include <utility>
8 8
9 #include "chrome/browser/tab_contents/render_view_context_menu.h" 9 #include "chrome/browser/tab_contents/render_view_context_menu.h"
10 10
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 if (page_url.SchemeIs("chrome-extension") && 220 if (page_url.SchemeIs("chrome-extension") &&
221 page_url.DomainIs(kFileBrowserDomain)) 221 page_url.DomainIs(kFileBrowserDomain))
222 return false; 222 return false;
223 #endif 223 #endif
224 224
225 return true; 225 return true;
226 } 226 }
227 } // namespace 227 } // namespace
228 228
229 // static 229 // static
230 const size_t RenderViewContextMenu::kMaxExtensionItemTitleLength = 75;
231 // static
230 const size_t RenderViewContextMenu::kMaxSelectionTextLength = 50; 232 const size_t RenderViewContextMenu::kMaxSelectionTextLength = 50;
231 233
232 // static 234 // static
233 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) { 235 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) {
234 return url.SchemeIs(chrome::kChromeDevToolsScheme) && 236 return url.SchemeIs(chrome::kChromeDevToolsScheme) &&
235 url.host() == chrome::kChromeUIDevToolsHost; 237 url.host() == chrome::kChromeUIDevToolsHost;
236 } 238 }
237 239
238 // static 240 // static
239 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) { 241 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) {
240 if (!url.SchemeIs(chrome::kChromeUIScheme)) 242 if (!url.SchemeIs(chrome::kChromeUIScheme))
241 return false; 243 return false;
242 return url.host() == chrome::kChromeUISyncResourcesHost; 244 return url.host() == chrome::kChromeUISyncResourcesHost;
243 } 245 }
244 246
245 static const int kSpellcheckRadioGroup = 1; 247 static const int kSpellcheckRadioGroup = 1;
246 248
247 RenderViewContextMenu::RenderViewContextMenu( 249 RenderViewContextMenu::RenderViewContextMenu(
248 WebContents* web_contents, 250 WebContents* web_contents,
249 const content::ContextMenuParams& params) 251 const content::ContextMenuParams& params)
250 : params_(params), 252 : params_(params),
251 source_web_contents_(web_contents), 253 source_web_contents_(web_contents),
252 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), 254 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
253 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)), 255 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)),
254 extension_items_(profile_, this, &menu_model_,
255 base::Bind(MenuItemMatchesParams, params_)),
256 external_(false), 256 external_(false),
257 ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_submenu_model_(this)), 257 ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_submenu_model_(this)),
258 ALLOW_THIS_IN_INITIALIZER_LIST(protocol_handler_submenu_model_(this)), 258 ALLOW_THIS_IN_INITIALIZER_LIST(protocol_handler_submenu_model_(this)),
259 protocol_handler_registry_(profile_->GetProtocolHandlerRegistry()) { 259 protocol_handler_registry_(profile_->GetProtocolHandlerRegistry()) {
260 } 260 }
261 261
262 RenderViewContextMenu::~RenderViewContextMenu() { 262 RenderViewContextMenu::~RenderViewContextMenu() {
263 } 263 }
264 264
265 // Menu construction functions ------------------------------------------------- 265 // Menu construction functions -------------------------------------------------
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 contexts.Contains(MenuItem::PAGE)) 331 contexts.Contains(MenuItem::PAGE))
332 return true; 332 return true;
333 333
334 return false; 334 return false;
335 } 335 }
336 336
337 static const GURL& GetDocumentURL(const content::ContextMenuParams& params) { 337 static const GURL& GetDocumentURL(const content::ContextMenuParams& params) {
338 return params.frame_url.is_empty() ? params.page_url : params.frame_url; 338 return params.frame_url.is_empty() ? params.page_url : params.frame_url;
339 } 339 }
340 340
341 // Given a list of items, returns the ones that match given the contents
342 // of |params| and the profile.
341 // static 343 // static
342 bool RenderViewContextMenu::MenuItemMatchesParams( 344 MenuItem::List RenderViewContextMenu::GetRelevantExtensionItems(
345 const MenuItem::List& items,
343 const content::ContextMenuParams& params, 346 const content::ContextMenuParams& params,
344 const extensions::MenuItem* item) { 347 Profile* profile,
345 bool match = ExtensionContextAndPatternMatch(params, item->contexts(), 348 bool can_cross_incognito) {
346 item->target_url_patterns()); 349 MenuItem::List result;
347 if (!match) 350 for (MenuItem::List::const_iterator i = items.begin();
348 return false; 351 i != items.end(); ++i) {
352 const MenuItem* item = *i;
349 353
350 const GURL& document_url = GetDocumentURL(params); 354 if (!ExtensionContextAndPatternMatch(params, item->contexts(),
351 return ExtensionPatternMatch(item->document_url_patterns(), document_url); 355 item->target_url_patterns()))
356 continue;
357
358 const GURL& document_url = GetDocumentURL(params);
359 if (!ExtensionPatternMatch(item->document_url_patterns(), document_url))
360 continue;
361
362 if (item->id().incognito == profile->IsOffTheRecord() ||
363 can_cross_incognito)
364 result.push_back(*i);
365 }
366 return result;
367 }
368
369 void RenderViewContextMenu::AppendExtensionItems(
370 const std::string& extension_id, int* index) {
371 ExtensionService* service = profile_->GetExtensionService();
372 MenuManager* manager = service->menu_manager();
373 const Extension* extension = service->GetExtensionById(extension_id, false);
374 DCHECK_GE(*index, 0);
375 int max_index =
376 IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST - IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST;
377 if (!extension || *index >= max_index)
378 return;
379
380 // Find matching items.
381 const MenuItem::List* all_items = manager->MenuItems(extension_id);
382 if (!all_items || all_items->empty())
383 return;
384 bool can_cross_incognito = service->CanCrossIncognito(extension);
385 MenuItem::List items =
386 GetRelevantExtensionItems(*all_items, params_, profile_,
387 can_cross_incognito);
388 if (items.empty())
389 return;
390
391 // If this is the first extension-provided menu item, and there are other
392 // items in the menu, add a separator.
393 if (*index == 0 && menu_model_.GetItemCount())
394 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
395
396 // Extensions (other than platform apps) are only allowed one top-level slot
397 // (and it can't be a radio or checkbox item because we are going to put the
398 // extension icon next to it).
399 // If they have more than that, we automatically push them into a submenu.
400 if (extension->is_platform_app()) {
401 RecursivelyAppendExtensionItems(items, can_cross_incognito, &menu_model_,
402 index);
403 } else {
404 int menu_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + (*index)++;
405 string16 title;
406 MenuItem::List submenu_items;
407
408 if (items.size() > 1 || items[0]->type() != MenuItem::NORMAL) {
409 title = UTF8ToUTF16(extension->name());
410 submenu_items = items;
411 } else {
412 MenuItem* item = items[0];
413 extension_item_map_[menu_id] = item->id();
414 title = item->TitleWithReplacement(PrintableSelectionText(),
415 kMaxExtensionItemTitleLength);
416 submenu_items = GetRelevantExtensionItems(item->children(), params_,
417 profile_, can_cross_incognito);
418 }
419
420 // Now add our item(s) to the menu_model_.
421 if (submenu_items.empty()) {
422 menu_model_.AddItem(menu_id, title);
423 } else {
424 ui::SimpleMenuModel* submenu = new ui::SimpleMenuModel(this);
425 extension_menu_models_.push_back(submenu);
426 menu_model_.AddSubMenu(menu_id, title, submenu);
427 RecursivelyAppendExtensionItems(submenu_items, can_cross_incognito,
428 submenu, index);
429 }
430 SetExtensionIcon(extension_id);
431 }
432 }
433
434 void RenderViewContextMenu::RecursivelyAppendExtensionItems(
435 const MenuItem::List& items,
436 bool can_cross_incognito,
437 ui::SimpleMenuModel* menu_model,
438 int* index) {
439 string16 selection_text = PrintableSelectionText();
440 MenuItem::Type last_type = MenuItem::NORMAL;
441 int radio_group_id = 1;
442
443 for (MenuItem::List::const_iterator i = items.begin();
444 i != items.end(); ++i) {
445 MenuItem* item = *i;
446
447 // If last item was of type radio but the current one isn't, auto-insert
448 // a separator. The converse case is handled below.
449 if (last_type == MenuItem::RADIO &&
450 item->type() != MenuItem::RADIO) {
451 menu_model->AddSeparator(ui::NORMAL_SEPARATOR);
452 last_type = MenuItem::SEPARATOR;
453 }
454
455 int menu_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + (*index)++;
456 if (menu_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST)
457 return;
458 extension_item_map_[menu_id] = item->id();
459 string16 title = item->TitleWithReplacement(selection_text,
460 kMaxExtensionItemTitleLength);
461 if (item->type() == MenuItem::NORMAL) {
462 MenuItem::List children =
463 GetRelevantExtensionItems(item->children(), params_,
464 profile_, can_cross_incognito);
465 if (children.empty()) {
466 menu_model->AddItem(menu_id, title);
467 } else {
468 ui::SimpleMenuModel* submenu = new ui::SimpleMenuModel(this);
469 extension_menu_models_.push_back(submenu);
470 menu_model->AddSubMenu(menu_id, title, submenu);
471 RecursivelyAppendExtensionItems(children, can_cross_incognito,
472 submenu, index);
473 }
474 } else if (item->type() == MenuItem::CHECKBOX) {
475 menu_model->AddCheckItem(menu_id, title);
476 } else if (item->type() == MenuItem::RADIO) {
477 if (i != items.begin() &&
478 last_type != MenuItem::RADIO) {
479 radio_group_id++;
480
481 // Auto-append a separator if needed.
482 if (last_type != MenuItem::SEPARATOR)
483 menu_model->AddSeparator(ui::NORMAL_SEPARATOR);
484 }
485
486 menu_model->AddRadioItem(menu_id, title, radio_group_id);
487 } else if (item->type() == MenuItem::SEPARATOR) {
488 if (i != items.begin() && last_type != MenuItem::SEPARATOR) {
489 menu_model->AddSeparator(ui::NORMAL_SEPARATOR);
490 }
491 }
492 last_type = item->type();
493 }
494 }
495
496 void RenderViewContextMenu::SetExtensionIcon(const std::string& extension_id) {
497 ExtensionService* service = profile_->GetExtensionService();
498 MenuManager* menu_manager = service->menu_manager();
499
500 int index = menu_model_.GetItemCount() - 1;
501 DCHECK_GE(index, 0);
502
503 const SkBitmap& icon = menu_manager->GetIconForExtension(extension_id);
504 DCHECK(icon.width() == gfx::kFaviconSize);
505 DCHECK(icon.height() == gfx::kFaviconSize);
506
507 menu_model_.SetIcon(index, gfx::Image(icon));
352 } 508 }
353 509
354 void RenderViewContextMenu::AppendAllExtensionItems() { 510 void RenderViewContextMenu::AppendAllExtensionItems() {
355 extension_items_.Clear(); 511 extension_item_map_.clear();
356 ExtensionService* service = profile_->GetExtensionService(); 512 ExtensionService* service = profile_->GetExtensionService();
357 if (!service) 513 if (!service)
358 return; // In unit-tests, we may not have an ExtensionService. 514 return; // In unit-tests, we may not have an ExtensionService.
359 MenuManager* menu_manager = service->menu_manager(); 515 MenuManager* menu_manager = service->menu_manager();
360 516
361 // Get a list of extension id's that have context menu items, and sort it by 517 // Get a list of extension id's that have context menu items, and sort it by
362 // the extension's name. 518 // the extension's name.
363 std::set<std::string> ids = menu_manager->ExtensionIds(); 519 std::set<std::string> ids = menu_manager->ExtensionIds();
364 std::vector<std::pair<std::string, std::string> > sorted_ids; 520 std::vector<std::pair<std::string, std::string> > sorted_ids;
365 for (std::set<std::string>::iterator i = ids.begin(); i != ids.end(); ++i) { 521 for (std::set<std::string>::iterator i = ids.begin(); i != ids.end(); ++i) {
366 const Extension* extension = service->GetExtensionById(*i, false); 522 const Extension* extension = service->GetExtensionById(*i, false);
367 // Platform apps have their context menus created directly in 523 // Platform apps have their context menus created directly in
368 // AppendPlatformAppItems. 524 // AppendPlatformAppItems.
369 if (extension && !extension->is_platform_app()) 525 if (extension && !extension->is_platform_app())
370 sorted_ids.push_back( 526 sorted_ids.push_back(
371 std::pair<std::string, std::string>(extension->name(), *i)); 527 std::pair<std::string, std::string>(extension->name(), *i));
372 } 528 }
373 // TODO(asargent) - See if this works properly for i18n names (bug 32363). 529 // TODO(asargent) - See if this works properly for i18n names (bug 32363).
374 std::sort(sorted_ids.begin(), sorted_ids.end()); 530 std::sort(sorted_ids.begin(), sorted_ids.end());
375 531
376 if (sorted_ids.empty()) 532 if (sorted_ids.empty())
377 return; 533 return;
378 534
379 int index = 0; 535 int index = 0;
380 base::TimeTicks begin = base::TimeTicks::Now(); 536 base::TimeTicks begin = base::TimeTicks::Now();
381 std::vector<std::pair<std::string, std::string> >::const_iterator i; 537 std::vector<std::pair<std::string, std::string> >::const_iterator i;
382 for (i = sorted_ids.begin(); 538 for (i = sorted_ids.begin();
383 i != sorted_ids.end(); ++i) { 539 i != sorted_ids.end(); ++i) {
384 extension_items_.AppendExtensionItems(i->second, PrintableSelectionText(), 540 AppendExtensionItems(i->second, &index);
385 &index);
386 } 541 }
387 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime", 542 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime",
388 base::TimeTicks::Now() - begin); 543 base::TimeTicks::Now() - begin);
389 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index); 544 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index);
390 } 545 }
391 546
392 void RenderViewContextMenu::InitMenu() { 547 void RenderViewContextMenu::InitMenu() {
393 chrome::ViewType view_type = chrome::GetViewType(source_web_contents_); 548 chrome::ViewType view_type = chrome::GetViewType(source_web_contents_);
394 if (view_type == chrome::VIEW_TYPE_APP_SHELL) { 549 if (view_type == chrome::VIEW_TYPE_APP_SHELL) {
395 AppendPlatformAppItems(); 550 AppendPlatformAppItems();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 661
507 bool has_selection = !params_.selection_text.empty(); 662 bool has_selection = !params_.selection_text.empty();
508 663
509 // Add undo/redo, cut/copy/paste etc for text fields 664 // Add undo/redo, cut/copy/paste etc for text fields
510 if (params_.is_editable) 665 if (params_.is_editable)
511 AppendEditableItems(); 666 AppendEditableItems();
512 else if (has_selection) 667 else if (has_selection)
513 AppendCopyItem(); 668 AppendCopyItem();
514 669
515 int index = 0; 670 int index = 0;
516 extension_items_.AppendExtensionItems(platform_app->id(), 671 AppendExtensionItems(platform_app->id(), &index);
517 PrintableSelectionText(), &index);
518 672
519 // Add dev tools for unpacked extensions. 673 // Add dev tools for unpacked extensions.
520 if (platform_app->location() == Extension::LOAD) { 674 if (platform_app->location() == Extension::LOAD) {
521 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); 675 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD);
522 AppendDeveloperItems(); 676 AppendDeveloperItems();
523 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE, 677 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE,
524 IDS_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE); 678 IDS_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE);
525 } 679 }
526 } 680 }
527 681
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 1052
899 menu_model_.AddSubMenu( 1053 menu_model_.AddSubMenu(
900 IDC_CONTENT_CONTEXT_OPENLINKWITH, 1054 IDC_CONTENT_CONTEXT_OPENLINKWITH,
901 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH), 1055 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH),
902 &protocol_handler_submenu_model_); 1056 &protocol_handler_submenu_model_);
903 } 1057 }
904 1058
905 void RenderViewContextMenu::AppendPlatformEditableItems() { 1059 void RenderViewContextMenu::AppendPlatformEditableItems() {
906 } 1060 }
907 1061
1062 MenuItem* RenderViewContextMenu::GetExtensionMenuItem(int id) const {
1063 MenuManager* manager = profile_->GetExtensionService()->menu_manager();
1064 std::map<int, MenuItem::Id>::const_iterator i =
1065 extension_item_map_.find(id);
1066 if (i != extension_item_map_.end()) {
1067 MenuItem* item = manager->GetItemById(i->second);
1068 if (item)
1069 return item;
1070 }
1071 return NULL;
1072 }
1073
908 // Menu delegate functions ----------------------------------------------------- 1074 // Menu delegate functions -----------------------------------------------------
909 1075
910 bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { 1076 bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
911 // If this command is is added by one of our observers, we dispatch it to the 1077 // If this command is is added by one of our observers, we dispatch it to the
912 // observer. 1078 // observer.
913 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); 1079 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_);
914 RenderViewContextMenuObserver* observer; 1080 RenderViewContextMenuObserver* observer;
915 while ((observer = it.GetNext()) != NULL) { 1081 while ((observer = it.GetNext()) != NULL) {
916 if (observer->IsCommandIdSupported(id)) 1082 if (observer->IsCommandIdSupported(id))
917 return observer->IsCommandIdEnabled(id); 1083 return observer->IsCommandIdEnabled(id);
(...skipping 19 matching lines...) Expand all
937 1103
938 // Custom items. 1104 // Custom items.
939 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && 1105 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST &&
940 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { 1106 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) {
941 return IsCustomItemEnabled(params_.custom_items, id); 1107 return IsCustomItemEnabled(params_.custom_items, id);
942 } 1108 }
943 1109
944 // Extension items. 1110 // Extension items.
945 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 1111 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
946 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 1112 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
947 return extension_items_.IsCommandIdEnabled(id); 1113 MenuItem* item = GetExtensionMenuItem(id);
1114 // If this is the parent menu item, it is always enabled.
1115 if (!item)
1116 return true;
1117 return item->enabled();
948 } 1118 }
949 1119
950 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 1120 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
951 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 1121 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
952 return true; 1122 return true;
953 } 1123 }
954 1124
955 IncognitoModePrefs::Availability incognito_avail = 1125 IncognitoModePrefs::Availability incognito_avail =
956 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); 1126 IncognitoModePrefs::GetAvailability(profile_->GetPrefs());
957 switch (id) { 1127 switch (id) {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 1404
1235 // Custom items. 1405 // Custom items.
1236 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && 1406 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST &&
1237 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { 1407 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) {
1238 return IsCustomItemChecked(params_.custom_items, id); 1408 return IsCustomItemChecked(params_.custom_items, id);
1239 } 1409 }
1240 1410
1241 // Extension items. 1411 // Extension items.
1242 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 1412 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
1243 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 1413 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
1244 return extension_items_.IsCommandIdChecked(id); 1414 MenuItem* item = GetExtensionMenuItem(id);
1415 if (item)
1416 return item->checked();
1417 else
1418 return false;
1245 } 1419 }
1246 1420
1247 #if defined(ENABLE_INPUT_SPEECH) 1421 #if defined(ENABLE_INPUT_SPEECH)
1248 // Check box for menu item 'Block offensive words'. 1422 // Check box for menu item 'Block offensive words'.
1249 if (id == IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES) { 1423 if (id == IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES) {
1250 return ChromeSpeechRecognitionPreferences::GetForProfile(profile_)-> 1424 return ChromeSpeechRecognitionPreferences::GetForProfile(profile_)->
1251 FilterProfanities(); 1425 FilterProfanities();
1252 } 1426 }
1253 #endif 1427 #endif
1254 1428
(...skipping 20 matching lines...) Expand all
1275 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && 1449 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST &&
1276 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { 1450 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) {
1277 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; 1451 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST;
1278 rvh->ExecuteCustomContextMenuCommand(action, params_.custom_context); 1452 rvh->ExecuteCustomContextMenuCommand(action, params_.custom_context);
1279 return; 1453 return;
1280 } 1454 }
1281 1455
1282 // Process extension menu items. 1456 // Process extension menu items.
1283 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 1457 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
1284 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 1458 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
1285 extension_items_.ExecuteCommand(id, params_); 1459 MenuManager* manager = profile_->GetExtensionService()->menu_manager();
1460 std::map<int, MenuItem::Id>::const_iterator i =
1461 extension_item_map_.find(id);
1462 if (i != extension_item_map_.end()) {
1463 manager->ExecuteCommand(profile_, source_web_contents_, params_,
1464 i->second);
1465 }
1286 return; 1466 return;
1287 } 1467 }
1288 1468
1289 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 1469 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
1290 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 1470 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
1291 ProtocolHandlerRegistry::ProtocolHandlerList handlers = 1471 ProtocolHandlerRegistry::ProtocolHandlerList handlers =
1292 GetHandlersForLinkUrl(); 1472 GetHandlersForLinkUrl();
1293 if (handlers.empty()) { 1473 if (handlers.empty()) {
1294 return; 1474 return;
1295 } 1475 }
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 source_web_contents_->GetRenderViewHost()-> 1978 source_web_contents_->GetRenderViewHost()->
1799 ExecuteMediaPlayerActionAtLocation(location, action); 1979 ExecuteMediaPlayerActionAtLocation(location, action);
1800 } 1980 }
1801 1981
1802 void RenderViewContextMenu::PluginActionAt( 1982 void RenderViewContextMenu::PluginActionAt(
1803 const gfx::Point& location, 1983 const gfx::Point& location,
1804 const WebPluginAction& action) { 1984 const WebPluginAction& action) {
1805 source_web_contents_->GetRenderViewHost()-> 1985 source_web_contents_->GetRenderViewHost()->
1806 ExecutePluginActionAtLocation(location, action); 1986 ExecutePluginActionAtLocation(location, action);
1807 } 1987 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.h ('k') | chrome/browser/ui/app_list/extension_app_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698