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

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: 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/spellchecker_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
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 Browser* browser = chrome::FindLastActiveWithProfile(profile, desktop_type); 439 Browser* browser = chrome::FindLastActiveWithProfile(profile, desktop_type);
435 chrome::NavigateParams nav_params(browser, link_url, 440 chrome::NavigateParams nav_params(browser, link_url,
436 ui::PAGE_TRANSITION_LINK); 441 ui::PAGE_TRANSITION_LINK);
437 nav_params.disposition = NEW_FOREGROUND_TAB; 442 nav_params.disposition = NEW_FOREGROUND_TAB;
438 nav_params.referrer = referrer; 443 nav_params.referrer = referrer;
439 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; 444 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW;
440 chrome::Navigate(&nav_params); 445 chrome::Navigate(&nav_params);
441 } 446 }
442 } 447 }
443 448
449 const int kSpellcheckRadioGroup = 1;
450
444 } // namespace 451 } // namespace
445 452
446 // static 453 // static
447 gfx::Vector2d RenderViewContextMenu::GetOffset( 454 gfx::Vector2d RenderViewContextMenu::GetOffset(
448 RenderFrameHost* render_frame_host) { 455 RenderFrameHost* render_frame_host) {
449 gfx::Vector2d offset; 456 gfx::Vector2d offset;
450 #if defined(ENABLE_EXTENSIONS) 457 #if defined(ENABLE_EXTENSIONS)
451 WebContents* web_contents = 458 WebContents* web_contents =
452 WebContents::FromRenderFrameHost(render_frame_host); 459 WebContents::FromRenderFrameHost(render_frame_host);
453 WebContents* top_level_web_contents = 460 WebContents* top_level_web_contents =
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL, 1183 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL,
1177 printable_selection_text)); 1184 printable_selection_text));
1178 } 1185 }
1179 } 1186 }
1180 } 1187 }
1181 1188
1182 void RenderViewContextMenu::AppendEditableItems() { 1189 void RenderViewContextMenu::AppendEditableItems() {
1183 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode(); 1190 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode();
1184 1191
1185 if (use_spellcheck_and_search) 1192 if (use_spellcheck_and_search)
1186 AppendSpellingSuggestionsSubMenu(); 1193 AppendSpellcheckSuggestionItems();
1187 1194
1188 // 'Undo' and 'Redo' for text input with no suggestions and no text selected. 1195 // '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 1196 // We make an exception for OS X as context clicking will select the closest
1190 // word. In this case both items are always shown. 1197 // word. In this case both items are always shown.
1191 #if defined(OS_MACOSX) 1198 #if defined(OS_MACOSX)
1192 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO, 1199 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO,
1193 IDS_CONTENT_CONTEXT_UNDO); 1200 IDS_CONTENT_CONTEXT_UNDO);
1194 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO, 1201 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO,
1195 IDS_CONTENT_CONTEXT_REDO); 1202 IDS_CONTENT_CONTEXT_REDO);
1196 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 1203 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
(...skipping 17 matching lines...) Expand all
1214 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, 1221 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE,
1215 IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE); 1222 IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE);
1216 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL, 1223 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL,
1217 IDS_CONTENT_CONTEXT_SELECTALL); 1224 IDS_CONTENT_CONTEXT_SELECTALL);
1218 1225
1219 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 1226 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
1220 } 1227 }
1221 1228
1222 void RenderViewContextMenu::AppendLanguageSettings() { 1229 void RenderViewContextMenu::AppendLanguageSettings() {
1223 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode(); 1230 const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode();
1231 if (!use_spellcheck_and_search)
1232 return;
1224 1233
1225 if (use_spellcheck_and_search) 1234 #if defined(USE_BROWSER_SPELLCHECKER)
1226 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, 1235 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS,
1227 IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); 1236 IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS);
1237 #else
1238 if (!spellchecker_submenu_observer_.get()) {
lazyboy 2016/01/28 20:36:24 .get() is unnecessary.
please use gerrit instead 2016/01/28 21:41:59 Done.
1239 spellchecker_submenu_observer_.reset(
1240 new SpellCheckerSubMenuObserver(this, this, kSpellcheckRadioGroup));
1241 }
1242
1243 spellchecker_submenu_observer_->InitMenu(params_);
1244 observers_.AddObserver(spellchecker_submenu_observer_.get());
1245 #endif
1228 } 1246 }
1229 1247
1230 void RenderViewContextMenu::AppendSpellingSuggestionsSubMenu() { 1248 void RenderViewContextMenu::AppendSpellcheckSuggestionItems() {
lazyboy 2016/01/28 20:36:24 I always get confused by Spelling*Menu and Spellch
please use gerrit instead 2016/01/28 21:41:59 Changed everything to use the word "Spelling" inst
lazyboy 2016/02/01 19:23:33 Got it, thanks.
1231 if (!spelling_menu_observer_.get()) 1249 if (!spelling_menu_observer_.get())
1232 spelling_menu_observer_.reset(new SpellingMenuObserver(this)); 1250 spelling_menu_observer_.reset(new SpellingMenuObserver(this));
1233 observers_.AddObserver(spelling_menu_observer_.get()); 1251 observers_.AddObserver(spelling_menu_observer_.get());
1234 spelling_menu_observer_->InitMenu(params_); 1252 spelling_menu_observer_->InitMenu(params_);
1235 } 1253 }
1236 1254
1237 void RenderViewContextMenu::AppendProtocolHandlerSubMenu() { 1255 void RenderViewContextMenu::AppendProtocolHandlerSubMenu() {
1238 const ProtocolHandlerRegistry::ProtocolHandlerList handlers = 1256 const ProtocolHandlerRegistry::ProtocolHandlerList handlers =
1239 GetHandlersForLinkUrl(); 1257 GetHandlersForLinkUrl();
1240 if (handlers.empty()) 1258 if (handlers.empty())
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2183 source_web_contents_->GetRenderViewHost()-> 2201 source_web_contents_->GetRenderViewHost()->
2184 ExecuteMediaPlayerActionAtLocation(location, action); 2202 ExecuteMediaPlayerActionAtLocation(location, action);
2185 } 2203 }
2186 2204
2187 void RenderViewContextMenu::PluginActionAt( 2205 void RenderViewContextMenu::PluginActionAt(
2188 const gfx::Point& location, 2206 const gfx::Point& location,
2189 const WebPluginAction& action) { 2207 const WebPluginAction& action) {
2190 source_web_contents_->GetRenderViewHost()-> 2208 source_web_contents_->GetRenderViewHost()->
2191 ExecutePluginActionAtLocation(location, action); 2209 ExecutePluginActionAtLocation(location, action);
2192 } 2210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698