summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-15 20:18:04 +0000
committersidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-15 20:18:04 +0000
commitbbbd545cc226d409d131afb806e1ae5df3e5aa73 (patch)
tree6c87d2afde518b04a7b19813c2ec360ba6afbf1f /chrome/browser
parentbdb1d32442597e46583a79c0af560e6cc9e57214 (diff)
downloadchromium_src-bbbd545cc226d409d131afb806e1ae5df3e5aa73.zip
chromium_src-bbbd545cc226d409d131afb806e1ae5df3e5aa73.tar.gz
chromium_src-bbbd545cc226d409d131afb806e1ae5df3e5aa73.tar.bz2
Add "Enable spell check for this field" menu option in sub context menu for context menu over text box, and deploy its functionality accordingly across the code. This patch also allows manual switch-on of spell check in single line text box fields.
Review URL: http://codereview.chromium.org/13731 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7000 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/render_view_context_menu.cc7
-rw-r--r--chrome/browser/render_view_context_menu_controller.cc8
-rw-r--r--chrome/browser/render_view_host.cc4
-rw-r--r--chrome/browser/render_view_host.h1
-rw-r--r--chrome/browser/resource_message_filter.cc2
5 files changed, 21 insertions, 1 deletions
diff --git a/chrome/browser/render_view_context_menu.cc b/chrome/browser/render_view_context_menu.cc
index 9634197..83082b4 100644
--- a/chrome/browser/render_view_context_menu.cc
+++ b/chrome/browser/render_view_context_menu.cc
@@ -168,6 +168,13 @@ void RenderViewContextMenu::AppendEditableItems() {
spellchecker_sub_menu_->AppendSeparator();
spellchecker_sub_menu_->AppendDelegateMenuItem(
IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS);
+
+ // Add 'Check the spelling of this field' item in the sub menu.
+ spellchecker_sub_menu_->AppendMenuItem(
+ IDC_CHECK_SPELLING_OF_THIS_FIELD,
+ l10n_util::GetString(IDS_CONTENT_CONTEXT_CHECK_SPELLING_OF_THIS_FIELD),
+ CHECKBOX);
+
AppendSeparator();
AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_SELECTALL);
}
diff --git a/chrome/browser/render_view_context_menu_controller.cc b/chrome/browser/render_view_context_menu_controller.cc
index 186fe0b..76a6279 100644
--- a/chrome/browser/render_view_context_menu_controller.cc
+++ b/chrome/browser/render_view_context_menu_controller.cc
@@ -190,6 +190,7 @@ bool RenderViewContextMenuController::IsCommandEnabled(int id) const {
case IDC_SPELLCHECK_SUGGESTION_3:
case IDC_SPELLCHECK_SUGGESTION_4:
case IDC_SPELLCHECK_MENU:
+ case IDC_CHECK_SPELLING_OF_THIS_FIELD:
case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS:
case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO:
return true;
@@ -203,6 +204,10 @@ bool RenderViewContextMenuController::IsCommandEnabled(int id) const {
}
bool RenderViewContextMenuController::IsItemChecked(int id) const {
+ // Check box for 'Check the Spelling of this field'.
+ if (id == IDC_CHECK_SPELLING_OF_THIS_FIELD)
+ return params_.spellcheck_enabled;
+
// Don't bother getting the display language vector if this isn't a spellcheck
// language.
if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) ||
@@ -446,6 +451,9 @@ void RenderViewContextMenuController::ExecuteCommand(int id) {
params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]);
break;
+ case IDC_CHECK_SPELLING_OF_THIS_FIELD:
+ source_web_contents_->render_view_host()->ToggleSpellCheck();
+ break;
case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY:
source_web_contents_->render_view_host()->AddToDictionary(
params_.misspelled_word);
diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc
index 4623978..f3b8e2b 100644
--- a/chrome/browser/render_view_host.cc
+++ b/chrome/browser/render_view_host.cc
@@ -450,6 +450,10 @@ void RenderViewHost::Replace(const std::wstring& text_to_replace) {
Send(new ViewMsg_Replace(routing_id_, text_to_replace));
}
+void RenderViewHost::ToggleSpellCheck() {
+ Send(new ViewMsg_ToggleSpellCheck(routing_id_));
+}
+
void RenderViewHost::AddToDictionary(const std::wstring& word) {
process_->AddWord(word);
}
diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h
index 5ccd88f..17d8f97 100644
--- a/chrome/browser/render_view_host.h
+++ b/chrome/browser/render_view_host.h
@@ -251,6 +251,7 @@ class RenderViewHost : public RenderWidgetHost {
void Copy();
void Paste();
void Replace(const std::wstring& text);
+ void ToggleSpellCheck();
void AddToDictionary(const std::wstring& word);
void Delete();
void SelectAll();
diff --git a/chrome/browser/resource_message_filter.cc b/chrome/browser/resource_message_filter.cc
index a674628..e4e8409 100644
--- a/chrome/browser/resource_message_filter.cc
+++ b/chrome/browser/resource_message_filter.cc
@@ -197,7 +197,7 @@ void ResourceMessageFilter::OnReceiveContextMenuMsg(const IPC::Message& msg) {
// Fill in the dictionary suggestions if required.
if (!params.misspelled_word.empty() &&
- spellchecker_ != NULL) {
+ spellchecker_ != NULL && params.spellcheck_enabled) {
int misspell_location, misspell_length;
bool is_misspelled = !spellchecker_->SpellCheckWord(
params.misspelled_word.c_str(),