diff options
author | sidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-01 21:08:11 +0000 |
---|---|---|
committer | sidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-01 21:08:11 +0000 |
commit | c5f9f1854f1cac2a4e7c459e86bc46a44365f7cf (patch) | |
tree | cdcd7a41d9fe730b0f704d153bdbf47b51a7c09c /chrome/browser/render_view_context_menu_controller.cc | |
parent | 8bbe7efe110336916c819fdc7f5566afa3a97495 (diff) | |
download | chromium_src-c5f9f1854f1cac2a4e7c459e86bc46a44365f7cf.zip chromium_src-c5f9f1854f1cac2a4e7c459e86bc46a44365f7cf.tar.gz chromium_src-c5f9f1854f1cac2a4e7c459e86bc46a44365f7cf.tar.bz2 |
Add a new submenu in the context menu for a text box. This submenu displays some spell check languages that Chrome supports, derived from the accept languages list and the current spell check language. The spell check language which is currently set is shown to be selected. The user can click on some other spell check language, and it will become effective immediately (this part of the code was addressed in a previous CL, and has been checked in).
Review URL: http://codereview.chromium.org/12614
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6162 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/render_view_context_menu_controller.cc')
-rw-r--r-- | chrome/browser/render_view_context_menu_controller.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/chrome/browser/render_view_context_menu_controller.cc b/chrome/browser/render_view_context_menu_controller.cc index 0e1b8f0..4943333 100644 --- a/chrome/browser/render_view_context_menu_controller.cc +++ b/chrome/browser/render_view_context_menu_controller.cc @@ -13,6 +13,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/spellchecker.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/save_package.h" #include "chrome/browser/navigation_controller.h" @@ -101,6 +102,12 @@ std::wstring RenderViewContextMenuController::GetLabel(int id) const { } bool RenderViewContextMenuController::IsCommandEnabled(int id) const { + // Allow Spell Check language items on sub menu for text area context menu. + if (id >= IDC_SPELLCHECKER_LANGUAGE_FIRST + && id <= IDC_SPELLCHECKER_LANGUAGE_LAST) { + return true; + } + switch (id) { case IDS_CONTENT_CONTEXT_BACK: return source_web_contents_->controller()->CanGoBack(); @@ -173,12 +180,16 @@ bool RenderViewContextMenuController::IsCommandEnabled(int id) const { case IDC_USESPELLCHECKSUGGESTION_3: case IDC_USESPELLCHECKSUGGESTION_4: return true; + case IDC_SHOW_SPELLCHECKER_SUBMENU: + return true; case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: return !params_.misspelled_word.empty(); case IDS_CONTENT_CONTEXT_VIEWPAGEINFO: return (source_web_contents_->controller()->GetActiveEntry() != NULL); case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO: return true; + case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: + return true; case IDS_CONTENT_CONTEXT_SAVEFRAMEAS: case IDS_CONTENT_CONTEXT_PRINTFRAME: case IDS_CONTENT_CONTEXT_ADDSEARCHENGINE: // Not implemented. @@ -187,6 +198,17 @@ bool RenderViewContextMenuController::IsCommandEnabled(int id) const { } } +bool RenderViewContextMenuController::IsItemChecked(int id) const { + std::vector<std::wstring> display_language_vector; + int spellcheck_language_index = SpellChecker:: + GetSpellCheckLanguagesToDisplayInContextMenu( + source_web_contents_->profile(), &display_language_vector); + if (id - IDC_SPELLCHECKER_LANGUAGE_FIRST == spellcheck_language_index) + return true; + + return false; +} + bool RenderViewContextMenuController::GetAcceleratorInfo( int id, views::Accelerator* accel) { @@ -222,6 +244,24 @@ bool RenderViewContextMenuController::GetAcceleratorInfo( } void RenderViewContextMenuController::ExecuteCommand(int id) { + // Check to see if one of the spell check language ids have been clicked. + if (id >= IDC_SPELLCHECKER_LANGUAGE_FIRST && + id <= IDC_SPELLCHECKER_LANGUAGE_LAST) { + std::vector<std::wstring> display_language_vector; + int current_language = SpellChecker:: + GetSpellCheckLanguagesToDisplayInContextMenu( + source_web_contents_->profile(), &display_language_vector); + if (id - IDC_SPELLCHECKER_LANGUAGE_FIRST < + static_cast<int>(display_language_vector.size())) { + StringPrefMember dictionary_language; + dictionary_language.Init(prefs::kSpellCheckDictionary, + source_web_contents_->profile()->GetPrefs(), NULL); + dictionary_language.SetValue(display_language_vector.at( + id - IDC_SPELLCHECKER_LANGUAGE_FIRST)); + } + + return; + } switch (id) { case IDS_CONTENT_CONTEXT_OPENLINKNEWTAB: OpenURL(params_.link_url, NEW_BACKGROUND_TAB, PageTransition::LINK); |