OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 #include "ui/base/clipboard/clipboard.h" | 113 #include "ui/base/clipboard/clipboard.h" |
114 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 114 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
115 #include "ui/base/l10n/l10n_util.h" | 115 #include "ui/base/l10n/l10n_util.h" |
116 #include "ui/gfx/canvas.h" | 116 #include "ui/gfx/canvas.h" |
117 #include "ui/gfx/favicon_size.h" | 117 #include "ui/gfx/favicon_size.h" |
118 #include "ui/gfx/geometry/point.h" | 118 #include "ui/gfx/geometry/point.h" |
119 #include "ui/gfx/geometry/size.h" | 119 #include "ui/gfx/geometry/size.h" |
120 #include "ui/gfx/path.h" | 120 #include "ui/gfx/path.h" |
121 #include "ui/gfx/text_elider.h" | 121 #include "ui/gfx/text_elider.h" |
122 | 122 |
123 #if !defined(USE_BROWSER_SPELLCHECKER) | |
124 #include "chrome/browser/renderer_context_menu/spelling_options_submenu_observer .h" | |
125 #endif | |
126 | |
123 #if defined(ENABLE_EXTENSIONS) | 127 #if defined(ENABLE_EXTENSIONS) |
124 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" | 128 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" |
125 #endif | 129 #endif |
126 | 130 |
127 #if defined(ENABLE_PRINTING) | 131 #if defined(ENABLE_PRINTING) |
128 #include "chrome/browser/printing/print_view_manager_common.h" | 132 #include "chrome/browser/printing/print_view_manager_common.h" |
129 #include "components/printing/common/print_messages.h" | 133 #include "components/printing/common/print_messages.h" |
130 | 134 |
131 #if defined(ENABLE_PRINT_PREVIEW) | 135 #if defined(ENABLE_PRINT_PREVIEW) |
132 #include "chrome/browser/printing/print_preview_context_menu_observer.h" | 136 #include "chrome/browser/printing/print_preview_context_menu_observer.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 {62, -1, IDC_WRITING_DIRECTION_MENU}, | 267 {62, -1, IDC_WRITING_DIRECTION_MENU}, |
264 {63, -1, IDC_WRITING_DIRECTION_DEFAULT}, | 268 {63, -1, IDC_WRITING_DIRECTION_DEFAULT}, |
265 {64, -1, IDC_WRITING_DIRECTION_LTR}, | 269 {64, -1, IDC_WRITING_DIRECTION_LTR}, |
266 {65, -1, IDC_WRITING_DIRECTION_RTL}, | 270 {65, -1, IDC_WRITING_DIRECTION_RTL}, |
267 {66, -1, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE}, | 271 {66, -1, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE}, |
268 {67, -1, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, | 272 {67, -1, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, |
269 {68, -1, IDC_ROUTE_MEDIA}, | 273 {68, -1, IDC_ROUTE_MEDIA}, |
270 {69, -1, IDC_CONTENT_CONTEXT_COPYLINKTEXT}, | 274 {69, -1, IDC_CONTENT_CONTEXT_COPYLINKTEXT}, |
271 {70, -1, IDC_CONTENT_CONTEXT_OPENLINKINPROFILE}, | 275 {70, -1, IDC_CONTENT_CONTEXT_OPENLINKINPROFILE}, |
272 {71, -1, IDC_OPEN_LINK_IN_PROFILE_FIRST}, | 276 {71, -1, IDC_OPEN_LINK_IN_PROFILE_FIRST}, |
277 {72, -1, IDC_SPELLCHECK_MULTI_LINGUAL}, | |
273 // Add new items here and use |enum_id| from the next line. | 278 // Add new items here and use |enum_id| from the next line. |
274 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. | 279 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. |
275 {72, -1, 0}, // Must be the last. Increment |enum_id| when new IDC | 280 {73, -1, 0}, // Must be the last. Increment |enum_id| when new IDC |
276 // was added. | 281 // was added. |
277 }; | 282 }; |
278 | 283 |
279 // Collapses large ranges of ids before looking for UMA enum. | 284 // Collapses large ranges of ids before looking for UMA enum. |
280 int CollapseCommandsForUMA(int id) { | 285 int CollapseCommandsForUMA(int id) { |
281 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); | 286 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); |
282 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); | 287 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); |
283 | 288 |
284 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && | 289 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && |
285 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { | 290 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1173 selection_navigation_url_.scheme())) { | 1178 selection_navigation_url_.scheme())) { |
1174 menu_model_.AddItem( | 1179 menu_model_.AddItem( |
1175 IDC_CONTENT_CONTEXT_GOTOURL, | 1180 IDC_CONTENT_CONTEXT_GOTOURL, |
1176 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL, | 1181 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL, |
1177 printable_selection_text)); | 1182 printable_selection_text)); |
1178 } | 1183 } |
1179 } | 1184 } |
1180 } | 1185 } |
1181 | 1186 |
1182 void RenderViewContextMenu::AppendEditableItems() { | 1187 void RenderViewContextMenu::AppendEditableItems() { |
1183 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode(); | 1188 const bool use_spelling = !chrome::IsRunningInForcedAppMode(); |
1184 | 1189 if (use_spelling) |
1185 if (use_spellcheck_and_search) | 1190 AppendSpellingSuggestionItems(); |
1186 AppendSpellingSuggestionsSubMenu(); | |
1187 | 1191 |
1188 // 'Undo' and 'Redo' for text input with no suggestions and no text selected. | 1192 // 'Undo' and 'Redo' for text input with no suggestions and no text selected. |
1189 // We make an exception for OS X as context clicking will select the closest | 1193 // We make an exception for OS X as context clicking will select the closest |
1190 // word. In this case both items are always shown. | 1194 // word. In this case both items are always shown. |
1191 #if defined(OS_MACOSX) | 1195 #if defined(OS_MACOSX) |
1192 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO, | 1196 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO, |
1193 IDS_CONTENT_CONTEXT_UNDO); | 1197 IDS_CONTENT_CONTEXT_UNDO); |
1194 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO, | 1198 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO, |
1195 IDS_CONTENT_CONTEXT_REDO); | 1199 IDS_CONTENT_CONTEXT_REDO); |
1196 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 1200 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
(...skipping 16 matching lines...) Expand all Loading... | |
1213 IDS_CONTENT_CONTEXT_PASTE); | 1217 IDS_CONTENT_CONTEXT_PASTE); |
1214 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, | 1218 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, |
1215 IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE); | 1219 IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE); |
1216 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL, | 1220 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL, |
1217 IDS_CONTENT_CONTEXT_SELECTALL); | 1221 IDS_CONTENT_CONTEXT_SELECTALL); |
1218 | 1222 |
1219 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 1223 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
1220 } | 1224 } |
1221 | 1225 |
1222 void RenderViewContextMenu::AppendLanguageSettings() { | 1226 void RenderViewContextMenu::AppendLanguageSettings() { |
1223 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode(); | 1227 const bool use_spelling = !chrome::IsRunningInForcedAppMode(); |
1228 if (!use_spelling) | |
1229 return; | |
1224 | 1230 |
1225 if (use_spellcheck_and_search) | 1231 #if defined(USE_BROWSER_SPELLCHECKER) |
groby-ooo-7-16
2016/01/28 22:49:28
MumbleGrumble. It's theoretically not related to u
please use gerrit instead
2016/01/29 20:09:34
OK. Using the OS_MACOSX macro.
| |
1226 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, | 1232 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, |
1227 IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); | 1233 IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); |
1234 #else | |
1235 if (!spelling_options_submenu_observer_) { | |
1236 const int kLanguageRadioGroup = 1; | |
1237 spelling_options_submenu_observer_.reset( | |
1238 new SpellingOptionsSubMenuObserver(this, this, kLanguageRadioGroup)); | |
1239 } | |
1240 | |
1241 spelling_options_submenu_observer_->InitMenu(params_); | |
1242 observers_.AddObserver(spelling_options_submenu_observer_.get()); | |
1243 #endif | |
1228 } | 1244 } |
1229 | 1245 |
1230 void RenderViewContextMenu::AppendSpellingSuggestionsSubMenu() { | 1246 void RenderViewContextMenu::AppendSpellingSuggestionItems() { |
1231 if (!spelling_menu_observer_.get()) | 1247 if (!spelling_suggestions_menu_observer_) |
1232 spelling_menu_observer_.reset(new SpellingMenuObserver(this)); | 1248 spelling_suggestions_menu_observer_.reset(new SpellingMenuObserver(this)); |
1233 observers_.AddObserver(spelling_menu_observer_.get()); | 1249 observers_.AddObserver(spelling_suggestions_menu_observer_.get()); |
1234 spelling_menu_observer_->InitMenu(params_); | 1250 spelling_suggestions_menu_observer_->InitMenu(params_); |
1235 } | 1251 } |
1236 | 1252 |
1237 void RenderViewContextMenu::AppendProtocolHandlerSubMenu() { | 1253 void RenderViewContextMenu::AppendProtocolHandlerSubMenu() { |
1238 const ProtocolHandlerRegistry::ProtocolHandlerList handlers = | 1254 const ProtocolHandlerRegistry::ProtocolHandlerList handlers = |
1239 GetHandlersForLinkUrl(); | 1255 GetHandlersForLinkUrl(); |
1240 if (handlers.empty()) | 1256 if (handlers.empty()) |
1241 return; | 1257 return; |
1242 size_t max = IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST - | 1258 size_t max = IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST - |
1243 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; | 1259 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; |
1244 for (size_t i = 0; i < handlers.size() && i <= max; i++) { | 1260 for (size_t i = 0; i < handlers.size() && i <= max; i++) { |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2183 source_web_contents_->GetRenderViewHost()-> | 2199 source_web_contents_->GetRenderViewHost()-> |
2184 ExecuteMediaPlayerActionAtLocation(location, action); | 2200 ExecuteMediaPlayerActionAtLocation(location, action); |
2185 } | 2201 } |
2186 | 2202 |
2187 void RenderViewContextMenu::PluginActionAt( | 2203 void RenderViewContextMenu::PluginActionAt( |
2188 const gfx::Point& location, | 2204 const gfx::Point& location, |
2189 const WebPluginAction& action) { | 2205 const WebPluginAction& action) { |
2190 source_web_contents_->GetRenderViewHost()-> | 2206 source_web_contents_->GetRenderViewHost()-> |
2191 ExecutePluginActionAtLocation(location, action); | 2207 ExecutePluginActionAtLocation(location, action); |
2192 } | 2208 } |
OLD | NEW |