OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/clipboard.h" | 8 #include "base/clipboard.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/scoped_clipboard_writer.h" | 11 #include "base/scoped_clipboard_writer.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/page_info_window.h" | 18 #include "chrome/browser/page_info_window.h" |
19 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
20 #include "chrome/browser/search_engines/template_url_model.h" | 20 #include "chrome/browser/search_engines/template_url_model.h" |
21 #include "chrome/browser/spellchecker.h" | 21 #include "chrome/browser/spellchecker.h" |
| 22 #include "chrome/browser/spellchecker_platform_engine.h" |
22 #include "chrome/browser/tab_contents/navigation_entry.h" | 23 #include "chrome/browser/tab_contents/navigation_entry.h" |
23 #include "chrome/browser/tab_contents/tab_contents.h" | 24 #include "chrome/browser/tab_contents/tab_contents.h" |
24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/platform_util.h" | 26 #include "chrome/common/platform_util.h" |
26 #include "chrome/common/pref_service.h" | 27 #include "chrome/common/pref_service.h" |
27 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
29 #include "net/base/escape.h" | 30 #include "net/base/escape.h" |
30 #include "net/base/net_util.h" | 31 #include "net/base/net_util.h" |
31 #include "webkit/glue/media_player_action.h" | 32 #include "webkit/glue/media_player_action.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // Add item in the sub menu to pop up the fonts and languages options menu. | 252 // Add item in the sub menu to pop up the fonts and languages options menu. |
252 AppendSeparator(); | 253 AppendSeparator(); |
253 AppendMenuItem(IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); | 254 AppendMenuItem(IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); |
254 | 255 |
255 // Add 'Check the spelling of this field' item in the sub menu. | 256 // Add 'Check the spelling of this field' item in the sub menu. |
256 AppendCheckboxMenuItem( | 257 AppendCheckboxMenuItem( |
257 IDC_CHECK_SPELLING_OF_THIS_FIELD, | 258 IDC_CHECK_SPELLING_OF_THIS_FIELD, |
258 l10n_util::GetStringUTF16( | 259 l10n_util::GetStringUTF16( |
259 IDS_CONTENT_CONTEXT_CHECK_SPELLING_OF_THIS_FIELD)); | 260 IDS_CONTENT_CONTEXT_CHECK_SPELLING_OF_THIS_FIELD)); |
260 | 261 |
| 262 // Add option for showing the spelling panel if the platfrom spellchecker |
| 263 // supports it. |
| 264 if (SpellCheckerPlatform::SpellCheckerAvailable() && |
| 265 SpellCheckerPlatform::SpellCheckerProvidesPanel()) { |
| 266 AppendCheckboxMenuItem(IDC_SPELLPANEL_TOGGLE, l10n_util::GetStringUTF16( |
| 267 SpellCheckerPlatform::SpellingPanelVisible() ? |
| 268 IDS_CONTENT_CONTEXT_HIDE_SPELLING_PANEL : |
| 269 IDS_CONTENT_CONTEXT_SHOW_SPELLING_PANEL)); |
| 270 } |
261 FinishSubMenu(); | 271 FinishSubMenu(); |
262 | 272 |
263 AppendSeparator(); | 273 AppendSeparator(); |
264 AppendMenuItem(IDS_CONTENT_CONTEXT_SELECTALL); | 274 AppendMenuItem(IDS_CONTENT_CONTEXT_SELECTALL); |
265 } | 275 } |
266 | 276 |
267 // Menu delegate functions ----------------------------------------------------- | 277 // Menu delegate functions ----------------------------------------------------- |
268 | 278 |
269 bool RenderViewContextMenu::IsItemCommandEnabled(int id) const { | 279 bool RenderViewContextMenu::IsItemCommandEnabled(int id) const { |
270 // Allow Spell Check language items on sub menu for text area context menu. | 280 // Allow Spell Check language items on sub menu for text area context menu. |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 params_.misspelled_word); | 703 params_.misspelled_word); |
694 break; | 704 break; |
695 | 705 |
696 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: | 706 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: |
697 ShowFontsLanguagesWindow( | 707 ShowFontsLanguagesWindow( |
698 platform_util::GetTopLevel( | 708 platform_util::GetTopLevel( |
699 source_tab_contents_->GetContentNativeView()), | 709 source_tab_contents_->GetContentNativeView()), |
700 LANGUAGES_PAGE, profile_); | 710 LANGUAGES_PAGE, profile_); |
701 break; | 711 break; |
702 | 712 |
| 713 case IDC_SPELLPANEL_TOGGLE: |
| 714 source_tab_contents_->render_view_host()->ToggleSpellPanel( |
| 715 SpellCheckerPlatform::SpellingPanelVisible()); |
| 716 break; |
703 case IDS_CONTENT_CONTEXT_ADDSEARCHENGINE: // Not implemented. | 717 case IDS_CONTENT_CONTEXT_ADDSEARCHENGINE: // Not implemented. |
704 default: | 718 default: |
705 break; | 719 break; |
706 } | 720 } |
707 } | 721 } |
708 | 722 |
709 bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { | 723 bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { |
710 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 724 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
711 if (command_line.HasSwitch(switches::kAlwaysEnableDevTools)) | 725 if (command_line.HasSwitch(switches::kAlwaysEnableDevTools)) |
712 return true; | 726 return true; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 WriteTextToClipboard(UTF8ToUTF16(utf8_text)); | 805 WriteTextToClipboard(UTF8ToUTF16(utf8_text)); |
792 DidWriteURLToClipboard(utf8_text); | 806 DidWriteURLToClipboard(utf8_text); |
793 } | 807 } |
794 | 808 |
795 void RenderViewContextMenu::MediaPlayerActionAt( | 809 void RenderViewContextMenu::MediaPlayerActionAt( |
796 int x, | 810 int x, |
797 int y, | 811 int y, |
798 const MediaPlayerAction& action) { | 812 const MediaPlayerAction& action) { |
799 source_tab_contents_->render_view_host()->MediaPlayerActionAt(x, y, action); | 813 source_tab_contents_->render_view_host()->MediaPlayerActionAt(x, y, action); |
800 } | 814 } |
OLD | NEW |