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

Side by Side Diff: chrome/browser/render_view_context_menu_controller.cc

Issue 13731: [chromium-reviews] Add "Enable spell check for this field" menu option in sub context menu for c... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/render_view_context_menu_controller.h" 5 #include "chrome/browser/render_view_context_menu_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/scoped_clipboard_writer.h" 9 #include "base/scoped_clipboard_writer.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 case IDS_CONTENT_CONTEXT_COPYIMAGE: 175 case IDS_CONTENT_CONTEXT_COPYIMAGE:
176 case IDS_CONTENT_CONTEXT_PRINT: 176 case IDS_CONTENT_CONTEXT_PRINT:
177 case IDS_CONTENT_CONTEXT_SEARCHWEBFOR: 177 case IDS_CONTENT_CONTEXT_SEARCHWEBFOR:
178 case IDC_SPELLCHECK_SUGGESTION_0: 178 case IDC_SPELLCHECK_SUGGESTION_0:
179 case IDC_SPELLCHECK_SUGGESTION_1: 179 case IDC_SPELLCHECK_SUGGESTION_1:
180 case IDC_SPELLCHECK_SUGGESTION_2: 180 case IDC_SPELLCHECK_SUGGESTION_2:
181 case IDC_SPELLCHECK_SUGGESTION_3: 181 case IDC_SPELLCHECK_SUGGESTION_3:
182 case IDC_SPELLCHECK_SUGGESTION_4: 182 case IDC_SPELLCHECK_SUGGESTION_4:
183 return true; 183 return true;
184 case IDC_SPELLCHECK_MENU: 184 case IDC_SPELLCHECK_MENU:
185 case IDC_CHECK_SPELLING_OF_THIS_FIELD:
185 return true; 186 return true;
186 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: 187 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY:
187 return !params_.misspelled_word.empty(); 188 return !params_.misspelled_word.empty();
188 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: 189 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS:
189 return true; 190 return true;
190 case IDS_CONTENT_CONTEXT_VIEWPAGEINFO: 191 case IDS_CONTENT_CONTEXT_VIEWPAGEINFO:
191 return (source_web_contents_->controller()->GetActiveEntry() != NULL); 192 return (source_web_contents_->controller()->GetActiveEntry() != NULL);
192 case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO: 193 case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO:
193 return true; 194 return true;
194 case IDS_CONTENT_CONTEXT_SAVEFRAMEAS: 195 case IDS_CONTENT_CONTEXT_SAVEFRAMEAS:
195 case IDS_CONTENT_CONTEXT_PRINTFRAME: 196 case IDS_CONTENT_CONTEXT_PRINTFRAME:
196 case IDS_CONTENT_CONTEXT_ADDSEARCHENGINE: // Not implemented. 197 case IDS_CONTENT_CONTEXT_ADDSEARCHENGINE: // Not implemented.
197 default: 198 default:
198 return false; 199 return false;
199 } 200 }
200 } 201 }
201 202
202 bool RenderViewContextMenuController::IsItemChecked(int id) const { 203 bool RenderViewContextMenuController::IsItemChecked(int id) const {
204 // Check box for 'Check the Spelling of this field'.
205 if (id == IDC_CHECK_SPELLING_OF_THIS_FIELD)
206 return params_.spellcheck_enabled;
207
208 // Radio button selection for spell check language.
203 std::vector<std::wstring> display_language_vector; 209 std::vector<std::wstring> display_language_vector;
204 int spellcheck_language_index = SpellChecker:: 210 int spellcheck_language_index = SpellChecker::
205 GetSpellCheckLanguagesToDisplayInContextMenu( 211 GetSpellCheckLanguagesToDisplayInContextMenu(
206 source_web_contents_->profile(), &display_language_vector); 212 source_web_contents_->profile(), &display_language_vector);
207 if (id - IDC_SPELLCHECK_LANGUAGES_FIRST == spellcheck_language_index) 213 if (id - IDC_SPELLCHECK_LANGUAGES_FIRST == spellcheck_language_index)
208 return true; 214 return true;
209 215
210 return false; 216 return false;
211 } 217 }
212 218
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 440
435 case IDC_SPELLCHECK_SUGGESTION_0: 441 case IDC_SPELLCHECK_SUGGESTION_0:
436 case IDC_SPELLCHECK_SUGGESTION_1: 442 case IDC_SPELLCHECK_SUGGESTION_1:
437 case IDC_SPELLCHECK_SUGGESTION_2: 443 case IDC_SPELLCHECK_SUGGESTION_2:
438 case IDC_SPELLCHECK_SUGGESTION_3: 444 case IDC_SPELLCHECK_SUGGESTION_3:
439 case IDC_SPELLCHECK_SUGGESTION_4: 445 case IDC_SPELLCHECK_SUGGESTION_4:
440 source_web_contents_->render_view_host()->Replace( 446 source_web_contents_->render_view_host()->Replace(
441 params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]); 447 params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]);
442 break; 448 break;
443 449
450 case IDC_CHECK_SPELLING_OF_THIS_FIELD:
451 source_web_contents_->render_view_host()->ToggleSpellCheck();
452 break;
444 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: 453 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY:
445 source_web_contents_->render_view_host()->AddToDictionary( 454 source_web_contents_->render_view_host()->AddToDictionary(
446 params_.misspelled_word); 455 params_.misspelled_word);
447 break; 456 break;
448 457
449 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: 458 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS:
450 views::Window::CreateChromeWindow( 459 views::Window::CreateChromeWindow(
451 source_web_contents_->GetContentHWND(), 460 source_web_contents_->GetContentHWND(),
452 gfx::Rect(), 461 gfx::Rect(),
453 new FontsLanguagesWindowView( 462 new FontsLanguagesWindowView(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 if (id == IDS_CONTENT_CONTEXT_INSPECTELEMENT) { 502 if (id == IDS_CONTENT_CONTEXT_INSPECTELEMENT) {
494 PrefService* prefs = source_web_contents_->profile()->GetPrefs(); 503 PrefService* prefs = source_web_contents_->profile()->GetPrefs();
495 if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled) || 504 if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled) ||
496 command_line.HasSwitch(switches::kDisableJavaScript)) 505 command_line.HasSwitch(switches::kDisableJavaScript))
497 return false; 506 return false;
498 } 507 }
499 508
500 return true; 509 return true;
501 } 510 }
502 511
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698