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

Side by Side Diff: chrome/browser/renderer_context_menu/render_view_context_menu.cc

Issue 260903010: Start removing support for the experimental x-webkit-speech API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't touch histograms.xml Created 6 years, 7 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 | Annotate | Revision Log
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 <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 { 39, IDC_CONTENT_CONTEXT_COPY }, 192 { 39, IDC_CONTENT_CONTEXT_COPY },
193 { 40, IDC_CONTENT_CONTEXT_PASTE }, 193 { 40, IDC_CONTENT_CONTEXT_PASTE },
194 { 41, IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE }, 194 { 41, IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE },
195 { 42, IDC_CONTENT_CONTEXT_DELETE }, 195 { 42, IDC_CONTENT_CONTEXT_DELETE },
196 { 43, IDC_CONTENT_CONTEXT_SELECTALL }, 196 { 43, IDC_CONTENT_CONTEXT_SELECTALL },
197 { 44, IDC_CONTENT_CONTEXT_SEARCHWEBFOR }, 197 { 44, IDC_CONTENT_CONTEXT_SEARCHWEBFOR },
198 { 45, IDC_CONTENT_CONTEXT_GOTOURL }, 198 { 45, IDC_CONTENT_CONTEXT_GOTOURL },
199 { 46, IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS }, 199 { 46, IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS },
200 { 47, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS }, 200 { 47, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS },
201 { 48, IDC_CONTENT_CONTEXT_ADDSEARCHENGINE }, 201 { 48, IDC_CONTENT_CONTEXT_ADDSEARCHENGINE },
202 { 49, IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES },
203 { 50, IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT },
204 { 51, IDC_SPEECH_INPUT_MENU },
205 { 52, IDC_CONTENT_CONTEXT_OPENLINKWITH }, 202 { 52, IDC_CONTENT_CONTEXT_OPENLINKWITH },
206 { 53, IDC_CHECK_SPELLING_WHILE_TYPING }, 203 { 53, IDC_CHECK_SPELLING_WHILE_TYPING },
207 { 54, IDC_SPELLCHECK_MENU }, 204 { 54, IDC_SPELLCHECK_MENU },
208 { 55, IDC_CONTENT_CONTEXT_SPELLING_TOGGLE }, 205 { 55, IDC_CONTENT_CONTEXT_SPELLING_TOGGLE },
209 { 56, IDC_SPELLCHECK_LANGUAGES_FIRST }, 206 { 56, IDC_SPELLCHECK_LANGUAGES_FIRST },
210 { 57, IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE }, 207 { 57, IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE },
211 // Add new items here and use |enum_id| from the next line. 208 // Add new items here and use |enum_id| from the next line.
212 { 58, 0 }, // Must be the last. Increment |enum_id| when new IDC was added. 209 { 58, 0 }, // Must be the last. Increment |enum_id| when new IDC was added.
213 }; 210 };
214 211
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 source_web_contents_(WebContents::FromRenderFrameHost(render_frame_host)), 402 source_web_contents_(WebContents::FromRenderFrameHost(render_frame_host)),
406 render_process_id_(render_frame_host->GetProcess()->GetID()), 403 render_process_id_(render_frame_host->GetProcess()->GetID()),
407 render_frame_id_(render_frame_host->GetRoutingID()), 404 render_frame_id_(render_frame_host->GetRoutingID()),
408 profile_(Profile::FromBrowserContext( 405 profile_(Profile::FromBrowserContext(
409 source_web_contents_->GetBrowserContext())), 406 source_web_contents_->GetBrowserContext())),
410 menu_model_(this), 407 menu_model_(this),
411 extension_items_(profile_, 408 extension_items_(profile_,
412 this, 409 this,
413 &menu_model_, 410 &menu_model_,
414 base::Bind(MenuItemMatchesParams, params_)), 411 base::Bind(MenuItemMatchesParams, params_)),
415 speech_input_submenu_model_(this),
416 protocol_handler_submenu_model_(this), 412 protocol_handler_submenu_model_(this),
417 protocol_handler_registry_( 413 protocol_handler_registry_(
418 ProtocolHandlerRegistryFactory::GetForProfile(profile_)), 414 ProtocolHandlerRegistryFactory::GetForProfile(profile_)),
419 command_executed_(false) { 415 command_executed_(false) {
420 content_type_.reset(ContextMenuContentTypeFactory::Create( 416 content_type_.reset(ContextMenuContentTypeFactory::Create(
421 source_web_contents_, params)); 417 source_web_contents_, params));
422 } 418 }
423 419
424 RenderViewContextMenu::~RenderViewContextMenu() { 420 RenderViewContextMenu::~RenderViewContextMenu() {
425 } 421 }
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 1011 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
1016 1012
1017 if (use_spellcheck_and_search && !params_.keyword_url.is_empty()) { 1013 if (use_spellcheck_and_search && !params_.keyword_url.is_empty()) {
1018 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ADDSEARCHENGINE, 1014 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ADDSEARCHENGINE,
1019 IDS_CONTENT_CONTEXT_ADDSEARCHENGINE); 1015 IDS_CONTENT_CONTEXT_ADDSEARCHENGINE);
1020 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 1016 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
1021 } 1017 }
1022 1018
1023 if (use_spellcheck_and_search) 1019 if (use_spellcheck_and_search)
1024 AppendSpellcheckOptionsSubMenu(); 1020 AppendSpellcheckOptionsSubMenu();
1025 AppendSpeechInputOptionsSubMenu();
1026 AppendPlatformEditableItems(); 1021 AppendPlatformEditableItems();
1027 1022
1028 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 1023 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
1029 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL, 1024 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL,
1030 IDS_CONTENT_CONTEXT_SELECTALL); 1025 IDS_CONTENT_CONTEXT_SELECTALL);
1031 } 1026 }
1032 1027
1033 void RenderViewContextMenu::AppendSpellingSuggestionsSubMenu() { 1028 void RenderViewContextMenu::AppendSpellingSuggestionsSubMenu() {
1034 if (!spelling_menu_observer_.get()) 1029 if (!spelling_menu_observer_.get())
1035 spelling_menu_observer_.reset(new SpellingMenuObserver(this)); 1030 spelling_menu_observer_.reset(new SpellingMenuObserver(this));
1036 observers_.AddObserver(spelling_menu_observer_.get()); 1031 observers_.AddObserver(spelling_menu_observer_.get());
1037 spelling_menu_observer_->InitMenu(params_); 1032 spelling_menu_observer_->InitMenu(params_);
1038 } 1033 }
1039 1034
1040 void RenderViewContextMenu::AppendSpellcheckOptionsSubMenu() { 1035 void RenderViewContextMenu::AppendSpellcheckOptionsSubMenu() {
1041 if (!spellchecker_submenu_observer_.get()) { 1036 if (!spellchecker_submenu_observer_.get()) {
1042 spellchecker_submenu_observer_.reset(new SpellCheckerSubMenuObserver( 1037 spellchecker_submenu_observer_.reset(new SpellCheckerSubMenuObserver(
1043 this, this, kSpellcheckRadioGroup)); 1038 this, this, kSpellcheckRadioGroup));
1044 } 1039 }
1045 spellchecker_submenu_observer_->InitMenu(params_); 1040 spellchecker_submenu_observer_->InitMenu(params_);
1046 observers_.AddObserver(spellchecker_submenu_observer_.get()); 1041 observers_.AddObserver(spellchecker_submenu_observer_.get());
1047 } 1042 }
1048 1043
1049 void RenderViewContextMenu::AppendSpeechInputOptionsSubMenu() {
1050 if (params_.speech_input_enabled) {
1051 speech_input_submenu_model_.AddCheckItem(
1052 IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES,
1053 l10n_util::GetStringUTF16(
1054 IDS_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES));
1055
1056 speech_input_submenu_model_.AddItemWithStringId(
1057 IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT,
1058 IDS_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT);
1059
1060 menu_model_.AddSubMenu(
1061 IDC_SPEECH_INPUT_MENU,
1062 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPEECH_INPUT_MENU),
1063 &speech_input_submenu_model_);
1064 }
1065 }
1066
1067 void RenderViewContextMenu::AppendProtocolHandlerSubMenu() { 1044 void RenderViewContextMenu::AppendProtocolHandlerSubMenu() {
1068 const ProtocolHandlerRegistry::ProtocolHandlerList handlers = 1045 const ProtocolHandlerRegistry::ProtocolHandlerList handlers =
1069 GetHandlersForLinkUrl(); 1046 GetHandlersForLinkUrl();
1070 if (handlers.empty()) 1047 if (handlers.empty())
1071 return; 1048 return;
1072 size_t max = IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST - 1049 size_t max = IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST -
1073 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; 1050 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST;
1074 for (size_t i = 0; i < handlers.size() && i <= max; i++) { 1051 for (size_t i = 0; i < handlers.size() && i <= max; i++) {
1075 protocol_handler_submenu_model_.AddItem( 1052 protocol_handler_submenu_model_.AddItem(
1076 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST + i, 1053 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST + i,
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 case IDC_INPUT_METHODS_MENU: 1347 case IDC_INPUT_METHODS_MENU:
1371 return true; 1348 return true;
1372 #endif 1349 #endif
1373 1350
1374 case IDC_CONTENT_CONTEXT_ADDSEARCHENGINE: 1351 case IDC_CONTENT_CONTEXT_ADDSEARCHENGINE:
1375 return !params_.keyword_url.is_empty(); 1352 return !params_.keyword_url.is_empty();
1376 1353
1377 case IDC_SPELLCHECK_MENU: 1354 case IDC_SPELLCHECK_MENU:
1378 return true; 1355 return true;
1379 1356
1380 case IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES:
1381 case IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT:
1382 case IDC_SPEECH_INPUT_MENU:
1383 return true;
1384
1385 case IDC_CONTENT_CONTEXT_OPENLINKWITH: 1357 case IDC_CONTENT_CONTEXT_OPENLINKWITH:
1386 return true; 1358 return true;
1387 1359
1388 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: 1360 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS:
1389 return true; 1361 return true;
1390 1362
1391 default: 1363 default:
1392 NOTREACHED(); 1364 NOTREACHED();
1393 return false; 1365 return false;
1394 } 1366 }
(...skipping 25 matching lines...) Expand all
1420 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { 1392 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) {
1421 return IsCustomItemChecked(params_.custom_items, id); 1393 return IsCustomItemChecked(params_.custom_items, id);
1422 } 1394 }
1423 1395
1424 // Extension items. 1396 // Extension items.
1425 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 1397 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
1426 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 1398 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
1427 return extension_items_.IsCommandIdChecked(id); 1399 return extension_items_.IsCommandIdChecked(id);
1428 } 1400 }
1429 1401
1430 #if defined(ENABLE_INPUT_SPEECH)
1431 // Check box for menu item 'Block offensive words'.
1432 if (id == IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES) {
1433 return profile_->GetPrefs()->GetBoolean(
1434 prefs::kSpeechRecognitionFilterProfanities);
1435 }
1436 #endif
1437
1438 return false; 1402 return false;
1439 } 1403 }
1440 1404
1441 void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { 1405 void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
1442 command_executed_ = true; 1406 command_executed_ = true;
1443 // If this command is is added by one of our observers, we dispatch it to the 1407 // If this command is is added by one of our observers, we dispatch it to the
1444 // observer. 1408 // observer.
1445 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); 1409 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_);
1446 RenderViewContextMenuObserver* observer; 1410 RenderViewContextMenuObserver* observer;
1447 while ((observer = it.GetNext()) != NULL) { 1411 while ((observer = it.GetNext()) != NULL) {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 data.SetURL(params_.keyword_url.spec()); 1818 data.SetURL(params_.keyword_url.spec());
1855 data.favicon_url = 1819 data.favicon_url =
1856 TemplateURL::GenerateFaviconURL(params_.page_url.GetOrigin()); 1820 TemplateURL::GenerateFaviconURL(params_.page_url.GetOrigin());
1857 // Takes ownership of the TemplateURL. 1821 // Takes ownership of the TemplateURL.
1858 search_engine_tab_helper->delegate()-> 1822 search_engine_tab_helper->delegate()->
1859 ConfirmAddSearchProvider(new TemplateURL(profile_, data), profile_); 1823 ConfirmAddSearchProvider(new TemplateURL(profile_, data), profile_);
1860 } 1824 }
1861 break; 1825 break;
1862 } 1826 }
1863 1827
1864 #if defined(ENABLE_INPUT_SPEECH)
1865 case IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES: {
1866 profile_->GetPrefs()->SetBoolean(
1867 prefs::kSpeechRecognitionFilterProfanities,
1868 !profile_->GetPrefs()->GetBoolean(
1869 prefs::kSpeechRecognitionFilterProfanities));
1870 break;
1871 }
1872 #endif
1873 case IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT: {
1874 GURL url(chrome::kSpeechInputAboutURL);
1875 GURL localized_url = google_util::AppendGoogleLocaleParam(url);
1876 // Open URL with no referrer field (because user clicked on menu item).
1877 OpenURL(localized_url, GURL(), NEW_FOREGROUND_TAB,
1878 content::PAGE_TRANSITION_LINK);
1879 break;
1880 }
1881
1882 default: 1828 default:
1883 NOTREACHED(); 1829 NOTREACHED();
1884 break; 1830 break;
1885 } 1831 }
1886 } 1832 }
1887 1833
1888 ProtocolHandlerRegistry::ProtocolHandlerList 1834 ProtocolHandlerRegistry::ProtocolHandlerList
1889 RenderViewContextMenu::GetHandlersForLinkUrl() { 1835 RenderViewContextMenu::GetHandlersForLinkUrl() {
1890 ProtocolHandlerRegistry::ProtocolHandlerList handlers = 1836 ProtocolHandlerRegistry::ProtocolHandlerList handlers =
1891 protocol_handler_registry_->GetHandlersFor(params_.link_url.scheme()); 1837 protocol_handler_registry_->GetHandlersFor(params_.link_url.scheme());
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 source_web_contents_->GetRenderViewHost()-> 1967 source_web_contents_->GetRenderViewHost()->
2022 ExecuteMediaPlayerActionAtLocation(location, action); 1968 ExecuteMediaPlayerActionAtLocation(location, action);
2023 } 1969 }
2024 1970
2025 void RenderViewContextMenu::PluginActionAt( 1971 void RenderViewContextMenu::PluginActionAt(
2026 const gfx::Point& location, 1972 const gfx::Point& location,
2027 const WebPluginAction& action) { 1973 const WebPluginAction& action) {
2028 source_web_contents_->GetRenderViewHost()-> 1974 source_web_contents_->GetRenderViewHost()->
2029 ExecutePluginActionAtLocation(location, action); 1975 ExecutePluginActionAtLocation(location, action);
2030 } 1976 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698