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" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 ChromeRenderWidgetHostViewMacDelegate* view_delegate_; | 104 ChromeRenderWidgetHostViewMacDelegate* view_delegate_; |
105 }; | 105 }; |
106 | 106 |
107 } // namespace ChromeRenderWidgetHostViewMacDelegateInternal | 107 } // namespace ChromeRenderWidgetHostViewMacDelegateInternal |
108 | 108 |
109 @implementation ChromeRenderWidgetHostViewMacDelegate | 109 @implementation ChromeRenderWidgetHostViewMacDelegate |
110 | 110 |
111 - (id)initWithRenderWidgetHost:(RenderWidgetHost*)renderWidgetHost { | 111 - (id)initWithRenderWidgetHost:(RenderWidgetHost*)renderWidgetHost { |
112 self = [super init]; | 112 self = [super init]; |
113 if (self) { | 113 if (self) { |
114 renderWidgetHost_ = (RenderWidgetHostImpl*)renderWidgetHost; | 114 renderWidgetHost_ = RenderWidgetHostImpl::From(renderWidgetHost); |
115 NSView* nativeView = renderWidgetHost_->view()->GetNativeView(); | 115 NSView* nativeView = renderWidgetHost_->GetView()->GetNativeView(); |
116 view_id_util::SetID(nativeView, VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 116 view_id_util::SetID(nativeView, VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); |
117 | 117 |
118 if (renderWidgetHost_->IsRenderView()) { | 118 if (renderWidgetHost_->IsRenderView()) { |
119 spellingObserver_.reset( | 119 spellingObserver_.reset( |
120 new ChromeRenderWidgetHostViewMacDelegateInternal:: | 120 new ChromeRenderWidgetHostViewMacDelegateInternal:: |
121 SpellCheckRenderViewObserver( | 121 SpellCheckRenderViewObserver( |
122 static_cast<RenderViewHost*>(renderWidgetHost_), self)); | 122 static_cast<RenderViewHost*>( |
| 123 static_cast<RenderViewHostImpl*>(renderWidgetHost_)), |
| 124 self)); |
123 } | 125 } |
124 } | 126 } |
125 return self; | 127 return self; |
126 } | 128 } |
127 | 129 |
128 - (void)viewGone:(NSView*)view { | 130 - (void)viewGone:(NSView*)view { |
129 view_id_util::UnsetID(view); | 131 view_id_util::UnsetID(view); |
130 [self autorelease]; | 132 [self autorelease]; |
131 } | 133 } |
132 | 134 |
(...skipping 28 matching lines...) Expand all Loading... |
161 // Scroll events always go to the web first, and can only trigger history | 163 // Scroll events always go to the web first, and can only trigger history |
162 // swiping if they come back unhandled. | 164 // swiping if they come back unhandled. |
163 if ([theEvent phase] == NSEventPhaseBegan) { | 165 if ([theEvent phase] == NSEventPhaseBegan) { |
164 totalScrollDelta_ = NSZeroSize; | 166 totalScrollDelta_ = NSZeroSize; |
165 gotUnhandledWheelEvent_ = NO; | 167 gotUnhandledWheelEvent_ = NO; |
166 } | 168 } |
167 | 169 |
168 if (!renderWidgetHost_ || !renderWidgetHost_->IsRenderView()) | 170 if (!renderWidgetHost_ || !renderWidgetHost_->IsRenderView()) |
169 return NO; | 171 return NO; |
170 if (DevToolsWindow::IsDevToolsWindow( | 172 if (DevToolsWindow::IsDevToolsWindow( |
171 static_cast<RenderViewHost*>(renderWidgetHost_))) { | 173 static_cast<RenderViewHost*>( |
| 174 static_cast<RenderViewHostImpl*>(renderWidgetHost_)))) { |
172 return NO; | 175 return NO; |
173 } | 176 } |
174 | 177 |
175 BOOL suppressWheelEvent = NO; | 178 BOOL suppressWheelEvent = NO; |
176 Browser* browser = BrowserList::FindBrowserWithWindow([theEvent window]); | 179 Browser* browser = BrowserList::FindBrowserWithWindow([theEvent window]); |
177 if (browser && [NSEvent isSwipeTrackingFromScrollEventsEnabled]) { | 180 if (browser && [NSEvent isSwipeTrackingFromScrollEventsEnabled]) { |
178 content::WebContents* contents = browser->GetSelectedWebContents(); | 181 content::WebContents* contents = browser->GetSelectedWebContents(); |
179 if (contents && contents->GetURL() == GURL(chrome::kChromeUINewTabURL)) { | 182 if (contents && contents->GetURL() == GURL(chrome::kChromeUINewTabURL)) { |
180 // Always do history navigation on the NTP if it's enabled. | 183 // Always do history navigation on the NTP if it's enabled. |
181 gotUnhandledWheelEvent_ = YES; | 184 gotUnhandledWheelEvent_ = YES; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // in the wrong direction. | 249 // in the wrong direction. |
247 [theEvent trackSwipeEventWithOptions:NSEventSwipeTrackingLockDirection | 250 [theEvent trackSwipeEventWithOptions:NSEventSwipeTrackingLockDirection |
248 dampenAmountThresholdMin:-1 | 251 dampenAmountThresholdMin:-1 |
249 max:1 | 252 max:1 |
250 usingHandler:^(CGFloat gestureAmount, | 253 usingHandler:^(CGFloat gestureAmount, |
251 NSEventPhase phase, | 254 NSEventPhase phase, |
252 BOOL isComplete, | 255 BOOL isComplete, |
253 BOOL *stop) { | 256 BOOL *stop) { |
254 if (phase == NSEventPhaseBegan) { | 257 if (phase == NSEventPhaseBegan) { |
255 [historyOverlay showPanelForView: | 258 [historyOverlay showPanelForView: |
256 renderWidgetHost_->view()->GetNativeView()]; | 259 renderWidgetHost_->GetView()->GetNativeView()]; |
257 return; | 260 return; |
258 } | 261 } |
259 | 262 |
260 BOOL ended = phase == NSEventPhaseEnded; | 263 BOOL ended = phase == NSEventPhaseEnded; |
261 | 264 |
262 // Dismiss the panel before navigation for immediate visual feedback. | 265 // Dismiss the panel before navigation for immediate visual feedback. |
263 [historyOverlay setProgress:gestureAmount]; | 266 [historyOverlay setProgress:gestureAmount]; |
264 if (ended) | 267 if (ended) |
265 [historyOverlay dismiss]; | 268 [historyOverlay dismiss]; |
266 | 269 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 329 |
327 // This message is sent by NSSpellChecker whenever the next word should be | 330 // This message is sent by NSSpellChecker whenever the next word should be |
328 // advanced to, either after a correction or clicking the "Find Next" button. | 331 // advanced to, either after a correction or clicking the "Find Next" button. |
329 // This isn't documented anywhere useful, like in NSSpellProtocol.h with the | 332 // This isn't documented anywhere useful, like in NSSpellProtocol.h with the |
330 // other spelling panel methods. This is probably because Apple assumes that the | 333 // other spelling panel methods. This is probably because Apple assumes that the |
331 // the spelling panel will be used with an NSText, which will automatically | 334 // the spelling panel will be used with an NSText, which will automatically |
332 // catch this and advance to the next word for you. Thanks Apple. | 335 // catch this and advance to the next word for you. Thanks Apple. |
333 // This is also called from the Edit -> Spelling -> Check Spelling menu item. | 336 // This is also called from the Edit -> Spelling -> Check Spelling menu item. |
334 - (void)checkSpelling:(id)sender { | 337 - (void)checkSpelling:(id)sender { |
335 renderWidgetHost_->Send(new SpellCheckMsg_AdvanceToNextMisspelling( | 338 renderWidgetHost_->Send(new SpellCheckMsg_AdvanceToNextMisspelling( |
336 renderWidgetHost_->routing_id())); | 339 renderWidgetHost_->GetRoutingID())); |
337 } | 340 } |
338 | 341 |
339 // This message is sent by the spelling panel whenever a word is ignored. | 342 // This message is sent by the spelling panel whenever a word is ignored. |
340 - (void)ignoreSpelling:(id)sender { | 343 - (void)ignoreSpelling:(id)sender { |
341 // Ideally, we would ask the current RenderView for its tag, but that would | 344 // Ideally, we would ask the current RenderView for its tag, but that would |
342 // mean making a blocking IPC call from the browser. Instead, | 345 // mean making a blocking IPC call from the browser. Instead, |
343 // spellcheck_mac::CheckSpelling remembers the last tag and | 346 // spellcheck_mac::CheckSpelling remembers the last tag and |
344 // spellcheck_mac::IgnoreWord assumes that is the correct tag. | 347 // spellcheck_mac::IgnoreWord assumes that is the correct tag. |
345 NSString* wordToIgnore = [sender stringValue]; | 348 NSString* wordToIgnore = [sender stringValue]; |
346 if (wordToIgnore != nil) | 349 if (wordToIgnore != nil) |
347 spellcheck_mac::IgnoreWord(base::SysNSStringToUTF16(wordToIgnore)); | 350 spellcheck_mac::IgnoreWord(base::SysNSStringToUTF16(wordToIgnore)); |
348 } | 351 } |
349 | 352 |
350 - (void)showGuessPanel:(id)sender { | 353 - (void)showGuessPanel:(id)sender { |
351 renderWidgetHost_->Send(new SpellCheckMsg_ToggleSpellPanel( | 354 renderWidgetHost_->Send(new SpellCheckMsg_ToggleSpellPanel( |
352 renderWidgetHost_->routing_id(), | 355 renderWidgetHost_->GetRoutingID(), |
353 spellcheck_mac::SpellingPanelVisible())); | 356 spellcheck_mac::SpellingPanelVisible())); |
354 } | 357 } |
355 | 358 |
356 - (void)toggleContinuousSpellChecking:(id)sender { | 359 - (void)toggleContinuousSpellChecking:(id)sender { |
357 renderWidgetHost_->Send( | 360 renderWidgetHost_->Send( |
358 new SpellCheckMsg_ToggleSpellCheck(renderWidgetHost_->routing_id())); | 361 new SpellCheckMsg_ToggleSpellCheck(renderWidgetHost_->GetRoutingID())); |
359 } | 362 } |
360 | 363 |
361 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { | 364 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { |
362 spellcheckEnabled_ = enabled; | 365 spellcheckEnabled_ = enabled; |
363 spellcheckChecked_ = checked; | 366 spellcheckChecked_ = checked; |
364 } | 367 } |
365 | 368 |
366 // END Spellchecking methods | 369 // END Spellchecking methods |
367 | 370 |
368 @end | 371 @end |
OLD | NEW |