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

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

Issue 6880275: Web Introducer overview Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 7
8 #include "chrome/browser/tab_contents/render_view_context_menu.h" 8 #include "chrome/browser/tab_contents/render_view_context_menu.h"
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/page_info_window.h" 29 #include "chrome/browser/page_info_window.h"
30 #include "chrome/browser/platform_util.h" 30 #include "chrome/browser/platform_util.h"
31 #include "chrome/browser/prefs/pref_member.h" 31 #include "chrome/browser/prefs/pref_member.h"
32 #include "chrome/browser/prefs/pref_service.h" 32 #include "chrome/browser/prefs/pref_service.h"
33 #include "chrome/browser/printing/print_preview_tab_controller.h" 33 #include "chrome/browser/printing/print_preview_tab_controller.h"
34 #include "chrome/browser/profiles/profile.h" 34 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/search_engines/template_url.h" 35 #include "chrome/browser/search_engines/template_url.h"
36 #include "chrome/browser/search_engines/template_url_model.h" 36 #include "chrome/browser/search_engines/template_url_model.h"
37 #include "chrome/browser/spellcheck_host.h" 37 #include "chrome/browser/spellcheck_host.h"
38 #include "chrome/browser/spellchecker_platform_engine.h" 38 #include "chrome/browser/spellchecker_platform_engine.h"
39 #include "chrome/browser/tab_contents/introducer_handler.h"
39 #include "chrome/browser/translate/translate_prefs.h" 40 #include "chrome/browser/translate/translate_prefs.h"
40 #include "chrome/browser/translate/translate_manager.h" 41 #include "chrome/browser/translate/translate_manager.h"
41 #include "chrome/common/chrome_constants.h" 42 #include "chrome/common/chrome_constants.h"
42 #include "chrome/common/chrome_switches.h" 43 #include "chrome/common/chrome_switches.h"
43 #include "chrome/common/content_restriction.h" 44 #include "chrome/common/content_restriction.h"
44 #include "chrome/common/pref_names.h" 45 #include "chrome/common/pref_names.h"
45 #include "chrome/common/print_messages.h" 46 #include "chrome/common/print_messages.h"
46 #include "chrome/common/url_constants.h" 47 #include "chrome/common/url_constants.h"
47 #include "content/browser/child_process_security_policy.h" 48 #include "content/browser/child_process_security_policy.h"
48 #include "content/browser/renderer_host/render_view_host.h" 49 #include "content/browser/renderer_host/render_view_host.h"
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 bool has_link = !params_.link_url.is_empty(); 451 bool has_link = !params_.link_url.is_empty();
451 bool has_selection = !params_.selection_text.empty(); 452 bool has_selection = !params_.selection_text.empty();
452 453
453 if (AppendCustomItems()) { 454 if (AppendCustomItems()) {
454 // Don't add items for Pepper menu. 455 // Don't add items for Pepper menu.
455 if (!params_.custom_context.is_pepper_menu) 456 if (!params_.custom_context.is_pepper_menu)
456 AppendDeveloperItems(); 457 AppendDeveloperItems();
457 return; 458 return;
458 } 459 }
459 460
461 if (IntroducerService::InitMenu(source_tab_contents_, profile_, params_,
462 &introducer_commands_, &menu_model_)) {
463 return;
464 }
465
460 // When no special node or text is selected and selection has no link, 466 // When no special node or text is selected and selection has no link,
461 // show page items. 467 // show page items.
462 bool is_devtools = false; 468 bool is_devtools = false;
463 if (params_.media_type == WebContextMenuData::MediaTypeNone && 469 if (params_.media_type == WebContextMenuData::MediaTypeNone &&
464 !has_link && 470 !has_link &&
465 !params_.is_editable && 471 !params_.is_editable &&
466 !has_selection) { 472 !has_selection) {
467 if (!params_.page_url.is_empty()) { 473 if (!params_.page_url.is_empty()) {
468 is_devtools = IsDevToolsURL(params_.page_url); 474 is_devtools = IsDevToolsURL(params_.page_url);
469 if (!is_devtools && !IsInternalResourcesURL(params_.page_url)) { 475 if (!is_devtools && !IsInternalResourcesURL(params_.page_url)) {
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 } 868 }
863 869
864 // Extension items. 870 // Extension items.
865 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 871 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
866 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 872 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
867 // In the future we may add APIs for extensions to disable items, but for 873 // In the future we may add APIs for extensions to disable items, but for
868 // now all items are implicitly enabled. 874 // now all items are implicitly enabled.
869 return true; 875 return true;
870 } 876 }
871 877
878 // Introducer items.
879 if (id >= IDC_INTRODUCER_CONTEXT_CUSTOM_FIRST &&
880 id <= IDC_INTRODUCER_CONTEXT_CUSTOM_LAST) {
881 return true;
882 }
883
872 switch (id) { 884 switch (id) {
873 case IDC_BACK: 885 case IDC_BACK:
874 return source_tab_contents_->controller().CanGoBack(); 886 return source_tab_contents_->controller().CanGoBack();
875 887
876 case IDC_FORWARD: 888 case IDC_FORWARD:
877 return source_tab_contents_->controller().CanGoForward(); 889 return source_tab_contents_->controller().CanGoForward();
878 890
879 case IDC_RELOAD: 891 case IDC_RELOAD:
880 return source_tab_contents_->delegate() && 892 return source_tab_contents_->delegate() &&
881 source_tab_contents_->delegate()->CanReloadContents( 893 source_tab_contents_->delegate()->CanReloadContents(
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 // Extension items. 1109 // Extension items.
1098 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 1110 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
1099 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 1111 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
1100 ExtensionMenuItem* item = GetExtensionMenuItem(id); 1112 ExtensionMenuItem* item = GetExtensionMenuItem(id);
1101 if (item) 1113 if (item)
1102 return item->checked(); 1114 return item->checked();
1103 else 1115 else
1104 return false; 1116 return false;
1105 } 1117 }
1106 1118
1119 // Introducer items.
1120 if (id >= IDC_INTRODUCER_CONTEXT_CUSTOM_FIRST &&
1121 id <= IDC_INTRODUCER_CONTEXT_CUSTOM_LAST) {
1122 return false;
1123 }
1124
1107 #if defined(OS_MACOSX) 1125 #if defined(OS_MACOSX)
1108 if (id == IDC_WRITING_DIRECTION_DEFAULT) 1126 if (id == IDC_WRITING_DIRECTION_DEFAULT)
1109 return params_.writing_direction_default & 1127 return params_.writing_direction_default &
1110 WebContextMenuData::CheckableMenuItemChecked; 1128 WebContextMenuData::CheckableMenuItemChecked;
1111 if (id == IDC_WRITING_DIRECTION_RTL) 1129 if (id == IDC_WRITING_DIRECTION_RTL)
1112 return params_.writing_direction_right_to_left & 1130 return params_.writing_direction_right_to_left &
1113 WebContextMenuData::CheckableMenuItemChecked; 1131 WebContextMenuData::CheckableMenuItemChecked;
1114 if (id == IDC_WRITING_DIRECTION_LTR) 1132 if (id == IDC_WRITING_DIRECTION_LTR)
1115 return params_.writing_direction_left_to_right & 1133 return params_.writing_direction_left_to_right &
1116 WebContextMenuData::CheckableMenuItemChecked; 1134 WebContextMenuData::CheckableMenuItemChecked;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 profile_->GetExtensionService()->menu_manager(); 1185 profile_->GetExtensionService()->menu_manager();
1168 std::map<int, ExtensionMenuItem::Id>::const_iterator i = 1186 std::map<int, ExtensionMenuItem::Id>::const_iterator i =
1169 extension_item_map_.find(id); 1187 extension_item_map_.find(id);
1170 if (i != extension_item_map_.end()) { 1188 if (i != extension_item_map_.end()) {
1171 manager->ExecuteCommand(profile_, source_tab_contents_, params_, 1189 manager->ExecuteCommand(profile_, source_tab_contents_, params_,
1172 i->second); 1190 i->second);
1173 } 1191 }
1174 return; 1192 return;
1175 } 1193 }
1176 1194
1195 // Process Introducer menu items.
1196 if (id >= IDC_INTRODUCER_CONTEXT_CUSTOM_FIRST &&
1197 id <= IDC_INTRODUCER_CONTEXT_CUSTOM_LAST) {
1198 if (IntroducerService::Introduce(source_tab_contents_, profile_, params_,
1199 introducer_commands_[id])) {
1200 params_.introduction_context.request_id = 0;
1201 }
1202 return;
1203 }
1177 1204
1178 switch (id) { 1205 switch (id) {
1179 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: 1206 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB:
1180 OpenURL(params_.link_url, 1207 OpenURL(params_.link_url,
1181 source_tab_contents_->delegate() && 1208 source_tab_contents_->delegate() &&
1182 source_tab_contents_->delegate()->IsApplication() ? 1209 source_tab_contents_->delegate()->IsApplication() ?
1183 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB, 1210 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB,
1184 PageTransition::LINK); 1211 PageTransition::LINK);
1185 break; 1212 break;
1186 1213
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 1490
1464 default: 1491 default:
1465 NOTREACHED(); 1492 NOTREACHED();
1466 break; 1493 break;
1467 } 1494 }
1468 } 1495 }
1469 1496
1470 void RenderViewContextMenu::MenuClosed() { 1497 void RenderViewContextMenu::MenuClosed() {
1471 source_tab_contents_->render_view_host()->ContextMenuClosed( 1498 source_tab_contents_->render_view_host()->ContextMenuClosed(
1472 params_.custom_context); 1499 params_.custom_context);
1500 if (params_.introduction_context.request_id) {
1501 IntroducerService::Dismiss(source_tab_contents_,
1502 params_.introduction_context.request_id);
1503 }
1473 } 1504 }
1474 1505
1475 bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { 1506 bool RenderViewContextMenu::IsDevCommandEnabled(int id) const {
1476 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 1507 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
1477 if (command_line.HasSwitch(switches::kAlwaysEnableDevTools)) 1508 if (command_line.HasSwitch(switches::kAlwaysEnableDevTools))
1478 return true; 1509 return true;
1479 1510
1480 NavigationEntry *active_entry = 1511 NavigationEntry *active_entry =
1481 source_tab_contents_->controller().GetActiveEntry(); 1512 source_tab_contents_->controller().GetActiveEntry();
1482 if (!active_entry) 1513 if (!active_entry)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1569 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1539 g_browser_process->clipboard()); 1570 g_browser_process->clipboard());
1540 } 1571 }
1541 1572
1542 void RenderViewContextMenu::MediaPlayerActionAt( 1573 void RenderViewContextMenu::MediaPlayerActionAt(
1543 const gfx::Point& location, 1574 const gfx::Point& location,
1544 const WebMediaPlayerAction& action) { 1575 const WebMediaPlayerAction& action) {
1545 source_tab_contents_->render_view_host()->MediaPlayerActionAt( 1576 source_tab_contents_->render_view_host()->MediaPlayerActionAt(
1546 location, action); 1577 location, action);
1547 } 1578 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698