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

Unified Diff: chrome/browser/tab_contents/spellchecker_submenu_observer_hunspell.cc

Issue 10548022: Synchronize the check status of the "Check Spelling While Typing" item. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/spellchecker_submenu_observer_hunspell.cc
===================================================================
--- chrome/browser/tab_contents/spellchecker_submenu_observer_hunspell.cc (revision 144063)
+++ chrome/browser/tab_contents/spellchecker_submenu_observer_hunspell.cc (working copy)
@@ -28,7 +28,6 @@
int group)
: proxy_(proxy),
submenu_model_(delegate),
- spellcheck_enabled_(false),
language_group_(group),
language_selected_(0) {
DCHECK(proxy_);
@@ -41,10 +40,9 @@
const content::ContextMenuParams& params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- spellcheck_enabled_ = params.spellcheck_enabled;
-
// Add available spell-checker languages to the sub menu.
Profile* profile = proxy_->GetProfile();
+ DCHECK(profile);
language_selected_ =
SpellCheckHost::GetSpellCheckLanguages(profile, &languages_);
DCHECK(languages_.size() <
@@ -115,9 +113,8 @@
// Check box for 'Check Spelling while typing'.
if (command_id == IDC_CHECK_SPELLING_WHILE_TYPING) {
Profile* profile = proxy_->GetProfile();
- if (!profile || !profile->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck))
- return false;
- return spellcheck_enabled_;
+ DCHECK(profile);
+ return profile->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck);
}
return false;
@@ -127,9 +124,7 @@
DCHECK(IsCommandIdSupported(command_id));
Profile* profile = proxy_->GetProfile();
- if (!profile)
- return false;
-
+ DCHECK(profile);
const PrefService* pref = profile->GetPrefs();
if (command_id >= IDC_SPELLCHECK_LANGUAGES_FIRST &&
command_id < IDC_SPELLCHECK_LANGUAGES_LAST) {
@@ -138,8 +133,6 @@
switch (command_id) {
case IDC_CHECK_SPELLING_WHILE_TYPING:
- return pref->GetBoolean(prefs::kEnableSpellCheck);
-
case IDC_SPELLPANEL_TOGGLE:
case IDC_SPELLCHECK_MENU:
return true;
@@ -152,9 +145,10 @@
DCHECK(IsCommandIdSupported(command_id));
// Check to see if one of the spell check language ids have been clicked.
+ Profile* profile = proxy_->GetProfile();
+ DCHECK(profile);
if (command_id >= IDC_SPELLCHECK_LANGUAGES_FIRST &&
command_id < IDC_SPELLCHECK_LANGUAGES_LAST) {
- Profile* profile = proxy_->GetProfile();
const size_t language = command_id - IDC_SPELLCHECK_LANGUAGES_FIRST;
if (profile && language < languages_.size()) {
StringPrefMember dictionary_language;
@@ -169,7 +163,11 @@
content::RenderViewHost* rvh = proxy_->GetRenderViewHost();
switch (command_id) {
case IDC_CHECK_SPELLING_WHILE_TYPING:
- rvh->Send(new SpellCheckMsg_ToggleSpellCheck(rvh->GetRoutingID()));
+ profile->GetPrefs()->SetBoolean(
+ prefs::kEnableSpellCheck,
+ !profile->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck));
+ if (rvh)
+ rvh->Send(new SpellCheckMsg_ToggleSpellCheck(rvh->GetRoutingID()));
break;
}
}

Powered by Google App Engine
This is Rietveld 408576698