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 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat e.h" | 5 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat e.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/mac/closure_blocks_leopard_compat.h" | 9 #include "base/mac/closure_blocks_leopard_compat.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| 11 #include "chrome/browser/debugger/devtools_window.h" | 11 #include "chrome/browser/debugger/devtools_window.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | |
| 13 #include "chrome/browser/profiles/profile.h" | |
| 12 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" | 14 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
| 13 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 15 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" | 17 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/view_id_util.h" | 18 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 19 #include "chrome/common/pref_names.h" | |
| 17 #include "chrome/common/spellcheck_messages.h" | 20 #include "chrome/common/spellcheck_messages.h" |
| 18 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 22 #include "content/public/browser/render_process_host.h" | |
| 19 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/render_view_host_observer.h" | 24 #include "content/public/browser/render_view_host_observer.h" |
| 21 #include "content/public/browser/render_widget_host.h" | 25 #include "content/public/browser/render_widget_host.h" |
| 22 #include "content/public/browser/render_widget_host_view.h" | 26 #include "content/public/browser/render_widget_host_view.h" |
| 23 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 24 | 28 |
| 25 using content::RenderViewHost; | 29 using content::RenderViewHost; |
| 26 | 30 |
| 27 // Declare things that are part of the 10.7 SDK. | 31 // Declare things that are part of the 10.7 SDK. |
| 28 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 32 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 // For now, this action is always enabled for render view; | 287 // For now, this action is always enabled for render view; |
| 284 // this is sub-optimal. | 288 // this is sub-optimal. |
| 285 // TODO(suzhe): Plumb the "can*" methods up from WebCore. | 289 // TODO(suzhe): Plumb the "can*" methods up from WebCore. |
| 286 if (action == @selector(checkSpelling:)) { | 290 if (action == @selector(checkSpelling:)) { |
| 287 *valid = renderWidgetHost_->IsRenderView(); | 291 *valid = renderWidgetHost_->IsRenderView(); |
| 288 return YES; | 292 return YES; |
| 289 } | 293 } |
| 290 | 294 |
| 291 if (action == @selector(toggleContinuousSpellChecking:)) { | 295 if (action == @selector(toggleContinuousSpellChecking:)) { |
| 292 if ([(id)item respondsToSelector:@selector(setState:)]) { | 296 if ([(id)item respondsToSelector:@selector(setState:)]) { |
| 297 content::RenderProcessHost* host = renderWidgetHost_->GetProcess(); | |
| 298 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); | |
| 299 if (profile) { | |
|
jeremy
2012/06/19 12:14:43
Is this null check still needed?
Hironori Bono
2012/06/21 09:38:18
Thanks for your comment. In my honest opinion, I h
| |
| 300 spellcheckChecked_ = | |
| 301 profile->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck); | |
| 302 } | |
| 293 NSCellStateValue checkedState = | 303 NSCellStateValue checkedState = |
| 294 spellcheckChecked_ ? NSOnState : NSOffState; | 304 spellcheckChecked_ ? NSOnState : NSOffState; |
| 295 [(id)item setState:checkedState]; | 305 [(id)item setState:checkedState]; |
| 296 } | 306 } |
| 297 *valid = spellcheckEnabled_; | 307 *valid = spellcheckEnabled_; |
| 298 return YES; | 308 return YES; |
| 299 } | 309 } |
| 300 | 310 |
| 301 return NO; | 311 return NO; |
| 302 } | 312 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 spellcheck_mac::IgnoreWord(base::SysNSStringToUTF16(wordToIgnore)); | 349 spellcheck_mac::IgnoreWord(base::SysNSStringToUTF16(wordToIgnore)); |
| 340 } | 350 } |
| 341 | 351 |
| 342 - (void)showGuessPanel:(id)sender { | 352 - (void)showGuessPanel:(id)sender { |
| 343 renderWidgetHost_->Send(new SpellCheckMsg_ToggleSpellPanel( | 353 renderWidgetHost_->Send(new SpellCheckMsg_ToggleSpellPanel( |
| 344 renderWidgetHost_->GetRoutingID(), | 354 renderWidgetHost_->GetRoutingID(), |
| 345 spellcheck_mac::SpellingPanelVisible())); | 355 spellcheck_mac::SpellingPanelVisible())); |
| 346 } | 356 } |
| 347 | 357 |
| 348 - (void)toggleContinuousSpellChecking:(id)sender { | 358 - (void)toggleContinuousSpellChecking:(id)sender { |
| 359 content::RenderProcessHost* host = renderWidgetHost_->GetProcess(); | |
| 360 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); | |
| 361 if (profile) { | |
|
jeremy
2012/06/19 12:14:43
Same question here
Hironori Bono
2012/06/21 09:38:18
Done.
| |
| 362 PrefService* pref = profile->GetPrefs(); | |
| 363 pref->SetBoolean(prefs::kEnableSpellCheck, | |
| 364 !pref->GetBoolean(prefs::kEnableSpellCheck)); | |
| 365 } | |
| 349 renderWidgetHost_->Send( | 366 renderWidgetHost_->Send( |
| 350 new SpellCheckMsg_ToggleSpellCheck(renderWidgetHost_->GetRoutingID())); | 367 new SpellCheckMsg_ToggleSpellCheck(renderWidgetHost_->GetRoutingID())); |
| 351 } | 368 } |
| 352 | 369 |
| 353 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { | 370 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { |
| 354 spellcheckEnabled_ = enabled; | 371 spellcheckEnabled_ = enabled; |
| 355 spellcheckChecked_ = checked; | 372 spellcheckChecked_ = checked; |
| 356 } | 373 } |
| 357 | 374 |
| 358 // END Spellchecking methods | 375 // END Spellchecking methods |
| 359 | 376 |
| 360 @end | 377 @end |
| OLD | NEW |