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

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

Issue 10918103: 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, 3 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 if (page_url.SchemeIs("chrome-extension") && 218 if (page_url.SchemeIs("chrome-extension") &&
219 page_url.DomainIs(kFileBrowserDomain)) 219 page_url.DomainIs(kFileBrowserDomain))
220 return false; 220 return false;
221 #endif 221 #endif
222 222
223 return true; 223 return true;
224 } 224 }
225 } // namespace 225 } // namespace
226 226
227 // static 227 // static
228 const size_t RenderViewContextMenu::kMaxExtensionItemTitleLength = 75;
229 // static
230 const size_t RenderViewContextMenu::kMaxSelectionTextLength = 50; 228 const size_t RenderViewContextMenu::kMaxSelectionTextLength = 50;
231 229
232 // static 230 // static
233 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) { 231 bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) {
234 return url.SchemeIs(chrome::kChromeDevToolsScheme) && 232 return url.SchemeIs(chrome::kChromeDevToolsScheme) &&
235 url.host() == chrome::kChromeUIDevToolsHost; 233 url.host() == chrome::kChromeUIDevToolsHost;
236 } 234 }
237 235
238 // static 236 // static
239 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) { 237 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) {
240 if (!url.SchemeIs(chrome::kChromeUIScheme)) 238 if (!url.SchemeIs(chrome::kChromeUIScheme))
241 return false; 239 return false;
242 return url.host() == chrome::kChromeUISyncResourcesHost; 240 return url.host() == chrome::kChromeUISyncResourcesHost;
243 } 241 }
244 242
245 static const int kSpellcheckRadioGroup = 1; 243 static const int kSpellcheckRadioGroup = 1;
246 244
247 RenderViewContextMenu::RenderViewContextMenu( 245 RenderViewContextMenu::RenderViewContextMenu(
248 WebContents* web_contents, 246 WebContents* web_contents,
249 const content::ContextMenuParams& params) 247 const content::ContextMenuParams& params)
250 : params_(params), 248 : params_(params),
251 source_web_contents_(web_contents), 249 source_web_contents_(web_contents),
252 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), 250 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
253 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)), 251 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)),
252 menu_manager_(profile_, this, &menu_model_,
253 base::Bind(MenuItemMatchesParams, params_)),
254 external_(false), 254 external_(false),
255 ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_submenu_model_(this)), 255 ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_submenu_model_(this)),
256 ALLOW_THIS_IN_INITIALIZER_LIST(bidi_submenu_model_(this)), 256 ALLOW_THIS_IN_INITIALIZER_LIST(bidi_submenu_model_(this)),
257 ALLOW_THIS_IN_INITIALIZER_LIST(protocol_handler_submenu_model_(this)), 257 ALLOW_THIS_IN_INITIALIZER_LIST(protocol_handler_submenu_model_(this)),
258 protocol_handler_registry_(profile_->GetProtocolHandlerRegistry()) { 258 protocol_handler_registry_(profile_->GetProtocolHandlerRegistry()) {
259 } 259 }
260 260
261 RenderViewContextMenu::~RenderViewContextMenu() { 261 RenderViewContextMenu::~RenderViewContextMenu() {
262 } 262 }
263 263
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 contexts.Contains(MenuItem::PAGE)) 330 contexts.Contains(MenuItem::PAGE))
331 return true; 331 return true;
332 332
333 return false; 333 return false;
334 } 334 }
335 335
336 static const GURL& GetDocumentURL(const content::ContextMenuParams& params) { 336 static const GURL& GetDocumentURL(const content::ContextMenuParams& params) {
337 return params.frame_url.is_empty() ? params.page_url : params.frame_url; 337 return params.frame_url.is_empty() ? params.page_url : params.frame_url;
338 } 338 }
339 339
340 // Given a list of items, returns the ones that match given the contents
341 // of |params| and the profile.
342 // static 340 // static
343 MenuItem::List RenderViewContextMenu::GetRelevantExtensionItems( 341 bool RenderViewContextMenu::MenuItemMatchesParams(
344 const MenuItem::List& items,
345 const content::ContextMenuParams& params, 342 const content::ContextMenuParams& params,
346 Profile* profile, 343 const extensions::MenuItem* item) {
347 bool can_cross_incognito) { 344 bool match = ExtensionContextAndPatternMatch(params, item->contexts(),
348 MenuItem::List result; 345 item->target_url_patterns());
349 for (MenuItem::List::const_iterator i = items.begin(); 346 if (!match)
350 i != items.end(); ++i) { 347 return false;
351 const MenuItem* item = *i;
352 348
353 if (!ExtensionContextAndPatternMatch(params, item->contexts(), 349 const GURL& document_url = GetDocumentURL(params);
354 item->target_url_patterns())) 350 return ExtensionPatternMatch(item->document_url_patterns(), document_url);
355 continue;
356
357 const GURL& document_url = GetDocumentURL(params);
358 if (!ExtensionPatternMatch(item->document_url_patterns(), document_url))
359 continue;
360
361 if (item->id().incognito == profile->IsOffTheRecord() ||
362 can_cross_incognito)
363 result.push_back(*i);
364 }
365 return result;
366 }
367
368 void RenderViewContextMenu::AppendExtensionItems(
369 const std::string& extension_id, int* index) {
370 ExtensionService* service = profile_->GetExtensionService();
371 MenuManager* manager = service->menu_manager();
372 const Extension* extension = service->GetExtensionById(extension_id, false);
373 DCHECK_GE(*index, 0);
374 int max_index =
375 IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST - IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST;
376 if (!extension || *index >= max_index)
377 return;
378
379 // Find matching items.
380 const MenuItem::List* all_items = manager->MenuItems(extension_id);
381 if (!all_items || all_items->empty())
382 return;
383 bool can_cross_incognito = service->CanCrossIncognito(extension);
384 MenuItem::List items =
385 GetRelevantExtensionItems(*all_items, params_, profile_,
386 can_cross_incognito);
387 if (items.empty())
388 return;
389
390 // If this is the first extension-provided menu item, and there are other
391 // items in the menu, add a separator.
392 if (*index == 0 && menu_model_.GetItemCount())
393 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
394
395 // Extensions (other than platform apps) are only allowed one top-level slot
396 // (and it can't be a radio or checkbox item because we are going to put the
397 // extension icon next to it).
398 // If they have more than that, we automatically push them into a submenu.
399 if (extension->is_platform_app()) {
400 RecursivelyAppendExtensionItems(items, can_cross_incognito, &menu_model_,
401 index);
402 } else {
403 int menu_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + (*index)++;
404 string16 title;
405 MenuItem::List submenu_items;
406
407 if (items.size() > 1 || items[0]->type() != MenuItem::NORMAL) {
408 title = UTF8ToUTF16(extension->name());
409 submenu_items = items;
410 } else {
411 MenuItem* item = items[0];
412 extension_item_map_[menu_id] = item->id();
413 title = item->TitleWithReplacement(PrintableSelectionText(),
414 kMaxExtensionItemTitleLength);
415 submenu_items = GetRelevantExtensionItems(item->children(), params_,
416 profile_, can_cross_incognito);
417 }
418
419 // Now add our item(s) to the menu_model_.
420 if (submenu_items.empty()) {
421 menu_model_.AddItem(menu_id, title);
422 } else {
423 ui::SimpleMenuModel* submenu = new ui::SimpleMenuModel(this);
424 extension_menu_models_.push_back(submenu);
425 menu_model_.AddSubMenu(menu_id, title, submenu);
426 RecursivelyAppendExtensionItems(submenu_items, can_cross_incognito,
427 submenu, index);
428 }
429 SetExtensionIcon(extension_id);
430 }
431 }
432
433 void RenderViewContextMenu::RecursivelyAppendExtensionItems(
434 const MenuItem::List& items,
435 bool can_cross_incognito,
436 ui::SimpleMenuModel* menu_model,
437 int* index) {
438 string16 selection_text = PrintableSelectionText();
439 MenuItem::Type last_type = MenuItem::NORMAL;
440 int radio_group_id = 1;
441
442 for (MenuItem::List::const_iterator i = items.begin();
443 i != items.end(); ++i) {
444 MenuItem* item = *i;
445
446 // If last item was of type radio but the current one isn't, auto-insert
447 // a separator. The converse case is handled below.
448 if (last_type == MenuItem::RADIO &&
449 item->type() != MenuItem::RADIO) {
450 menu_model->AddSeparator(ui::NORMAL_SEPARATOR);
451 last_type = MenuItem::SEPARATOR;
452 }
453
454 int menu_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + (*index)++;
455 if (menu_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST)
456 return;
457 extension_item_map_[menu_id] = item->id();
458 string16 title = item->TitleWithReplacement(selection_text,
459 kMaxExtensionItemTitleLength);
460 if (item->type() == MenuItem::NORMAL) {
461 MenuItem::List children =
462 GetRelevantExtensionItems(item->children(), params_,
463 profile_, can_cross_incognito);
464 if (children.empty()) {
465 menu_model->AddItem(menu_id, title);
466 } else {
467 ui::SimpleMenuModel* submenu = new ui::SimpleMenuModel(this);
468 extension_menu_models_.push_back(submenu);
469 menu_model->AddSubMenu(menu_id, title, submenu);
470 RecursivelyAppendExtensionItems(children, can_cross_incognito,
471 submenu, index);
472 }
473 } else if (item->type() == MenuItem::CHECKBOX) {
474 menu_model->AddCheckItem(menu_id, title);
475 } else if (item->type() == MenuItem::RADIO) {
476 if (i != items.begin() &&
477 last_type != MenuItem::RADIO) {
478 radio_group_id++;
479
480 // Auto-append a separator if needed.
481 if (last_type != MenuItem::SEPARATOR)
482 menu_model->AddSeparator(ui::NORMAL_SEPARATOR);
483 }
484
485 menu_model->AddRadioItem(menu_id, title, radio_group_id);
486 } else if (item->type() == MenuItem::SEPARATOR) {
487 if (i != items.begin() && last_type != MenuItem::SEPARATOR) {
488 menu_model->AddSeparator(ui::NORMAL_SEPARATOR);
489 }
490 }
491 last_type = item->type();
492 }
493 }
494
495 void RenderViewContextMenu::SetExtensionIcon(const std::string& extension_id) {
496 ExtensionService* service = profile_->GetExtensionService();
497 MenuManager* menu_manager = service->menu_manager();
498
499 int index = menu_model_.GetItemCount() - 1;
500 DCHECK_GE(index, 0);
501
502 const SkBitmap& icon = menu_manager->GetIconForExtension(extension_id);
503 DCHECK(icon.width() == gfx::kFaviconSize);
504 DCHECK(icon.height() == gfx::kFaviconSize);
505
506 menu_model_.SetIcon(index, gfx::Image(icon));
507 } 351 }
508 352
509 void RenderViewContextMenu::AppendAllExtensionItems() { 353 void RenderViewContextMenu::AppendAllExtensionItems() {
510 extension_item_map_.clear(); 354 menu_manager_.Clear();
511 ExtensionService* service = profile_->GetExtensionService(); 355 ExtensionService* service = profile_->GetExtensionService();
512 if (!service) 356 if (!service)
513 return; // In unit-tests, we may not have an ExtensionService. 357 return; // In unit-tests, we may not have an ExtensionService.
514 MenuManager* menu_manager = service->menu_manager(); 358 MenuManager* menu_manager = service->menu_manager();
515 359
516 // Get a list of extension id's that have context menu items, and sort it by 360 // Get a list of extension id's that have context menu items, and sort it by
517 // the extension's name. 361 // the extension's name.
518 std::set<std::string> ids = menu_manager->ExtensionIds(); 362 std::set<std::string> ids = menu_manager->ExtensionIds();
519 std::vector<std::pair<std::string, std::string> > sorted_ids; 363 std::vector<std::pair<std::string, std::string> > sorted_ids;
520 for (std::set<std::string>::iterator i = ids.begin(); i != ids.end(); ++i) { 364 for (std::set<std::string>::iterator i = ids.begin(); i != ids.end(); ++i) {
521 const Extension* extension = service->GetExtensionById(*i, false); 365 const Extension* extension = service->GetExtensionById(*i, false);
522 // Platform apps have their context menus created directly in 366 // Platform apps have their context menus created directly in
523 // AppendPlatformAppItems. 367 // AppendPlatformAppItems.
524 if (extension && !extension->is_platform_app()) 368 if (extension && !extension->is_platform_app())
525 sorted_ids.push_back( 369 sorted_ids.push_back(
526 std::pair<std::string, std::string>(extension->name(), *i)); 370 std::pair<std::string, std::string>(extension->name(), *i));
527 } 371 }
528 // TODO(asargent) - See if this works properly for i18n names (bug 32363). 372 // TODO(asargent) - See if this works properly for i18n names (bug 32363).
529 std::sort(sorted_ids.begin(), sorted_ids.end()); 373 std::sort(sorted_ids.begin(), sorted_ids.end());
530 374
531 if (sorted_ids.empty()) 375 if (sorted_ids.empty())
532 return; 376 return;
533 377
534 int index = 0; 378 int index = 0;
535 base::TimeTicks begin = base::TimeTicks::Now(); 379 base::TimeTicks begin = base::TimeTicks::Now();
536 std::vector<std::pair<std::string, std::string> >::const_iterator i; 380 std::vector<std::pair<std::string, std::string> >::const_iterator i;
537 for (i = sorted_ids.begin(); 381 for (i = sorted_ids.begin();
538 i != sorted_ids.end(); ++i) { 382 i != sorted_ids.end(); ++i) {
539 AppendExtensionItems(i->second, &index); 383 menu_manager_.AppendExtensionItems(i->second, PrintableSelectionText(),
384 &index);
540 } 385 }
541 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime", 386 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime",
542 base::TimeTicks::Now() - begin); 387 base::TimeTicks::Now() - begin);
543 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index); 388 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index);
544 } 389 }
545 390
546 void RenderViewContextMenu::InitMenu() { 391 void RenderViewContextMenu::InitMenu() {
547 chrome::ViewType view_type = chrome::GetViewType(source_web_contents_); 392 chrome::ViewType view_type = chrome::GetViewType(source_web_contents_);
548 if (view_type == chrome::VIEW_TYPE_APP_SHELL) { 393 if (view_type == chrome::VIEW_TYPE_APP_SHELL) {
549 AppendPlatformAppItems(); 394 AppendPlatformAppItems();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 505
661 bool has_selection = !params_.selection_text.empty(); 506 bool has_selection = !params_.selection_text.empty();
662 507
663 // Add undo/redo, cut/copy/paste etc for text fields 508 // Add undo/redo, cut/copy/paste etc for text fields
664 if (params_.is_editable) 509 if (params_.is_editable)
665 AppendEditableItems(); 510 AppendEditableItems();
666 else if (has_selection) 511 else if (has_selection)
667 AppendCopyItem(); 512 AppendCopyItem();
668 513
669 int index = 0; 514 int index = 0;
670 AppendExtensionItems(platform_app->id(), &index); 515 menu_manager_.AppendExtensionItems(platform_app->id(),
516 PrintableSelectionText(), &index);
671 517
672 // Add dev tools for unpacked extensions. 518 // Add dev tools for unpacked extensions.
673 if (platform_app->location() == Extension::LOAD) { 519 if (platform_app->location() == Extension::LOAD) {
674 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); 520 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD);
675 AppendDeveloperItems(); 521 AppendDeveloperItems();
676 } 522 }
677 } 523 }
678 524
679 void RenderViewContextMenu::AppendPopupExtensionItems() { 525 void RenderViewContextMenu::AppendPopupExtensionItems() {
680 bool has_selection = !params_.selection_text.empty(); 526 bool has_selection = !params_.selection_text.empty();
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 protocol_handler_submenu_model_.AddItem( 914 protocol_handler_submenu_model_.AddItem(
1069 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS, 915 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS,
1070 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH_CONFIGURE)); 916 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH_CONFIGURE));
1071 917
1072 menu_model_.AddSubMenu( 918 menu_model_.AddSubMenu(
1073 IDC_CONTENT_CONTEXT_OPENLINKWITH, 919 IDC_CONTENT_CONTEXT_OPENLINKWITH,
1074 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH), 920 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH),
1075 &protocol_handler_submenu_model_); 921 &protocol_handler_submenu_model_);
1076 } 922 }
1077 923
1078 MenuItem* RenderViewContextMenu::GetExtensionMenuItem(int id) const {
1079 MenuManager* manager = profile_->GetExtensionService()->menu_manager();
1080 std::map<int, MenuItem::Id>::const_iterator i =
1081 extension_item_map_.find(id);
1082 if (i != extension_item_map_.end()) {
1083 MenuItem* item = manager->GetItemById(i->second);
1084 if (item)
1085 return item;
1086 }
1087 return NULL;
1088 }
1089
1090 // Menu delegate functions ----------------------------------------------------- 924 // Menu delegate functions -----------------------------------------------------
1091 925
1092 bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { 926 bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
1093 // If this command is is added by one of our observers, we dispatch it to the 927 // If this command is is added by one of our observers, we dispatch it to the
1094 // observer. 928 // observer.
1095 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); 929 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_);
1096 RenderViewContextMenuObserver* observer; 930 RenderViewContextMenuObserver* observer;
1097 while ((observer = it.GetNext()) != NULL) { 931 while ((observer = it.GetNext()) != NULL) {
1098 if (observer->IsCommandIdSupported(id)) 932 if (observer->IsCommandIdSupported(id))
1099 return observer->IsCommandIdEnabled(id); 933 return observer->IsCommandIdEnabled(id);
(...skipping 19 matching lines...) Expand all
1119 953
1120 // Custom items. 954 // Custom items.
1121 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && 955 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST &&
1122 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { 956 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) {
1123 return IsCustomItemEnabled(params_.custom_items, id); 957 return IsCustomItemEnabled(params_.custom_items, id);
1124 } 958 }
1125 959
1126 // Extension items. 960 // Extension items.
1127 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 961 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
1128 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 962 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
1129 MenuItem* item = GetExtensionMenuItem(id); 963 return menu_manager_.IsCommandIdEnabled(id);
1130 // If this is the parent menu item, it is always enabled.
1131 if (!item)
1132 return true;
1133 return item->enabled();
1134 } 964 }
1135 965
1136 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 966 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
1137 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 967 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
1138 return true; 968 return true;
1139 } 969 }
1140 970
1141 IncognitoModePrefs::Availability incognito_avail = 971 IncognitoModePrefs::Availability incognito_avail =
1142 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); 972 IncognitoModePrefs::GetAvailability(profile_->GetPrefs());
1143 switch (id) { 973 switch (id) {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 1260
1431 // Custom items. 1261 // Custom items.
1432 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && 1262 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST &&
1433 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { 1263 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) {
1434 return IsCustomItemChecked(params_.custom_items, id); 1264 return IsCustomItemChecked(params_.custom_items, id);
1435 } 1265 }
1436 1266
1437 // Extension items. 1267 // Extension items.
1438 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 1268 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
1439 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 1269 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
1440 MenuItem* item = GetExtensionMenuItem(id); 1270 return menu_manager_.IsCommandIdChecked(id);
1441 if (item)
1442 return item->checked();
1443 else
1444 return false;
1445 } 1271 }
1446 1272
1447 #if defined(OS_MACOSX) 1273 #if defined(OS_MACOSX)
1448 if (id == IDC_WRITING_DIRECTION_DEFAULT) 1274 if (id == IDC_WRITING_DIRECTION_DEFAULT)
1449 return params_.writing_direction_default & 1275 return params_.writing_direction_default &
1450 WebContextMenuData::CheckableMenuItemChecked; 1276 WebContextMenuData::CheckableMenuItemChecked;
1451 if (id == IDC_WRITING_DIRECTION_RTL) 1277 if (id == IDC_WRITING_DIRECTION_RTL)
1452 return params_.writing_direction_right_to_left & 1278 return params_.writing_direction_right_to_left &
1453 WebContextMenuData::CheckableMenuItemChecked; 1279 WebContextMenuData::CheckableMenuItemChecked;
1454 if (id == IDC_WRITING_DIRECTION_LTR) 1280 if (id == IDC_WRITING_DIRECTION_LTR)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && 1315 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST &&
1490 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { 1316 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) {
1491 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; 1317 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST;
1492 rvh->ExecuteCustomContextMenuCommand(action, params_.custom_context); 1318 rvh->ExecuteCustomContextMenuCommand(action, params_.custom_context);
1493 return; 1319 return;
1494 } 1320 }
1495 1321
1496 // Process extension menu items. 1322 // Process extension menu items.
1497 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 1323 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
1498 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 1324 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
1499 MenuManager* manager = profile_->GetExtensionService()->menu_manager(); 1325 menu_manager_.ExecuteCommand(id, params_);
1500 std::map<int, MenuItem::Id>::const_iterator i =
1501 extension_item_map_.find(id);
1502 if (i != extension_item_map_.end()) {
1503 manager->ExecuteCommand(profile_, source_web_contents_, params_,
1504 i->second);
1505 }
1506 return; 1326 return;
1507 } 1327 }
1508 1328
1509 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 1329 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
1510 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 1330 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
1511 ProtocolHandlerRegistry::ProtocolHandlerList handlers = 1331 ProtocolHandlerRegistry::ProtocolHandlerList handlers =
1512 GetHandlersForLinkUrl(); 1332 GetHandlersForLinkUrl();
1513 if (handlers.empty()) { 1333 if (handlers.empty()) {
1514 return; 1334 return;
1515 } 1335 }
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 source_web_contents_->GetRenderViewHost()-> 1843 source_web_contents_->GetRenderViewHost()->
2024 ExecuteMediaPlayerActionAtLocation(location, action); 1844 ExecuteMediaPlayerActionAtLocation(location, action);
2025 } 1845 }
2026 1846
2027 void RenderViewContextMenu::PluginActionAt( 1847 void RenderViewContextMenu::PluginActionAt(
2028 const gfx::Point& location, 1848 const gfx::Point& location,
2029 const WebPluginAction& action) { 1849 const WebPluginAction& action) {
2030 source_web_contents_->GetRenderViewHost()-> 1850 source_web_contents_->GetRenderViewHost()->
2031 ExecutePluginActionAtLocation(location, action); 1851 ExecutePluginActionAtLocation(location, action);
2032 } 1852 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698