OLD | NEW |
---|---|
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 22 matching lines...) Expand all Loading... | |
33 #include "chrome/browser/prefs/pref_service.h" | 33 #include "chrome/browser/prefs/pref_service.h" |
34 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
35 #include "chrome/browser/profiles/profile_io_data.h" | 35 #include "chrome/browser/profiles/profile_io_data.h" |
36 #include "chrome/browser/search_engines/template_url.h" | 36 #include "chrome/browser/search_engines/template_url.h" |
37 #include "chrome/browser/search_engines/template_url_model.h" | 37 #include "chrome/browser/search_engines/template_url_model.h" |
38 #include "chrome/browser/spellcheck_host.h" | 38 #include "chrome/browser/spellcheck_host.h" |
39 #include "chrome/browser/spellchecker_platform_engine.h" | 39 #include "chrome/browser/spellchecker_platform_engine.h" |
40 #include "chrome/browser/translate/translate_manager.h" | 40 #include "chrome/browser/translate/translate_manager.h" |
41 #include "chrome/browser/translate/translate_prefs.h" | 41 #include "chrome/browser/translate/translate_prefs.h" |
42 #include "chrome/browser/translate/translate_tab_helper.h" | 42 #include "chrome/browser/translate/translate_tab_helper.h" |
43 #include "chrome/browser/ui/browser_back_forward_navigator.h" | |
43 #include "chrome/browser/ui/download/download_tab_helper.h" | 44 #include "chrome/browser/ui/download/download_tab_helper.h" |
44 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 45 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
46 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" | |
45 #include "chrome/common/chrome_constants.h" | 47 #include "chrome/common/chrome_constants.h" |
46 #include "chrome/common/chrome_switches.h" | 48 #include "chrome/common/chrome_switches.h" |
47 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
48 #include "chrome/common/print_messages.h" | 50 #include "chrome/common/print_messages.h" |
49 #include "chrome/common/spellcheck_messages.h" | 51 #include "chrome/common/spellcheck_messages.h" |
50 #include "chrome/common/url_constants.h" | 52 #include "chrome/common/url_constants.h" |
51 #include "content/browser/child_process_security_policy.h" | 53 #include "content/browser/child_process_security_policy.h" |
52 #include "content/browser/renderer_host/render_view_host.h" | 54 #include "content/browser/renderer_host/render_view_host.h" |
53 #include "content/browser/renderer_host/render_widget_host_view.h" | 55 #include "content/browser/renderer_host/render_widget_host_view.h" |
54 #include "content/browser/tab_contents/navigation_entry.h" | 56 #include "content/browser/tab_contents/navigation_entry.h" |
55 #include "content/browser/tab_contents/tab_contents.h" | 57 #include "content/browser/tab_contents/tab_contents.h" |
56 #include "content/browser/user_metrics.h" | 58 #include "content/browser/user_metrics.h" |
57 #include "content/common/content_restriction.h" | 59 #include "content/common/content_restriction.h" |
58 #include "content/common/view_messages.h" | 60 #include "content/common/view_messages.h" |
59 #include "grit/generated_resources.h" | 61 #include "grit/generated_resources.h" |
60 #include "net/base/escape.h" | 62 #include "net/base/escape.h" |
61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
62 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" | 64 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" |
63 #include "ui/base/l10n/l10n_util.h" | 65 #include "ui/base/l10n/l10n_util.h" |
64 #include "ui/gfx/favicon_size.h" | 66 #include "ui/gfx/favicon_size.h" |
65 #include "webkit/glue/webmenuitem.h" | 67 #include "webkit/glue/webmenuitem.h" |
68 #include "webkit/glue/window_open_disposition.h" | |
66 | 69 |
67 using WebKit::WebContextMenuData; | 70 using WebKit::WebContextMenuData; |
68 using WebKit::WebMediaPlayerAction; | 71 using WebKit::WebMediaPlayerAction; |
69 using WebKit::WebURL; | 72 using WebKit::WebURL; |
70 using WebKit::WebString; | 73 using WebKit::WebString; |
71 | 74 |
72 namespace { | 75 namespace { |
73 | 76 |
74 bool IsCustomItemEnabled(const std::vector<WebMenuItem>& items, int id) { | 77 bool IsCustomItemEnabled(const std::vector<WebMenuItem>& items, int id) { |
75 DCHECK(id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && | 78 DCHECK(id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && |
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1191 // language. | 1194 // language. |
1192 if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) || | 1195 if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) || |
1193 (id >= IDC_SPELLCHECK_LANGUAGES_LAST)) | 1196 (id >= IDC_SPELLCHECK_LANGUAGES_LAST)) |
1194 return false; | 1197 return false; |
1195 | 1198 |
1196 std::vector<std::string> languages; | 1199 std::vector<std::string> languages; |
1197 return SpellCheckHost::GetSpellCheckLanguages(profile_, &languages) == | 1200 return SpellCheckHost::GetSpellCheckLanguages(profile_, &languages) == |
1198 (id - IDC_SPELLCHECK_LANGUAGES_FIRST); | 1201 (id - IDC_SPELLCHECK_LANGUAGES_FIRST); |
1199 } | 1202 } |
1200 | 1203 |
1204 void RenderViewContextMenu::ExecuteCommandWithFlags(int id, int flags) { | |
1205 switch (id) { | |
1206 case IDC_BACK: { | |
Ben Goodger (Google)
2011/05/31 16:00:00
A general note. It seems weird to me that the cont
shinyak (Google)
2011/06/09 02:29:04
I've changed these so that they just call a functi
| |
1207 TabContentsWrapper* wrapper = | |
1208 TabContentsWrapper::GetCurrentWrapperForContents( | |
1209 source_tab_contents_); | |
1210 browser::BrowserBackForwardNavigator::GoBack( | |
1211 wrapper->delegate(), flags); | |
1212 return; | |
1213 } | |
1214 case IDC_FORWARD: { | |
1215 TabContentsWrapper* wrapper = | |
1216 TabContentsWrapper::GetCurrentWrapperForContents( | |
1217 source_tab_contents_); | |
1218 browser::BrowserBackForwardNavigator::GoForward( | |
1219 wrapper->delegate(), flags); | |
1220 return; | |
1221 } | |
1222 } | |
1223 | |
1224 // If not processed, call ExecuteCommand instead. | |
1225 ExecuteCommand(id); | |
1226 } | |
1227 | |
1201 void RenderViewContextMenu::ExecuteCommand(int id) { | 1228 void RenderViewContextMenu::ExecuteCommand(int id) { |
1202 // Check to see if one of the spell check language ids have been clicked. | 1229 // Check to see if one of the spell check language ids have been clicked. |
1203 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST && | 1230 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST && |
1204 id < IDC_SPELLCHECK_LANGUAGES_LAST) { | 1231 id < IDC_SPELLCHECK_LANGUAGES_LAST) { |
1205 const size_t language_number = id - IDC_SPELLCHECK_LANGUAGES_FIRST; | 1232 const size_t language_number = id - IDC_SPELLCHECK_LANGUAGES_FIRST; |
1206 std::vector<std::string> languages; | 1233 std::vector<std::string> languages; |
1207 SpellCheckHost::GetSpellCheckLanguages(profile_, &languages); | 1234 SpellCheckHost::GetSpellCheckLanguages(profile_, &languages); |
1208 if (language_number < languages.size()) { | 1235 if (language_number < languages.size()) { |
1209 StringPrefMember dictionary_language; | 1236 StringPrefMember dictionary_language; |
1210 dictionary_language.Init(prefs::kSpellCheckDictionary, | 1237 dictionary_language.Init(prefs::kSpellCheckDictionary, |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1639 g_browser_process->clipboard()); | 1666 g_browser_process->clipboard()); |
1640 } | 1667 } |
1641 | 1668 |
1642 void RenderViewContextMenu::MediaPlayerActionAt( | 1669 void RenderViewContextMenu::MediaPlayerActionAt( |
1643 const gfx::Point& location, | 1670 const gfx::Point& location, |
1644 const WebMediaPlayerAction& action) { | 1671 const WebMediaPlayerAction& action) { |
1645 RenderViewHost* rvh = source_tab_contents_->render_view_host(); | 1672 RenderViewHost* rvh = source_tab_contents_->render_view_host(); |
1646 rvh->Send(new ViewMsg_MediaPlayerActionAt( | 1673 rvh->Send(new ViewMsg_MediaPlayerActionAt( |
1647 rvh->routing_id(), location, action)); | 1674 rvh->routing_id(), location, action)); |
1648 } | 1675 } |
OLD | NEW |