Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/spellchecker_submenu_observer.h" | 5 #include "chrome/browser/tab_contents/spellchecker_submenu_observer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" | 10 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 77 |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool SpellCheckerSubMenuObserver::IsCommandIdChecked(int command_id) { | 81 bool SpellCheckerSubMenuObserver::IsCommandIdChecked(int command_id) { |
| 82 DCHECK(IsCommandIdSupported(command_id)); | 82 DCHECK(IsCommandIdSupported(command_id)); |
| 83 | 83 |
| 84 // Check box for 'Check Spelling while typing'. | 84 // Check box for 'Check Spelling while typing'. |
| 85 if (command_id == IDC_CHECK_SPELLING_WHILE_TYPING) { | 85 if (command_id == IDC_CHECK_SPELLING_WHILE_TYPING) { |
| 86 Profile* profile = proxy_->GetProfile(); | 86 Profile* profile = proxy_->GetProfile(); |
| 87 if (!profile || !profile->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)) | 87 return profile->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck); |
|
jeremy
2012/06/13 17:43:30
Are you sure that removing the Null check here is
Hironori Bono
2012/06/14 08:16:03
Thanks for noticing it. Even though I somehow remo
| |
| 88 return false; | |
| 89 return check_spelling_while_typing_; | |
|
jeremy
2012/06/13 17:43:30
If we're just reading this straight from the prefs
Hironori Bono
2012/06/14 08:16:03
Thanks for noticing it. Yes, we can remove it. I h
| |
| 90 } | 88 } |
| 91 | 89 |
| 92 return false; | 90 return false; |
| 93 } | 91 } |
| 94 | 92 |
| 95 bool SpellCheckerSubMenuObserver::IsCommandIdEnabled(int command_id) { | 93 bool SpellCheckerSubMenuObserver::IsCommandIdEnabled(int command_id) { |
| 96 DCHECK(IsCommandIdSupported(command_id)); | 94 DCHECK(IsCommandIdSupported(command_id)); |
| 97 | 95 |
| 98 Profile* profile = proxy_->GetProfile(); | 96 Profile* profile = proxy_->GetProfile(); |
| 99 if (!profile) | 97 if (!profile) |
| 100 return false; | 98 return false; |
| 101 | 99 |
| 102 const PrefService* pref = profile->GetPrefs(); | |
| 103 | |
| 104 switch (command_id) { | 100 switch (command_id) { |
| 105 case IDC_CHECK_SPELLING_WHILE_TYPING: | 101 case IDC_CHECK_SPELLING_WHILE_TYPING: |
| 106 return pref->GetBoolean(prefs::kEnableSpellCheck); | |
| 107 | |
| 108 case IDC_SPELLPANEL_TOGGLE: | 102 case IDC_SPELLPANEL_TOGGLE: |
| 109 case IDC_SPELLCHECK_MENU: | 103 case IDC_SPELLCHECK_MENU: |
| 110 case IDC_CONTENT_CONTEXT_SPELLING_TOGGLE: | 104 case IDC_CONTENT_CONTEXT_SPELLING_TOGGLE: |
| 111 return true; | 105 return true; |
| 112 } | 106 } |
| 113 | 107 |
| 114 return false; | 108 return false; |
| 115 } | 109 } |
| 116 | 110 |
| 117 void SpellCheckerSubMenuObserver::ExecuteCommand(int command_id) { | 111 void SpellCheckerSubMenuObserver::ExecuteCommand(int command_id) { |
| 118 DCHECK(IsCommandIdSupported(command_id)); | 112 DCHECK(IsCommandIdSupported(command_id)); |
| 119 | 113 |
| 120 content::RenderViewHost* rvh = proxy_->GetRenderViewHost(); | 114 content::RenderViewHost* rvh = proxy_->GetRenderViewHost(); |
| 115 Profile* profile = proxy_->GetProfile(); | |
| 121 switch (command_id) { | 116 switch (command_id) { |
| 122 case IDC_CHECK_SPELLING_WHILE_TYPING: | 117 case IDC_CHECK_SPELLING_WHILE_TYPING: |
| 118 profile->GetPrefs()->SetBoolean( | |
| 119 prefs::kEnableSpellCheck, | |
| 120 !profile->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)); | |
| 123 rvh->Send(new SpellCheckMsg_ToggleSpellCheck(rvh->GetRoutingID())); | 121 rvh->Send(new SpellCheckMsg_ToggleSpellCheck(rvh->GetRoutingID())); |
| 124 break; | 122 break; |
| 125 | 123 |
| 126 case IDC_SPELLPANEL_TOGGLE: | 124 case IDC_SPELLPANEL_TOGGLE: |
| 127 rvh->Send(new SpellCheckMsg_ToggleSpellPanel( | 125 rvh->Send(new SpellCheckMsg_ToggleSpellPanel( |
| 128 rvh->GetRoutingID(), spellcheck_mac::SpellingPanelVisible())); | 126 rvh->GetRoutingID(), spellcheck_mac::SpellingPanelVisible())); |
| 129 break; | 127 break; |
| 130 } | 128 } |
| 131 } | 129 } |
| OLD | NEW |