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

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

Issue 395007: Move Mac to using renderer spellchecker. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: ui test fix Created 11 years, 1 month 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
« no previous file with comments | « chrome/browser/spellchecker_win.cc ('k') | chrome/browser/views/options/languages_page_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 23 #include "chrome/browser/spellcheck_host.h"
25 #endif
26 #include "chrome/browser/spellchecker.h"
27 #include "chrome/browser/spellchecker_platform_engine.h" 24 #include "chrome/browser/spellchecker_platform_engine.h"
28 #include "chrome/browser/tab_contents/navigation_entry.h" 25 #include "chrome/browser/tab_contents/navigation_entry.h"
29 #include "chrome/browser/tab_contents/tab_contents.h" 26 #include "chrome/browser/tab_contents/tab_contents.h"
30 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/platform_util.h" 28 #include "chrome/common/platform_util.h"
29 #include "chrome/common/pref_names.h"
32 #include "chrome/common/pref_service.h" 30 #include "chrome/common/pref_service.h"
33 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
34 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
35 #include "net/base/escape.h" 33 #include "net/base/escape.h"
36 #include "third_party/WebKit/WebKit/chromium/public/WebMediaPlayerAction.h" 34 #include "third_party/WebKit/WebKit/chromium/public/WebMediaPlayerAction.h"
37 #include "third_party/WebKit/WebKit/chromium/public/WebContextMenuData.h" 35 #include "third_party/WebKit/WebKit/chromium/public/WebContextMenuData.h"
38 36
39 using WebKit::WebContextMenuData; 37 using WebKit::WebContextMenuData;
40 using WebKit::WebMediaPlayerAction; 38 using WebKit::WebMediaPlayerAction;
41 39
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 AppendMenuItem(IDS_CONTENT_CONTEXT_PASTE); 264 AppendMenuItem(IDS_CONTENT_CONTEXT_PASTE);
267 AppendMenuItem(IDS_CONTENT_CONTEXT_DELETE); 265 AppendMenuItem(IDS_CONTENT_CONTEXT_DELETE);
268 AppendSeparator(); 266 AppendSeparator();
269 267
270 // Add Spell Check options sub menu. 268 // Add Spell Check options sub menu.
271 StartSubMenu(IDC_SPELLCHECK_MENU, 269 StartSubMenu(IDC_SPELLCHECK_MENU,
272 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPELLCHECK_MENU)); 270 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPELLCHECK_MENU));
273 271
274 // Add Spell Check languages to sub menu. 272 // Add Spell Check languages to sub menu.
275 std::vector<std::string> spellcheck_languages; 273 std::vector<std::string> spellcheck_languages;
276 SpellChecker::GetSpellCheckLanguages(profile_, 274 SpellCheckHost::GetSpellCheckLanguages(profile_,
277 &spellcheck_languages); 275 &spellcheck_languages);
278 DCHECK(spellcheck_languages.size() < 276 DCHECK(spellcheck_languages.size() <
279 IDC_SPELLCHECK_LANGUAGES_LAST - IDC_SPELLCHECK_LANGUAGES_FIRST); 277 IDC_SPELLCHECK_LANGUAGES_LAST - IDC_SPELLCHECK_LANGUAGES_FIRST);
280 const std::string app_locale = g_browser_process->GetApplicationLocale(); 278 const std::string app_locale = g_browser_process->GetApplicationLocale();
281 for (size_t i = 0; i < spellcheck_languages.size(); ++i) { 279 for (size_t i = 0; i < spellcheck_languages.size(); ++i) {
282 string16 display_name(l10n_util::GetDisplayNameForLocale( 280 string16 display_name(l10n_util::GetDisplayNameForLocale(
283 spellcheck_languages[i], app_locale, true)); 281 spellcheck_languages[i], app_locale, true));
284 AppendRadioMenuItem(IDC_SPELLCHECK_LANGUAGES_FIRST + i, display_name); 282 AppendRadioMenuItem(IDC_SPELLCHECK_LANGUAGES_FIRST + i, display_name);
285 } 283 }
286 284
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)); 481 profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck));
484 } 482 }
485 483
486 // Don't bother getting the display language vector if this isn't a spellcheck 484 // Don't bother getting the display language vector if this isn't a spellcheck
487 // language. 485 // language.
488 if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) || 486 if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) ||
489 (id >= IDC_SPELLCHECK_LANGUAGES_LAST)) 487 (id >= IDC_SPELLCHECK_LANGUAGES_LAST))
490 return false; 488 return false;
491 489
492 std::vector<std::string> languages; 490 std::vector<std::string> languages;
493 return SpellChecker::GetSpellCheckLanguages(profile_, &languages) == 491 return SpellCheckHost::GetSpellCheckLanguages(profile_, &languages) ==
494 (id - IDC_SPELLCHECK_LANGUAGES_FIRST); 492 (id - IDC_SPELLCHECK_LANGUAGES_FIRST);
495 } 493 }
496 494
497 void RenderViewContextMenu::ExecuteItemCommand(int id) { 495 void RenderViewContextMenu::ExecuteItemCommand(int id) {
498 // Check to see if one of the spell check language ids have been clicked. 496 // Check to see if one of the spell check language ids have been clicked.
499 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST && 497 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST &&
500 id < IDC_SPELLCHECK_LANGUAGES_LAST) { 498 id < IDC_SPELLCHECK_LANGUAGES_LAST) {
501 const size_t language_number = id - IDC_SPELLCHECK_LANGUAGES_FIRST; 499 const size_t language_number = id - IDC_SPELLCHECK_LANGUAGES_FIRST;
502 std::vector<std::string> languages; 500 std::vector<std::string> languages;
503 SpellChecker::GetSpellCheckLanguages(profile_, &languages); 501 SpellCheckHost::GetSpellCheckLanguages(profile_, &languages);
504 if (language_number < languages.size()) { 502 if (language_number < languages.size()) {
505 StringPrefMember dictionary_language; 503 StringPrefMember dictionary_language;
506 dictionary_language.Init(prefs::kSpellCheckDictionary, 504 dictionary_language.Init(prefs::kSpellCheckDictionary,
507 profile_->GetPrefs(), NULL); 505 profile_->GetPrefs(), NULL);
508 dictionary_language.SetValue(ASCIIToWide(languages[language_number])); 506 dictionary_language.SetValue(ASCIIToWide(languages[language_number]));
509 } 507 }
510 508
511 return; 509 return;
512 } 510 }
513 511
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 case IDC_SPELLCHECK_SUGGESTION_3: 715 case IDC_SPELLCHECK_SUGGESTION_3:
718 case IDC_SPELLCHECK_SUGGESTION_4: 716 case IDC_SPELLCHECK_SUGGESTION_4:
719 source_tab_contents_->render_view_host()->Replace( 717 source_tab_contents_->render_view_host()->Replace(
720 params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]); 718 params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]);
721 break; 719 break;
722 720
723 case IDC_CHECK_SPELLING_OF_THIS_FIELD: 721 case IDC_CHECK_SPELLING_OF_THIS_FIELD:
724 source_tab_contents_->render_view_host()->ToggleSpellCheck(); 722 source_tab_contents_->render_view_host()->ToggleSpellCheck();
725 break; 723 break;
726 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: { 724 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: {
727 #if defined(SPELLCHECKER_IN_RENDERER)
728 SpellCheckHost* spellcheck_host = profile_->GetSpellCheckHost(); 725 SpellCheckHost* spellcheck_host = profile_->GetSpellCheckHost();
729 if (!spellcheck_host) { 726 if (!spellcheck_host) {
730 NOTREACHED(); 727 NOTREACHED();
731 break; 728 break;
732 } 729 }
733 spellcheck_host->AddWord(UTF16ToUTF8(params_.misspelled_word)); 730 spellcheck_host->AddWord(UTF16ToUTF8(params_.misspelled_word));
734 #else 731 SpellCheckerPlatform::AddWord(params_.misspelled_word);
735 source_tab_contents_->render_view_host()->AddToDictionary(
736 params_.misspelled_word);
737 #endif
738 break; 732 break;
739 } 733 }
740 734
741 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: 735 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS:
742 ShowFontsLanguagesWindow( 736 ShowFontsLanguagesWindow(
743 platform_util::GetTopLevel( 737 platform_util::GetTopLevel(
744 source_tab_contents_->GetContentNativeView()), 738 source_tab_contents_->GetContentNativeView()),
745 LANGUAGES_PAGE, profile_); 739 LANGUAGES_PAGE, profile_);
746 break; 740 break;
747 741
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 824 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
831 g_browser_process->clipboard()); 825 g_browser_process->clipboard());
832 } 826 }
833 827
834 void RenderViewContextMenu::MediaPlayerActionAt( 828 void RenderViewContextMenu::MediaPlayerActionAt(
835 const gfx::Point& location, 829 const gfx::Point& location,
836 const WebMediaPlayerAction& action) { 830 const WebMediaPlayerAction& action) {
837 source_tab_contents_->render_view_host()->MediaPlayerActionAt( 831 source_tab_contents_->render_view_host()->MediaPlayerActionAt(
838 location, action); 832 location, action);
839 } 833 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker_win.cc ('k') | chrome/browser/views/options/languages_page_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698