 Chromium Code Reviews
 Chromium Code Reviews Issue 7086005:
  Context menu for "Voice recognition options"  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk
    
  
    Issue 7086005:
  Context menu for "Voice recognition options"  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk| Index: chrome/browser/tab_contents/render_view_context_menu.cc | 
| diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc | 
| index eac5c8b32fe1ce2eac46babbf4aabd907280dbc1..1ab116a6d0ffba0ed924feaa9a4c4199c4bcf097 100644 | 
| --- a/chrome/browser/tab_contents/render_view_context_menu.cc | 
| +++ b/chrome/browser/tab_contents/render_view_context_menu.cc | 
| @@ -24,6 +24,7 @@ | 
| #include "chrome/browser/download/save_package.h" | 
| #include "chrome/browser/extensions/extension_event_router.h" | 
| #include "chrome/browser/extensions/extension_service.h" | 
| +#include "chrome/browser/google/google_util.h" | 
| #include "chrome/browser/net/browser_url_util.h" | 
| #include "chrome/browser/page_info_window.h" | 
| #include "chrome/browser/platform_util.h" | 
| @@ -193,6 +194,7 @@ RenderViewContextMenu::RenderViewContextMenu( | 
| ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)), | 
| external_(false), | 
| ALLOW_THIS_IN_INITIALIZER_LIST(spellcheck_submenu_model_(this)), | 
| + ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_submenu_model_(this)), | 
| ALLOW_THIS_IN_INITIALIZER_LIST(bidi_submenu_model_(this)), | 
| ALLOW_THIS_IN_INITIALIZER_LIST(protocol_handler_submenu_model_(this)), | 
| protocol_handler_registry_( | 
| @@ -793,6 +795,7 @@ void RenderViewContextMenu::AppendEditableItems() { | 
| } | 
| AppendSpellcheckOptionsSubMenu(); | 
| + AppendSpeechInputOptionsSubMenu(); | 
| #if defined(OS_MACOSX) | 
| // OS X provides a contextual menu to set writing direction for BiDi | 
| @@ -853,6 +856,24 @@ void RenderViewContextMenu::AppendSpellcheckOptionsSubMenu() { | 
| &spellcheck_submenu_model_); | 
| } | 
| +void RenderViewContextMenu::AppendSpeechInputOptionsSubMenu() { | 
| + if (params_.speech_input_enabled) { | 
| + speech_input_submenu_model_.AddCheckItem( | 
| + IDC_CONTENT_CONTEXT_SPEECH_INPUT_CENSOR_RESULTS, | 
| + l10n_util::GetStringUTF16( | 
| + IDS_CONTENT_CONTEXT_SPEECH_INPUT_CENSOR_RESULTS)); | 
| + | 
| + speech_input_submenu_model_.AddItemWithStringId( | 
| + IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT, | 
| + IDS_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT); | 
| + | 
| + menu_model_.AddSubMenu( | 
| + IDC_SPEECH_INPUT_MENU, | 
| + l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPEECH_INPUT_MENU), | 
| + &speech_input_submenu_model_); | 
| + } | 
| +} | 
| + | 
| #if defined(OS_MACOSX) | 
| void RenderViewContextMenu::AppendBidiSubMenu() { | 
| bidi_submenu_model_.AddCheckItem(IDC_WRITING_DIRECTION_DEFAULT, | 
| @@ -1190,6 +1211,11 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { | 
| case IDC_SPELLCHECK_MENU: | 
| return true; | 
| + case IDC_CONTENT_CONTEXT_SPEECH_INPUT_CENSOR_RESULTS: | 
| + case IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT: | 
| + case IDC_SPEECH_INPUT_MENU: | 
| + return true; | 
| + | 
| case IDC_CONTENT_CONTEXT_OPENLINKWITH: | 
| return true; | 
| @@ -1250,6 +1276,11 @@ bool RenderViewContextMenu::IsCommandIdChecked(int id) const { | 
| profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)); | 
| } | 
| + // Check box for menu item 'Block offensive words'. | 
| + if (id == IDC_CONTENT_CONTEXT_SPEECH_INPUT_CENSOR_RESULTS) { | 
| + return profile_->GetPrefs()->GetBoolean(prefs::kSpeechInputCensorResults); | 
| + } | 
| + | 
| // Don't bother getting the display language vector if this isn't a spellcheck | 
| // language. | 
| if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) || | 
| @@ -1662,6 +1693,26 @@ void RenderViewContextMenu::ExecuteCommand(int id) { | 
| break; | 
| } | 
| + case IDC_CONTENT_CONTEXT_SPEECH_INPUT_CENSOR_RESULTS: { | 
| + PrefService* prefs = profile_->GetPrefs(); | 
| + const bool censor = | 
| + !prefs->GetBoolean(prefs::kSpeechInputCensorResults); | 
| + prefs->SetBoolean(prefs::kSpeechInputCensorResults, censor); | 
| + break; | 
| + } | 
| + | 
| + case IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT: { | 
| + GURL about_url(chrome::kSpeechInputAboutURL); | 
| + GURL localized_about_url = google_util::AppendGoogleLocaleParam(about_url); | 
| 
Satish
2011/07/20 15:23:13
line too long?
 
gshires
2011/07/20 17:16:10
Done.
 | 
| + // Open URL with no referrer field (because user clicked on menu item). | 
| + OpenURL( | 
| + localized_about_url, | 
| 
Satish
2011/07/20 15:23:13
suggest moving the first parameter to the previous
 
gshires
2011/07/20 17:16:10
Done.
 | 
| + GURL(), | 
| + NEW_FOREGROUND_TAB, | 
| + PageTransition::LINK); | 
| + break; | 
| + } | 
| + | 
| default: | 
| NOTREACHED(); | 
| break; |