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

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

Issue 6893046: added CTRL+Click and SHIFT+Click handler for context menu, Back and Forward. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 8 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/browser/ui/browser.cc » ('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 23 matching lines...) Expand all
34 #include "chrome/browser/prefs/pref_service.h" 34 #include "chrome/browser/prefs/pref_service.h"
35 #include "chrome/browser/printing/print_preview_tab_controller.h" 35 #include "chrome/browser/printing/print_preview_tab_controller.h"
36 #include "chrome/browser/profiles/profile.h" 36 #include "chrome/browser/profiles/profile.h"
37 #include "chrome/browser/search_engines/template_url.h" 37 #include "chrome/browser/search_engines/template_url.h"
38 #include "chrome/browser/search_engines/template_url_model.h" 38 #include "chrome/browser/search_engines/template_url_model.h"
39 #include "chrome/browser/spellcheck_host.h" 39 #include "chrome/browser/spellcheck_host.h"
40 #include "chrome/browser/spellchecker_platform_engine.h" 40 #include "chrome/browser/spellchecker_platform_engine.h"
41 #include "chrome/browser/translate/translate_manager.h" 41 #include "chrome/browser/translate/translate_manager.h"
42 #include "chrome/browser/translate/translate_prefs.h" 42 #include "chrome/browser/translate/translate_prefs.h"
43 #include "chrome/browser/translate/translate_tab_helper.h" 43 #include "chrome/browser/translate/translate_tab_helper.h"
44 #include "chrome/browser/ui/browser.h"
brettw 2011/04/28 20:43:39 You can see we've been careful to never call into
45 #include "chrome/browser/ui/browser_list.h"
44 #include "chrome/browser/ui/download/download_tab_helper.h" 46 #include "chrome/browser/ui/download/download_tab_helper.h"
45 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 47 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
46 #include "chrome/common/chrome_constants.h" 48 #include "chrome/common/chrome_constants.h"
47 #include "chrome/common/chrome_switches.h" 49 #include "chrome/common/chrome_switches.h"
48 #include "chrome/common/content_restriction.h" 50 #include "chrome/common/content_restriction.h"
49 #include "chrome/common/pref_names.h" 51 #include "chrome/common/pref_names.h"
50 #include "chrome/common/print_messages.h" 52 #include "chrome/common/print_messages.h"
51 #include "chrome/common/spellcheck_messages.h" 53 #include "chrome/common/spellcheck_messages.h"
52 #include "chrome/common/url_constants.h" 54 #include "chrome/common/url_constants.h"
53 #include "content/browser/child_process_security_policy.h" 55 #include "content/browser/child_process_security_policy.h"
54 #include "content/browser/renderer_host/render_view_host.h" 56 #include "content/browser/renderer_host/render_view_host.h"
55 #include "content/browser/tab_contents/navigation_entry.h" 57 #include "content/browser/tab_contents/navigation_entry.h"
56 #include "content/browser/tab_contents/tab_contents.h" 58 #include "content/browser/tab_contents/tab_contents.h"
57 #include "grit/generated_resources.h" 59 #include "grit/generated_resources.h"
58 #include "net/base/escape.h" 60 #include "net/base/escape.h"
59 #include "net/url_request/url_request.h" 61 #include "net/url_request/url_request.h"
60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 62 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" 63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h"
62 #include "ui/base/l10n/l10n_util.h" 64 #include "ui/base/l10n/l10n_util.h"
63 #include "ui/gfx/favicon_size.h" 65 #include "ui/gfx/favicon_size.h"
64 #include "webkit/glue/webmenuitem.h" 66 #include "webkit/glue/webmenuitem.h"
67 #include "webkit/glue/window_open_disposition.h"
65 68
66 using WebKit::WebContextMenuData; 69 using WebKit::WebContextMenuData;
67 using WebKit::WebMediaPlayerAction; 70 using WebKit::WebMediaPlayerAction;
68 using WebKit::WebURL; 71 using WebKit::WebURL;
69 using WebKit::WebString; 72 using WebKit::WebString;
70 73
71 namespace { 74 namespace {
72 75
73 bool IsCustomItemEnabled(const std::vector<WebMenuItem>& items, int id) { 76 bool IsCustomItemEnabled(const std::vector<WebMenuItem>& items, int id) {
74 DCHECK(id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && 77 DCHECK(id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST &&
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 // language. 1153 // language.
1151 if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) || 1154 if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) ||
1152 (id >= IDC_SPELLCHECK_LANGUAGES_LAST)) 1155 (id >= IDC_SPELLCHECK_LANGUAGES_LAST))
1153 return false; 1156 return false;
1154 1157
1155 std::vector<std::string> languages; 1158 std::vector<std::string> languages;
1156 return SpellCheckHost::GetSpellCheckLanguages(profile_, &languages) == 1159 return SpellCheckHost::GetSpellCheckLanguages(profile_, &languages) ==
1157 (id - IDC_SPELLCHECK_LANGUAGES_FIRST); 1160 (id - IDC_SPELLCHECK_LANGUAGES_FIRST);
1158 } 1161 }
1159 1162
1163 void RenderViewContextMenu::ExecuteCommandWithDisposition(
brettw 2011/04/28 20:43:39 Be sure the implementation order matches the heade
1164 int id, WindowOpenDisposition disposition) {
1165
1166 switch (id) {
1167 case IDC_BACK: {
1168 Profile* profile = source_tab_contents_->profile();
1169 Browser* browser =
1170 BrowserList::FindBrowserWithType(profile,
1171 Browser::TYPE_NORMAL, false);
1172 if (browser) {
1173 browser->GoBack(disposition);
1174 return;
1175 }
1176 }
1177 case IDC_FORWARD: {
1178 Profile* profile = source_tab_contents_->profile();
1179 Browser* browser =
1180 BrowserList::FindBrowserWithType(profile,
1181 Browser::TYPE_NORMAL, false);
1182 if (browser) {
1183 browser->GoForward(disposition);
1184 return;
1185 }
1186 }
1187 }
1188
1189 // If not processed, call ExecuteCommand instead.
1190 ExecuteCommand(id);
1191 }
1192
1160 void RenderViewContextMenu::ExecuteCommand(int id) { 1193 void RenderViewContextMenu::ExecuteCommand(int id) {
1161 // Check to see if one of the spell check language ids have been clicked. 1194 // Check to see if one of the spell check language ids have been clicked.
1162 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST && 1195 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST &&
1163 id < IDC_SPELLCHECK_LANGUAGES_LAST) { 1196 id < IDC_SPELLCHECK_LANGUAGES_LAST) {
1164 const size_t language_number = id - IDC_SPELLCHECK_LANGUAGES_FIRST; 1197 const size_t language_number = id - IDC_SPELLCHECK_LANGUAGES_FIRST;
1165 std::vector<std::string> languages; 1198 std::vector<std::string> languages;
1166 SpellCheckHost::GetSpellCheckLanguages(profile_, &languages); 1199 SpellCheckHost::GetSpellCheckLanguages(profile_, &languages);
1167 if (language_number < languages.size()) { 1200 if (language_number < languages.size()) {
1168 StringPrefMember dictionary_language; 1201 StringPrefMember dictionary_language;
1169 dictionary_language.Init(prefs::kSpellCheckDictionary, 1202 dictionary_language.Init(prefs::kSpellCheckDictionary,
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1616 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1584 g_browser_process->clipboard()); 1617 g_browser_process->clipboard());
1585 } 1618 }
1586 1619
1587 void RenderViewContextMenu::MediaPlayerActionAt( 1620 void RenderViewContextMenu::MediaPlayerActionAt(
1588 const gfx::Point& location, 1621 const gfx::Point& location,
1589 const WebMediaPlayerAction& action) { 1622 const WebMediaPlayerAction& action) {
1590 source_tab_contents_->render_view_host()->MediaPlayerActionAt( 1623 source_tab_contents_->render_view_host()->MediaPlayerActionAt(
1591 location, action); 1624 location, action);
1592 } 1625 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698