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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // namespace ChromeRenderWidgetHostViewMacDelegateInternal | 69 } // namespace ChromeRenderWidgetHostViewMacDelegateInternal |
| 70 | 70 |
| 71 @implementation ChromeRenderWidgetHostViewMacDelegate | 71 @implementation ChromeRenderWidgetHostViewMacDelegate |
| 72 | 72 |
| 73 - (id)initWithRenderWidgetHost:(content::RenderWidgetHost*)renderWidgetHost { | 73 - (id)initWithRenderWidgetHost:(content::RenderWidgetHost*)renderWidgetHost { |
| 74 self = [super init]; | 74 self = [super init]; |
| 75 if (self) { | 75 if (self) { |
| 76 renderWidgetHost_ = renderWidgetHost; | 76 renderWidgetHost_ = renderWidgetHost; |
| 77 if (renderWidgetHost_->IsRenderView()) { | 77 RenderViewHost* rvh = RenderViewHost::From(renderWidgetHost_); |
| 78 if (rvh) { | |
| 78 spellingObserver_.reset( | 79 spellingObserver_.reset( |
| 79 new ChromeRenderWidgetHostViewMacDelegateInternal::SpellCheckObserver( | 80 new ChromeRenderWidgetHostViewMacDelegateInternal::SpellCheckObserver( |
| 80 RenderViewHost::From(renderWidgetHost_), self)); | 81 rvh, self)); |
| 81 } | 82 } |
| 82 | 83 |
| 83 historySwiper_.reset([[HistorySwiper alloc] initWithDelegate:self]); | 84 historySwiper_.reset([[HistorySwiper alloc] initWithDelegate:self]); |
| 84 } | 85 } |
| 85 return self; | 86 return self; |
| 86 } | 87 } |
| 87 | 88 |
| 88 - (void)dealloc { | 89 - (void)dealloc { |
| 89 [historySwiper_ setDelegate:nil]; | 90 [historySwiper_ setDelegate:nil]; |
| 90 [super dealloc]; | 91 [super dealloc]; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 return [historySwiper_ canRubberbandLeft:view]; | 131 return [historySwiper_ canRubberbandLeft:view]; |
| 131 } | 132 } |
| 132 | 133 |
| 133 - (BOOL)canRubberbandRight:(NSView*)view { | 134 - (BOOL)canRubberbandRight:(NSView*)view { |
| 134 return [historySwiper_ canRubberbandRight:view]; | 135 return [historySwiper_ canRubberbandRight:view]; |
| 135 } | 136 } |
| 136 | 137 |
| 137 // HistorySwiperDelegate methods | 138 // HistorySwiperDelegate methods |
| 138 | 139 |
| 139 - (BOOL)shouldAllowHistorySwiping { | 140 - (BOOL)shouldAllowHistorySwiping { |
| 140 if (!renderWidgetHost_ || !renderWidgetHost_->IsRenderView()) | 141 if (!renderWidgetHost_) |
| 141 return NO; | 142 return NO; |
| 142 content::WebContents* webContents = content::WebContents::FromRenderViewHost( | 143 content::WebContents* webContents = content::WebContents::FromRenderViewHost( |
| 143 RenderViewHost::From(renderWidgetHost_)); | 144 RenderViewHost::From(renderWidgetHost_)); |
|
ncarter (slow)
2015/10/26 18:35:02
In the case where renderWidgetHost_ is not a for a
Avi (use Gerrit)
2015/10/26 19:41:28
No. :\
| |
| 144 if (webContents && DevToolsWindow::IsDevToolsWindow(webContents)) { | 145 if (webContents && DevToolsWindow::IsDevToolsWindow(webContents)) { |
| 145 return NO; | 146 return NO; |
| 146 } | 147 } |
| 147 | 148 |
| 148 return YES; | 149 return YES; |
| 149 } | 150 } |
| 150 | 151 |
| 151 - (NSView*)viewThatWantsHistoryOverlay { | 152 - (NSView*)viewThatWantsHistoryOverlay { |
| 152 return renderWidgetHost_->GetView()->GetNativeView(); | 153 return renderWidgetHost_->GetView()->GetNativeView(); |
| 153 } | 154 } |
| 154 | 155 |
| 155 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item | 156 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item |
| 156 isValidItem:(BOOL*)valid { | 157 isValidItem:(BOOL*)valid { |
| 157 SEL action = [item action]; | 158 SEL action = [item action]; |
| 158 | 159 |
| 159 // For now, this action is always enabled for render view; | 160 // For now, this action is always enabled for render view; |
| 160 // this is sub-optimal. | 161 // this is sub-optimal. |
| 161 // TODO(suzhe): Plumb the "can*" methods up from WebCore. | 162 // TODO(suzhe): Plumb the "can*" methods up from WebCore. |
| 162 if (action == @selector(checkSpelling:)) { | 163 if (action == @selector(checkSpelling:)) { |
| 163 *valid = renderWidgetHost_->IsRenderView(); | 164 *valid = |
| 165 renderWidgetHost_ && RenderViewHost::From(renderWidgetHost_) != nullptr; | |
|
ncarter (slow)
2015/10/26 18:35:02
This seems to be the only place in this class wher
Avi (use Gerrit)
2015/10/26 19:41:28
Well, there are a few other places (note the metho
| |
| 164 return YES; | 166 return YES; |
| 165 } | 167 } |
| 166 | 168 |
| 167 // TODO(groby): Clarify who sends this and if toggleContinuousSpellChecking: | 169 // TODO(groby): Clarify who sends this and if toggleContinuousSpellChecking: |
| 168 // is still necessary. | 170 // is still necessary. |
| 169 if (action == @selector(toggleContinuousSpellChecking:)) { | 171 if (action == @selector(toggleContinuousSpellChecking:)) { |
| 170 if ([(id)item respondsToSelector:@selector(setState:)]) { | 172 if ([(id)item respondsToSelector:@selector(setState:)]) { |
| 171 content::RenderProcessHost* host = renderWidgetHost_->GetProcess(); | 173 content::RenderProcessHost* host = renderWidgetHost_->GetProcess(); |
| 172 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); | 174 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
| 173 DCHECK(profile); | 175 DCHECK(profile); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 } | 248 } |
| 247 | 249 |
| 248 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { | 250 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { |
| 249 spellcheckEnabled_ = enabled; | 251 spellcheckEnabled_ = enabled; |
| 250 spellcheckChecked_ = checked; | 252 spellcheckChecked_ = checked; |
| 251 } | 253 } |
| 252 | 254 |
| 253 // END Spellchecking methods | 255 // END Spellchecking methods |
| 254 | 256 |
| 255 @end | 257 @end |
| OLD | NEW |