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