| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 8 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/printing/print_preview_tab_controller.h" | 32 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 33 #include "chrome/browser/printing/print_view_manager.h" | 33 #include "chrome/browser/printing/print_view_manager.h" |
| 34 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
| 35 #include "chrome/browser/profiles/profile_io_data.h" | 35 #include "chrome/browser/profiles/profile_io_data.h" |
| 36 #include "chrome/browser/search_engines/template_url.h" | 36 #include "chrome/browser/search_engines/template_url.h" |
| 37 #include "chrome/browser/search_engines/template_url_service.h" | 37 #include "chrome/browser/search_engines/template_url_service.h" |
| 38 #include "chrome/browser/search_engines/template_url_service_factory.h" | 38 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 39 #include "chrome/browser/spellchecker/spellcheck_host.h" | 39 #include "chrome/browser/spellchecker/spellcheck_host.h" |
| 40 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 40 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
| 41 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" | 41 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" |
| 42 #include "chrome/browser/tab_contents/spellchecker_submenu_observer.h" |
| 42 #include "chrome/browser/tab_contents/spelling_menu_observer.h" | 43 #include "chrome/browser/tab_contents/spelling_menu_observer.h" |
| 43 #include "chrome/browser/translate/translate_manager.h" | 44 #include "chrome/browser/translate/translate_manager.h" |
| 44 #include "chrome/browser/translate/translate_prefs.h" | 45 #include "chrome/browser/translate/translate_prefs.h" |
| 45 #include "chrome/browser/translate/translate_tab_helper.h" | 46 #include "chrome/browser/translate/translate_tab_helper.h" |
| 46 #include "chrome/browser/ui/browser.h" | 47 #include "chrome/browser/ui/browser.h" |
| 47 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 48 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
| 48 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 49 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 49 #include "chrome/common/chrome_constants.h" | 50 #include "chrome/common/chrome_constants.h" |
| 50 #include "chrome/common/chrome_switches.h" | 51 #include "chrome/common/chrome_switches.h" |
| 51 #include "chrome/common/pref_names.h" | 52 #include "chrome/common/pref_names.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 static const int kSpellcheckRadioGroup = 1; | 221 static const int kSpellcheckRadioGroup = 1; |
| 221 | 222 |
| 222 RenderViewContextMenu::RenderViewContextMenu( | 223 RenderViewContextMenu::RenderViewContextMenu( |
| 223 TabContents* tab_contents, | 224 TabContents* tab_contents, |
| 224 const ContextMenuParams& params) | 225 const ContextMenuParams& params) |
| 225 : params_(params), | 226 : params_(params), |
| 226 source_tab_contents_(tab_contents), | 227 source_tab_contents_(tab_contents), |
| 227 profile_(Profile::FromBrowserContext(tab_contents->browser_context())), | 228 profile_(Profile::FromBrowserContext(tab_contents->browser_context())), |
| 228 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)), | 229 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)), |
| 229 external_(false), | 230 external_(false), |
| 230 ALLOW_THIS_IN_INITIALIZER_LIST(spellcheck_submenu_model_(this)), | |
| 231 ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_submenu_model_(this)), | 231 ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_submenu_model_(this)), |
| 232 ALLOW_THIS_IN_INITIALIZER_LIST(bidi_submenu_model_(this)), | 232 ALLOW_THIS_IN_INITIALIZER_LIST(bidi_submenu_model_(this)), |
| 233 ALLOW_THIS_IN_INITIALIZER_LIST(protocol_handler_submenu_model_(this)), | 233 ALLOW_THIS_IN_INITIALIZER_LIST(protocol_handler_submenu_model_(this)), |
| 234 protocol_handler_registry_(profile_->GetProtocolHandlerRegistry()) { | 234 protocol_handler_registry_(profile_->GetProtocolHandlerRegistry()) { |
| 235 } | 235 } |
| 236 | 236 |
| 237 RenderViewContextMenu::~RenderViewContextMenu() { | 237 RenderViewContextMenu::~RenderViewContextMenu() { |
| 238 } | 238 } |
| 239 | 239 |
| 240 // Menu construction functions ------------------------------------------------- | 240 // Menu construction functions ------------------------------------------------- |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 case WebContextMenuData::MediaTypePlugin: | 567 case WebContextMenuData::MediaTypePlugin: |
| 568 AppendPluginItems(); | 568 AppendPluginItems(); |
| 569 break; | 569 break; |
| 570 #ifdef WEBCONTEXT_MEDIATYPEFILE_DEFINED | 570 #ifdef WEBCONTEXT_MEDIATYPEFILE_DEFINED |
| 571 case WebContextMenuData::MediaTypeFile: | 571 case WebContextMenuData::MediaTypeFile: |
| 572 break; | 572 break; |
| 573 #endif | 573 #endif |
| 574 } | 574 } |
| 575 | 575 |
| 576 if (params_.is_editable) { | 576 if (params_.is_editable) { |
| 577 // Add a menu item that shows suggestions from the Spelling service. | 577 // Add a menu item that shows suggestions. |
| 578 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 578 if (!spelling_menu_observer_.get()) { |
| 579 if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) { | 579 spelling_menu_observer_.reset( |
| 580 PrefService* pref = profile_->GetPrefs(); | 580 new SpellingMenuObserver(this)); |
| 581 bool use_spelling_service = | |
| 582 pref && pref->GetBoolean(prefs::kSpellCheckUseSpellingService); | |
| 583 if (use_spelling_service) { | |
| 584 if (!spelling_menu_observer_.get()) | |
| 585 spelling_menu_observer_.reset(new SpellingMenuObserver(this)); | |
| 586 | |
| 587 if (spelling_menu_observer_.get()) | |
| 588 observers_.AddObserver(spelling_menu_observer_.get()); | |
| 589 } | |
| 590 } | 581 } |
| 582 if (spelling_menu_observer_.get()) |
| 583 observers_.AddObserver(spelling_menu_observer_.get()); |
| 591 } | 584 } |
| 592 | 585 |
| 593 // Ask our observers to add their menu items. | 586 // Ask our observers to add their menu items. |
| 594 FOR_EACH_OBSERVER(RenderViewContextMenuObserver, observers_, | 587 FOR_EACH_OBSERVER(RenderViewContextMenuObserver, observers_, |
| 595 InitMenu(params_)); | 588 InitMenu(params_)); |
| 596 | 589 |
| 597 if (params_.is_editable) | 590 if (params_.is_editable) |
| 598 AppendEditableItems(); | 591 AppendEditableItems(); |
| 599 else if (has_selection) | 592 else if (has_selection) |
| 600 AppendCopyItem(); | 593 AppendCopyItem(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 611 void RenderViewContextMenu::LookUpInDictionary() { | 604 void RenderViewContextMenu::LookUpInDictionary() { |
| 612 // Used only in the Mac port. | 605 // Used only in the Mac port. |
| 613 NOTREACHED(); | 606 NOTREACHED(); |
| 614 } | 607 } |
| 615 | 608 |
| 616 void RenderViewContextMenu::AddMenuItem(int command_id, | 609 void RenderViewContextMenu::AddMenuItem(int command_id, |
| 617 const string16& title) { | 610 const string16& title) { |
| 618 menu_model_.AddItem(command_id, title); | 611 menu_model_.AddItem(command_id, title); |
| 619 } | 612 } |
| 620 | 613 |
| 614 void RenderViewContextMenu::AddSubMenu(int command_id, |
| 615 const string16& label, |
| 616 ui::MenuModel* model) { |
| 617 menu_model_.AddSubMenu(command_id, label, model); |
| 618 } |
| 619 |
| 621 void RenderViewContextMenu::UpdateMenuItem(int command_id, | 620 void RenderViewContextMenu::UpdateMenuItem(int command_id, |
| 622 bool enabled, | 621 bool enabled, |
| 623 bool hidden, | 622 bool hidden, |
| 624 const string16& label) { | 623 const string16& label) { |
| 625 // This function needs platform-specific implementation. | 624 // This function needs platform-specific implementation. |
| 626 NOTIMPLEMENTED(); | 625 NOTIMPLEMENTED(); |
| 627 } | 626 } |
| 628 | 627 |
| 629 | |
| 630 RenderViewHost* RenderViewContextMenu::GetRenderViewHost() const { | 628 RenderViewHost* RenderViewContextMenu::GetRenderViewHost() const { |
| 631 return source_tab_contents_->render_view_host(); | 629 return source_tab_contents_->render_view_host(); |
| 632 } | 630 } |
| 633 | 631 |
| 634 Profile* RenderViewContextMenu::GetProfile() const { | 632 Profile* RenderViewContextMenu::GetProfile() const { |
| 635 return profile_; | 633 return profile_; |
| 636 } | 634 } |
| 637 | 635 |
| 638 bool RenderViewContextMenu::AppendCustomItems() { | 636 bool RenderViewContextMenu::AppendCustomItems() { |
| 639 size_t total_items = 0; | 637 size_t total_items = 0; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 // This functionality is exposed as a keyboard shortcut on Windows & Linux. | 899 // This functionality is exposed as a keyboard shortcut on Windows & Linux. |
| 902 AppendBidiSubMenu(); | 900 AppendBidiSubMenu(); |
| 903 #endif // OS_MACOSX | 901 #endif // OS_MACOSX |
| 904 | 902 |
| 905 menu_model_.AddSeparator(); | 903 menu_model_.AddSeparator(); |
| 906 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL, | 904 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL, |
| 907 IDS_CONTENT_CONTEXT_SELECTALL); | 905 IDS_CONTENT_CONTEXT_SELECTALL); |
| 908 } | 906 } |
| 909 | 907 |
| 910 void RenderViewContextMenu::AppendSpellcheckOptionsSubMenu() { | 908 void RenderViewContextMenu::AppendSpellcheckOptionsSubMenu() { |
| 911 // Add Spell Check languages to sub menu. | 909 if (!spellchecker_submenu_observer_.get()) { |
| 912 std::vector<std::string> spellcheck_languages; | 910 spellchecker_submenu_observer_.reset(new SpellCheckerSubMenuObserver( |
| 913 SpellCheckHost::GetSpellCheckLanguages(profile_, | 911 this, this, kSpellcheckRadioGroup)); |
| 914 &spellcheck_languages); | |
| 915 DCHECK(spellcheck_languages.size() < | |
| 916 IDC_SPELLCHECK_LANGUAGES_LAST - IDC_SPELLCHECK_LANGUAGES_FIRST); | |
| 917 const std::string app_locale = g_browser_process->GetApplicationLocale(); | |
| 918 for (size_t i = 0; i < spellcheck_languages.size(); ++i) { | |
| 919 string16 display_name(l10n_util::GetDisplayNameForLocale( | |
| 920 spellcheck_languages[i], app_locale, true)); | |
| 921 spellcheck_submenu_model_.AddRadioItem( | |
| 922 IDC_SPELLCHECK_LANGUAGES_FIRST + i, | |
| 923 display_name, | |
| 924 kSpellcheckRadioGroup); | |
| 925 } | 912 } |
| 926 | 913 if (spellchecker_submenu_observer_.get()) { |
| 927 // Add item in the sub menu to pop up the fonts and languages options menu. | 914 spellchecker_submenu_observer_->InitMenu(params_); |
| 928 spellcheck_submenu_model_.AddSeparator(); | 915 observers_.AddObserver(spellchecker_submenu_observer_.get()); |
| 929 spellcheck_submenu_model_.AddItemWithStringId( | |
| 930 IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, | |
| 931 IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); | |
| 932 | |
| 933 // Add 'Check the spelling of this field' item in the sub menu. | |
| 934 spellcheck_submenu_model_.AddCheckItem( | |
| 935 IDC_CHECK_SPELLING_OF_THIS_FIELD, | |
| 936 l10n_util::GetStringUTF16( | |
| 937 IDS_CONTENT_CONTEXT_CHECK_SPELLING_OF_THIS_FIELD)); | |
| 938 | |
| 939 // Add option for showing the spelling panel if the platform spellchecker | |
| 940 // supports it. | |
| 941 if (SpellCheckerPlatform::SpellCheckerAvailable() && | |
| 942 SpellCheckerPlatform::SpellCheckerProvidesPanel()) { | |
| 943 spellcheck_submenu_model_.AddCheckItem( | |
| 944 IDC_SPELLPANEL_TOGGLE, | |
| 945 l10n_util::GetStringUTF16( | |
| 946 SpellCheckerPlatform::SpellingPanelVisible() ? | |
| 947 IDS_CONTENT_CONTEXT_HIDE_SPELLING_PANEL : | |
| 948 IDS_CONTENT_CONTEXT_SHOW_SPELLING_PANEL)); | |
| 949 } | 916 } |
| 950 | |
| 951 menu_model_.AddSubMenu( | |
| 952 IDC_SPELLCHECK_MENU, | |
| 953 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPELLCHECK_MENU), | |
| 954 &spellcheck_submenu_model_); | |
| 955 } | 917 } |
| 956 | 918 |
| 957 void RenderViewContextMenu::AppendSpeechInputOptionsSubMenu() { | 919 void RenderViewContextMenu::AppendSpeechInputOptionsSubMenu() { |
| 958 if (params_.speech_input_enabled) { | 920 if (params_.speech_input_enabled) { |
| 959 speech_input_submenu_model_.AddCheckItem( | 921 speech_input_submenu_model_.AddCheckItem( |
| 960 IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES, | 922 IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES, |
| 961 l10n_util::GetStringUTF16( | 923 l10n_util::GetStringUTF16( |
| 962 IDS_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES)); | 924 IDS_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES)); |
| 963 | 925 |
| 964 speech_input_submenu_model_.AddItemWithStringId( | 926 speech_input_submenu_model_.AddItemWithStringId( |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: | 1295 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: |
| 1334 return true; | 1296 return true; |
| 1335 | 1297 |
| 1336 default: | 1298 default: |
| 1337 NOTREACHED(); | 1299 NOTREACHED(); |
| 1338 return false; | 1300 return false; |
| 1339 } | 1301 } |
| 1340 } | 1302 } |
| 1341 | 1303 |
| 1342 bool RenderViewContextMenu::IsCommandIdChecked(int id) const { | 1304 bool RenderViewContextMenu::IsCommandIdChecked(int id) const { |
| 1305 // If this command is is added by one of our observers, we dispatch it to the |
| 1306 // observer. |
| 1307 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); |
| 1308 RenderViewContextMenuObserver* observer; |
| 1309 while ((observer = it.GetNext()) != NULL) { |
| 1310 if (observer->IsCommandIdSupported(id)) |
| 1311 return observer->IsCommandIdChecked(id); |
| 1312 } |
| 1313 |
| 1343 // See if the video is set to looping. | 1314 // See if the video is set to looping. |
| 1344 if (id == IDC_CONTENT_CONTEXT_LOOP) { | 1315 if (id == IDC_CONTENT_CONTEXT_LOOP) { |
| 1345 return (params_.media_flags & | 1316 return (params_.media_flags & |
| 1346 WebContextMenuData::MediaLoop) != 0; | 1317 WebContextMenuData::MediaLoop) != 0; |
| 1347 } | 1318 } |
| 1348 | 1319 |
| 1349 if (id == IDC_CONTENT_CONTEXT_CONTROLS) { | 1320 if (id == IDC_CONTENT_CONTEXT_CONTROLS) { |
| 1350 return (params_.media_flags & | 1321 return (params_.media_flags & |
| 1351 WebContextMenuData::MediaControlRootElement) != 0; | 1322 WebContextMenuData::MediaControlRootElement) != 0; |
| 1352 } | 1323 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1374 if (id == IDC_WRITING_DIRECTION_RTL) | 1345 if (id == IDC_WRITING_DIRECTION_RTL) |
| 1375 return params_.writing_direction_right_to_left & | 1346 return params_.writing_direction_right_to_left & |
| 1376 WebContextMenuData::CheckableMenuItemChecked; | 1347 WebContextMenuData::CheckableMenuItemChecked; |
| 1377 if (id == IDC_WRITING_DIRECTION_LTR) | 1348 if (id == IDC_WRITING_DIRECTION_LTR) |
| 1378 return params_.writing_direction_left_to_right & | 1349 return params_.writing_direction_left_to_right & |
| 1379 WebContextMenuData::CheckableMenuItemChecked; | 1350 WebContextMenuData::CheckableMenuItemChecked; |
| 1380 if (id == IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY) | 1351 if (id == IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY) |
| 1381 return false; | 1352 return false; |
| 1382 #endif // OS_MACOSX | 1353 #endif // OS_MACOSX |
| 1383 | 1354 |
| 1384 // Check box for 'Check the Spelling of this field'. | |
| 1385 if (id == IDC_CHECK_SPELLING_OF_THIS_FIELD) { | |
| 1386 return (params_.spellcheck_enabled && | |
| 1387 profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)); | |
| 1388 } | |
| 1389 | |
| 1390 // Check box for menu item 'Block offensive words'. | 1355 // Check box for menu item 'Block offensive words'. |
| 1391 if (id == IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES) { | 1356 if (id == IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES) { |
| 1392 return profile_->GetPrefs()->GetBoolean( | 1357 return profile_->GetPrefs()->GetBoolean( |
| 1393 prefs::kSpeechInputFilterProfanities); | 1358 prefs::kSpeechInputFilterProfanities); |
| 1394 } | 1359 } |
| 1395 | 1360 |
| 1396 // Don't bother getting the display language vector if this isn't a spellcheck | 1361 return false; |
| 1397 // language. | |
| 1398 if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) || | |
| 1399 (id >= IDC_SPELLCHECK_LANGUAGES_LAST)) | |
| 1400 return false; | |
| 1401 | |
| 1402 std::vector<std::string> languages; | |
| 1403 return SpellCheckHost::GetSpellCheckLanguages(profile_, &languages) == | |
| 1404 (id - IDC_SPELLCHECK_LANGUAGES_FIRST); | |
| 1405 } | 1362 } |
| 1406 | 1363 |
| 1407 void RenderViewContextMenu::ExecuteCommand(int id) { | 1364 void RenderViewContextMenu::ExecuteCommand(int id) { |
| 1408 return ExecuteCommand(id, 0); | 1365 return ExecuteCommand(id, 0); |
| 1409 } | 1366 } |
| 1410 | 1367 |
| 1411 void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { | 1368 void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { |
| 1412 // If this command is is added by one of our observers, we dispatch it to the | 1369 // If this command is is added by one of our observers, we dispatch it to the |
| 1413 // observer. | 1370 // observer. |
| 1414 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); | 1371 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); |
| 1415 RenderViewContextMenuObserver* observer; | 1372 RenderViewContextMenuObserver* observer; |
| 1416 while ((observer = it.GetNext()) != NULL) { | 1373 while ((observer = it.GetNext()) != NULL) { |
| 1417 if (observer->IsCommandIdSupported(id)) | 1374 if (observer->IsCommandIdSupported(id)) |
| 1418 return observer->ExecuteCommand(id); | 1375 return observer->ExecuteCommand(id); |
| 1419 } | 1376 } |
| 1420 | 1377 |
| 1421 // Check to see if one of the spell check language ids have been clicked. | |
| 1422 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST && | |
| 1423 id < IDC_SPELLCHECK_LANGUAGES_LAST) { | |
| 1424 const size_t language_number = id - IDC_SPELLCHECK_LANGUAGES_FIRST; | |
| 1425 std::vector<std::string> languages; | |
| 1426 SpellCheckHost::GetSpellCheckLanguages(profile_, &languages); | |
| 1427 if (language_number < languages.size()) { | |
| 1428 StringPrefMember dictionary_language; | |
| 1429 dictionary_language.Init(prefs::kSpellCheckDictionary, | |
| 1430 profile_->GetPrefs(), NULL); | |
| 1431 dictionary_language.SetValue(languages[language_number]); | |
| 1432 } | |
| 1433 return; | |
| 1434 } | |
| 1435 | |
| 1436 RenderViewHost* rvh = source_tab_contents_->render_view_host(); | 1378 RenderViewHost* rvh = source_tab_contents_->render_view_host(); |
| 1437 | 1379 |
| 1438 // Process custom actions range. | 1380 // Process custom actions range. |
| 1439 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && | 1381 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && |
| 1440 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { | 1382 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { |
| 1441 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; | 1383 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; |
| 1442 rvh->ExecuteCustomContextMenuCommand(action, params_.custom_context); | 1384 rvh->ExecuteCustomContextMenuCommand(action, params_.custom_context); |
| 1443 return; | 1385 return; |
| 1444 } | 1386 } |
| 1445 | 1387 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 case IDC_SPELLCHECK_SUGGESTION_4: { | 1696 case IDC_SPELLCHECK_SUGGESTION_4: { |
| 1755 rvh->Replace( | 1697 rvh->Replace( |
| 1756 params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]); | 1698 params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]); |
| 1757 // GetSpellCheckHost() can return null when the suggested word is | 1699 // GetSpellCheckHost() can return null when the suggested word is |
| 1758 // provided by Web SpellCheck API. | 1700 // provided by Web SpellCheck API. |
| 1759 SpellCheckHost* spellcheck_host = profile_->GetSpellCheckHost(); | 1701 SpellCheckHost* spellcheck_host = profile_->GetSpellCheckHost(); |
| 1760 if (spellcheck_host && spellcheck_host->GetMetrics()) | 1702 if (spellcheck_host && spellcheck_host->GetMetrics()) |
| 1761 spellcheck_host->GetMetrics()->RecordReplacedWordStats(1); | 1703 spellcheck_host->GetMetrics()->RecordReplacedWordStats(1); |
| 1762 break; | 1704 break; |
| 1763 } | 1705 } |
| 1764 case IDC_CHECK_SPELLING_OF_THIS_FIELD: { | |
| 1765 rvh->Send(new SpellCheckMsg_ToggleSpellCheck(rvh->routing_id())); | |
| 1766 break; | |
| 1767 } | |
| 1768 case IDC_SPELLCHECK_ADD_TO_DICTIONARY: { | 1706 case IDC_SPELLCHECK_ADD_TO_DICTIONARY: { |
| 1769 // GetSpellCheckHost() can return null when the suggested word is | 1707 // GetSpellCheckHost() can return null when the suggested word is |
| 1770 // provided by Web SpellCheck API. | 1708 // provided by Web SpellCheck API. |
| 1771 if (profile_->GetSpellCheckHost()) | 1709 if (profile_->GetSpellCheckHost()) |
| 1772 profile_->GetSpellCheckHost()->AddWord( | 1710 profile_->GetSpellCheckHost()->AddWord( |
| 1773 UTF16ToUTF8(params_.misspelled_word)); | 1711 UTF16ToUTF8(params_.misspelled_word)); |
| 1774 SpellCheckerPlatform::AddWord(params_.misspelled_word); | 1712 SpellCheckerPlatform::AddWord(params_.misspelled_word); |
| 1775 break; | 1713 break; |
| 1776 } | 1714 } |
| 1777 | 1715 |
| 1778 case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: { | 1716 case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: { |
| 1779 WindowOpenDisposition disposition = | 1717 WindowOpenDisposition disposition = |
| 1780 ForceNewTabDispositionFromEventFlags(event_flags); | 1718 ForceNewTabDispositionFromEventFlags(event_flags); |
| 1781 std::string url = std::string(chrome::kChromeUISettingsURL) + | 1719 std::string url = std::string(chrome::kChromeUISettingsURL) + |
| 1782 chrome::kLanguageOptionsSubPage; | 1720 chrome::kLanguageOptionsSubPage; |
| 1783 OpenURL(GURL(url), GURL(), 0, disposition, content::PAGE_TRANSITION_LINK); | 1721 OpenURL(GURL(url), GURL(), 0, disposition, content::PAGE_TRANSITION_LINK); |
| 1784 break; | 1722 break; |
| 1785 } | 1723 } |
| 1786 | 1724 |
| 1787 case IDC_SPELLPANEL_TOGGLE: { | |
| 1788 rvh->Send(new SpellCheckMsg_ToggleSpellPanel( | |
| 1789 rvh->routing_id(), SpellCheckerPlatform::SpellingPanelVisible())); | |
| 1790 break; | |
| 1791 } | |
| 1792 | |
| 1793 #if defined(OS_MACOSX) | 1725 #if defined(OS_MACOSX) |
| 1794 case IDC_WRITING_DIRECTION_DEFAULT: | 1726 case IDC_WRITING_DIRECTION_DEFAULT: |
| 1795 // WebKit's current behavior is for this menu item to always be disabled. | 1727 // WebKit's current behavior is for this menu item to always be disabled. |
| 1796 NOTREACHED(); | 1728 NOTREACHED(); |
| 1797 break; | 1729 break; |
| 1798 case IDC_WRITING_DIRECTION_RTL: | 1730 case IDC_WRITING_DIRECTION_RTL: |
| 1799 case IDC_WRITING_DIRECTION_LTR: { | 1731 case IDC_WRITING_DIRECTION_LTR: { |
| 1800 WebKit::WebTextDirection dir = WebKit::WebTextDirectionLeftToRight; | 1732 WebKit::WebTextDirection dir = WebKit::WebTextDirectionLeftToRight; |
| 1801 if (id == IDC_WRITING_DIRECTION_RTL) | 1733 if (id == IDC_WRITING_DIRECTION_RTL) |
| 1802 dir = WebKit::WebTextDirectionRightToLeft; | 1734 dir = WebKit::WebTextDirectionRightToLeft; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1965 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 1897 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
| 1966 g_browser_process->clipboard()); | 1898 g_browser_process->clipboard()); |
| 1967 } | 1899 } |
| 1968 | 1900 |
| 1969 void RenderViewContextMenu::MediaPlayerActionAt( | 1901 void RenderViewContextMenu::MediaPlayerActionAt( |
| 1970 const gfx::Point& location, | 1902 const gfx::Point& location, |
| 1971 const WebMediaPlayerAction& action) { | 1903 const WebMediaPlayerAction& action) { |
| 1972 source_tab_contents_->render_view_host()-> | 1904 source_tab_contents_->render_view_host()-> |
| 1973 ExecuteMediaPlayerActionAtLocation(location, action); | 1905 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1974 } | 1906 } |
| OLD | NEW |