OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/tab_contents/render_view_context_menu.h" | 5 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
6 | 6 |
7 #include "app/clipboard/clipboard.h" | 7 #include "app/clipboard/clipboard.h" |
8 #include "app/clipboard/scoped_clipboard_writer.h" | 8 #include "app/clipboard/scoped_clipboard_writer.h" |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "chrome/app/chrome_dll_resource.h" | 12 #include "chrome/app/chrome_dll_resource.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/debugger/devtools_manager.h" | 14 #include "chrome/browser/debugger/devtools_manager.h" |
15 #include "chrome/browser/download/download_manager.h" | 15 #include "chrome/browser/download/download_manager.h" |
16 #include "chrome/browser/fonts_languages_window.h" | 16 #include "chrome/browser/fonts_languages_window.h" |
17 #include "chrome/browser/metrics/user_metrics.h" | 17 #include "chrome/browser/metrics/user_metrics.h" |
18 #include "chrome/browser/net/browser_url_util.h" | 18 #include "chrome/browser/net/browser_url_util.h" |
19 #include "chrome/browser/page_info_window.h" | 19 #include "chrome/browser/page_info_window.h" |
20 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
21 #include "chrome/browser/search_versus_navigate_classifier.h" | 21 #include "chrome/browser/search_versus_navigate_classifier.h" |
22 #include "chrome/browser/search_engines/template_url_model.h" | 22 #include "chrome/browser/search_engines/template_url_model.h" |
| 23 #if defined(SPELLCHECKER_IN_RENDERER) |
| 24 #include "chrome/browser/spellcheck_host.h" |
| 25 #endif |
23 #include "chrome/browser/spellchecker.h" | 26 #include "chrome/browser/spellchecker.h" |
24 #include "chrome/browser/spellchecker_platform_engine.h" | 27 #include "chrome/browser/spellchecker_platform_engine.h" |
25 #include "chrome/browser/tab_contents/navigation_entry.h" | 28 #include "chrome/browser/tab_contents/navigation_entry.h" |
26 #include "chrome/browser/tab_contents/tab_contents.h" | 29 #include "chrome/browser/tab_contents/tab_contents.h" |
27 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/platform_util.h" | 31 #include "chrome/common/platform_util.h" |
29 #include "chrome/common/pref_service.h" | 32 #include "chrome/common/pref_service.h" |
30 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
31 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
32 #include "net/base/escape.h" | 35 #include "net/base/escape.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // Add item in the sub menu to pop up the fonts and languages options menu. | 287 // Add item in the sub menu to pop up the fonts and languages options menu. |
285 AppendSeparator(); | 288 AppendSeparator(); |
286 AppendMenuItem(IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); | 289 AppendMenuItem(IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); |
287 | 290 |
288 // Add 'Check the spelling of this field' item in the sub menu. | 291 // Add 'Check the spelling of this field' item in the sub menu. |
289 AppendCheckboxMenuItem( | 292 AppendCheckboxMenuItem( |
290 IDC_CHECK_SPELLING_OF_THIS_FIELD, | 293 IDC_CHECK_SPELLING_OF_THIS_FIELD, |
291 l10n_util::GetStringUTF16( | 294 l10n_util::GetStringUTF16( |
292 IDS_CONTENT_CONTEXT_CHECK_SPELLING_OF_THIS_FIELD)); | 295 IDS_CONTENT_CONTEXT_CHECK_SPELLING_OF_THIS_FIELD)); |
293 | 296 |
294 // Add option for showing the spelling panel if the platfrom spellchecker | 297 // Add option for showing the spelling panel if the platform spellchecker |
295 // supports it. | 298 // supports it. |
296 if (SpellCheckerPlatform::SpellCheckerAvailable() && | 299 if (SpellCheckerPlatform::SpellCheckerAvailable() && |
297 SpellCheckerPlatform::SpellCheckerProvidesPanel()) { | 300 SpellCheckerPlatform::SpellCheckerProvidesPanel()) { |
298 AppendCheckboxMenuItem(IDC_SPELLPANEL_TOGGLE, l10n_util::GetStringUTF16( | 301 AppendCheckboxMenuItem(IDC_SPELLPANEL_TOGGLE, l10n_util::GetStringUTF16( |
299 SpellCheckerPlatform::SpellingPanelVisible() ? | 302 SpellCheckerPlatform::SpellingPanelVisible() ? |
300 IDS_CONTENT_CONTEXT_HIDE_SPELLING_PANEL : | 303 IDS_CONTENT_CONTEXT_HIDE_SPELLING_PANEL : |
301 IDS_CONTENT_CONTEXT_SHOW_SPELLING_PANEL)); | 304 IDS_CONTENT_CONTEXT_SHOW_SPELLING_PANEL)); |
302 } | 305 } |
303 FinishSubMenu(); | 306 FinishSubMenu(); |
304 | 307 |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 case IDC_SPELLCHECK_SUGGESTION_2: | 716 case IDC_SPELLCHECK_SUGGESTION_2: |
714 case IDC_SPELLCHECK_SUGGESTION_3: | 717 case IDC_SPELLCHECK_SUGGESTION_3: |
715 case IDC_SPELLCHECK_SUGGESTION_4: | 718 case IDC_SPELLCHECK_SUGGESTION_4: |
716 source_tab_contents_->render_view_host()->Replace( | 719 source_tab_contents_->render_view_host()->Replace( |
717 params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]); | 720 params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]); |
718 break; | 721 break; |
719 | 722 |
720 case IDC_CHECK_SPELLING_OF_THIS_FIELD: | 723 case IDC_CHECK_SPELLING_OF_THIS_FIELD: |
721 source_tab_contents_->render_view_host()->ToggleSpellCheck(); | 724 source_tab_contents_->render_view_host()->ToggleSpellCheck(); |
722 break; | 725 break; |
723 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: | 726 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: { |
| 727 #if defined(SPELLCHECKER_IN_RENDERER) |
| 728 SpellCheckHost* spellcheck_host = profile_->GetSpellCheckHost(); |
| 729 if (!spellcheck_host) { |
| 730 NOTREACHED(); |
| 731 break; |
| 732 } |
| 733 spellcheck_host->AddWord(UTF16ToUTF8(params_.misspelled_word)); |
| 734 #else |
724 source_tab_contents_->render_view_host()->AddToDictionary( | 735 source_tab_contents_->render_view_host()->AddToDictionary( |
725 params_.misspelled_word); | 736 params_.misspelled_word); |
| 737 #endif |
726 break; | 738 break; |
| 739 } |
727 | 740 |
728 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: | 741 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: |
729 ShowFontsLanguagesWindow( | 742 ShowFontsLanguagesWindow( |
730 platform_util::GetTopLevel( | 743 platform_util::GetTopLevel( |
731 source_tab_contents_->GetContentNativeView()), | 744 source_tab_contents_->GetContentNativeView()), |
732 LANGUAGES_PAGE, profile_); | 745 LANGUAGES_PAGE, profile_); |
733 break; | 746 break; |
734 | 747 |
735 case IDC_SPELLPANEL_TOGGLE: | 748 case IDC_SPELLPANEL_TOGGLE: |
736 source_tab_contents_->render_view_host()->ToggleSpellPanel( | 749 source_tab_contents_->render_view_host()->ToggleSpellPanel( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 823 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
811 g_browser_process->clipboard()); | 824 g_browser_process->clipboard()); |
812 } | 825 } |
813 | 826 |
814 void RenderViewContextMenu::MediaPlayerActionAt( | 827 void RenderViewContextMenu::MediaPlayerActionAt( |
815 const gfx::Point& location, | 828 const gfx::Point& location, |
816 const WebMediaPlayerAction& action) { | 829 const WebMediaPlayerAction& action) { |
817 source_tab_contents_->render_view_host()->MediaPlayerActionAt( | 830 source_tab_contents_->render_view_host()->MediaPlayerActionAt( |
818 location, action); | 831 location, action); |
819 } | 832 } |
OLD | NEW |