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

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

Issue 1647723002: [win/cros/lin] Add back the spellcheck menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 10 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
OLDNEW
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 #include "ui/base/clipboard/clipboard.h" 114 #include "ui/base/clipboard/clipboard.h"
115 #include "ui/base/clipboard/scoped_clipboard_writer.h" 115 #include "ui/base/clipboard/scoped_clipboard_writer.h"
116 #include "ui/base/l10n/l10n_util.h" 116 #include "ui/base/l10n/l10n_util.h"
117 #include "ui/gfx/canvas.h" 117 #include "ui/gfx/canvas.h"
118 #include "ui/gfx/favicon_size.h" 118 #include "ui/gfx/favicon_size.h"
119 #include "ui/gfx/geometry/point.h" 119 #include "ui/gfx/geometry/point.h"
120 #include "ui/gfx/geometry/size.h" 120 #include "ui/gfx/geometry/size.h"
121 #include "ui/gfx/path.h" 121 #include "ui/gfx/path.h"
122 #include "ui/gfx/text_elider.h" 122 #include "ui/gfx/text_elider.h"
123 123
124 #if !defined(USE_BROWSER_SPELLCHECKER)
125 #include "chrome/browser/renderer_context_menu/spelling_options_submenu_observer .h"
126 #endif
127
124 #if defined(ENABLE_EXTENSIONS) 128 #if defined(ENABLE_EXTENSIONS)
125 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" 129 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h"
126 #endif 130 #endif
127 131
128 #if defined(ENABLE_PRINTING) 132 #if defined(ENABLE_PRINTING)
129 #include "chrome/browser/printing/print_view_manager_common.h" 133 #include "chrome/browser/printing/print_view_manager_common.h"
130 #include "components/printing/common/print_messages.h" 134 #include "components/printing/common/print_messages.h"
131 135
132 #if defined(ENABLE_PRINT_PREVIEW) 136 #if defined(ENABLE_PRINT_PREVIEW)
133 #include "chrome/browser/printing/print_preview_context_menu_observer.h" 137 #include "chrome/browser/printing/print_preview_context_menu_observer.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 {63, -1, IDC_WRITING_DIRECTION_DEFAULT}, 269 {63, -1, IDC_WRITING_DIRECTION_DEFAULT},
266 {64, -1, IDC_WRITING_DIRECTION_LTR}, 270 {64, -1, IDC_WRITING_DIRECTION_LTR},
267 {65, -1, IDC_WRITING_DIRECTION_RTL}, 271 {65, -1, IDC_WRITING_DIRECTION_RTL},
268 {66, -1, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE}, 272 {66, -1, IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE},
269 {67, -1, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD}, 273 {67, -1, IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD},
270 {68, -1, IDC_ROUTE_MEDIA}, 274 {68, -1, IDC_ROUTE_MEDIA},
271 {69, -1, IDC_CONTENT_CONTEXT_COPYLINKTEXT}, 275 {69, -1, IDC_CONTENT_CONTEXT_COPYLINKTEXT},
272 {70, -1, IDC_CONTENT_CONTEXT_OPENLINKINPROFILE}, 276 {70, -1, IDC_CONTENT_CONTEXT_OPENLINKINPROFILE},
273 {71, -1, IDC_OPEN_LINK_IN_PROFILE_FIRST}, 277 {71, -1, IDC_OPEN_LINK_IN_PROFILE_FIRST},
274 {72, -1, IDC_CONTENT_CONTEXT_GENERATEPASSWORD}, 278 {72, -1, IDC_CONTENT_CONTEXT_GENERATEPASSWORD},
279 {73, -1, IDC_SPELLCHECK_MULTI_LINGUAL},
275 // Add new items here and use |enum_id| from the next line. 280 // Add new items here and use |enum_id| from the next line.
276 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml. 281 // Also, add new items to RenderViewContextMenuItem enum in histograms.xml.
277 {73, -1, 0}, // Must be the last. Increment |enum_id| when new IDC 282 {74, -1, 0}, // Must be the last. Increment |enum_id| when new IDC
278 // was added. 283 // was added.
279 }; 284 };
280 285
281 // Collapses large ranges of ids before looking for UMA enum. 286 // Collapses large ranges of ids before looking for UMA enum.
282 int CollapseCommandsForUMA(int id) { 287 int CollapseCommandsForUMA(int id) {
283 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); 288 DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id));
284 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); 289 DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id));
285 290
286 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 291 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
287 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 292 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 selection_navigation_url_.scheme())) { 1180 selection_navigation_url_.scheme())) {
1176 menu_model_.AddItem( 1181 menu_model_.AddItem(
1177 IDC_CONTENT_CONTEXT_GOTOURL, 1182 IDC_CONTENT_CONTEXT_GOTOURL,
1178 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL, 1183 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL,
1179 printable_selection_text)); 1184 printable_selection_text));
1180 } 1185 }
1181 } 1186 }
1182 } 1187 }
1183 1188
1184 void RenderViewContextMenu::AppendEditableItems() { 1189 void RenderViewContextMenu::AppendEditableItems() {
1185 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode(); 1190 const bool use_spelling = !chrome::IsRunningInForcedAppMode();
1186 1191 if (use_spelling)
1187 if (use_spellcheck_and_search) 1192 AppendSpellingSuggestionItems();
1188 AppendSpellingSuggestionsSubMenu();
1189 1193
1190 // 'Undo' and 'Redo' for text input with no suggestions and no text selected. 1194 // 'Undo' and 'Redo' for text input with no suggestions and no text selected.
1191 // We make an exception for OS X as context clicking will select the closest 1195 // We make an exception for OS X as context clicking will select the closest
1192 // word. In this case both items are always shown. 1196 // word. In this case both items are always shown.
1193 #if defined(OS_MACOSX) 1197 #if defined(OS_MACOSX)
1194 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO, 1198 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO,
1195 IDS_CONTENT_CONTEXT_UNDO); 1199 IDS_CONTENT_CONTEXT_UNDO);
1196 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO, 1200 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO,
1197 IDS_CONTENT_CONTEXT_REDO); 1201 IDS_CONTENT_CONTEXT_REDO);
1198 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 1202 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
(...skipping 16 matching lines...) Expand all
1215 IDS_CONTENT_CONTEXT_PASTE); 1219 IDS_CONTENT_CONTEXT_PASTE);
1216 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, 1220 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE,
1217 IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE); 1221 IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE);
1218 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL, 1222 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL,
1219 IDS_CONTENT_CONTEXT_SELECTALL); 1223 IDS_CONTENT_CONTEXT_SELECTALL);
1220 1224
1221 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 1225 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
1222 } 1226 }
1223 1227
1224 void RenderViewContextMenu::AppendLanguageSettings() { 1228 void RenderViewContextMenu::AppendLanguageSettings() {
1225 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode(); 1229 const bool use_spelling = !chrome::IsRunningInForcedAppMode();
1230 if (!use_spelling)
1231 return;
1226 1232
1227 if (use_spellcheck_and_search) 1233 #if defined(OS_MACOSX)
1228 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, 1234 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS,
1229 IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); 1235 IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS);
1236 #else
1237 if (!spelling_options_submenu_observer_) {
1238 const int kLanguageRadioGroup = 1;
1239 spelling_options_submenu_observer_.reset(
1240 new SpellingOptionsSubMenuObserver(this, this, kLanguageRadioGroup));
1241 }
1242
1243 spelling_options_submenu_observer_->InitMenu(params_);
1244 observers_.AddObserver(spelling_options_submenu_observer_.get());
1245 #endif
1230 } 1246 }
1231 1247
1232 void RenderViewContextMenu::AppendSpellingSuggestionsSubMenu() { 1248 void RenderViewContextMenu::AppendSpellingSuggestionItems() {
1233 if (!spelling_menu_observer_.get()) 1249 if (!spelling_suggestions_menu_observer_)
1234 spelling_menu_observer_.reset(new SpellingMenuObserver(this)); 1250 spelling_suggestions_menu_observer_.reset(new SpellingMenuObserver(this));
1235 observers_.AddObserver(spelling_menu_observer_.get()); 1251 observers_.AddObserver(spelling_suggestions_menu_observer_.get());
1236 spelling_menu_observer_->InitMenu(params_); 1252 spelling_suggestions_menu_observer_->InitMenu(params_);
1237 } 1253 }
1238 1254
1239 void RenderViewContextMenu::AppendProtocolHandlerSubMenu() { 1255 void RenderViewContextMenu::AppendProtocolHandlerSubMenu() {
1240 const ProtocolHandlerRegistry::ProtocolHandlerList handlers = 1256 const ProtocolHandlerRegistry::ProtocolHandlerList handlers =
1241 GetHandlersForLinkUrl(); 1257 GetHandlersForLinkUrl();
1242 if (handlers.empty()) 1258 if (handlers.empty())
1243 return; 1259 return;
1244 size_t max = IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST - 1260 size_t max = IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST -
1245 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; 1261 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST;
1246 for (size_t i = 0; i < handlers.size() && i <= max; i++) { 1262 for (size_t i = 0; i < handlers.size() && i <= max; i++) {
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 source_web_contents_->GetRenderViewHost()-> 2211 source_web_contents_->GetRenderViewHost()->
2196 ExecuteMediaPlayerActionAtLocation(location, action); 2212 ExecuteMediaPlayerActionAtLocation(location, action);
2197 } 2213 }
2198 2214
2199 void RenderViewContextMenu::PluginActionAt( 2215 void RenderViewContextMenu::PluginActionAt(
2200 const gfx::Point& location, 2216 const gfx::Point& location,
2201 const WebPluginAction& action) { 2217 const WebPluginAction& action) {
2202 source_web_contents_->GetRenderViewHost()-> 2218 source_web_contents_->GetRenderViewHost()->
2203 ExecutePluginActionAtLocation(location, action); 2219 ExecutePluginActionAtLocation(location, action);
2204 } 2220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698