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 #import "base/mac/sdk_forward_declarations.h" | 9 #import "base/mac/sdk_forward_declarations.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 bool shouldGoForward = isPinnedRight_ || !hasHorizontalScrollbar_; | 172 bool shouldGoForward = isPinnedRight_ || !hasHorizontalScrollbar_; |
173 if (isHorizontalGesture && | 173 if (isHorizontalGesture && |
174 // For normal pages, canGoBack/canGoForward are checked in the renderer | 174 // For normal pages, canGoBack/canGoForward are checked in the renderer |
175 // (ChromeClientImpl::shouldRubberBand()), when it decides if it should | 175 // (ChromeClientImpl::shouldRubberBand()), when it decides if it should |
176 // rubberband or send back an event unhandled. The check here is | 176 // rubberband or send back an event unhandled. The check here is |
177 // required for pages with an onmousewheel handler that doesn't call | 177 // required for pages with an onmousewheel handler that doesn't call |
178 // preventDefault(). | 178 // preventDefault(). |
179 ((shouldGoBack && canGoBack && !isRightScroll) || | 179 ((shouldGoBack && canGoBack && !isRightScroll) || |
180 (shouldGoForward && canGoForward && isRightScroll))) { | 180 (shouldGoForward && canGoForward && isRightScroll))) { |
181 | 181 |
| 182 BrowserWindowController* windowController = |
| 183 [BrowserWindowController browserWindowControllerForView: |
| 184 renderWidgetHost_->GetView()->GetNativeView()]; |
| 185 |
182 // Released by the tracking handler once the gesture is complete. | 186 // Released by the tracking handler once the gesture is complete. |
183 HistoryOverlayController* historyOverlay = | 187 HistoryOverlayController* historyOverlay = |
184 [[HistoryOverlayController alloc] | 188 [[HistoryOverlayController alloc] |
185 initForMode:goForward ? kHistoryOverlayModeForward : | 189 initForMode:goForward ? kHistoryOverlayModeForward : |
186 kHistoryOverlayModeBack]; | 190 kHistoryOverlayModeBack]; |
187 | 191 |
188 // The way this API works: gestureAmount is between -1 and 1 (float). If | 192 // The way this API works: gestureAmount is between -1 and 1 (float). If |
189 // the user does the gesture for more than about 25% (i.e. < -0.25 or > | 193 // the user does the gesture for more than about 25% (i.e. < -0.25 or > |
190 // 0.25) and then lets go, it is accepted, we get a NSEventPhaseEnded, | 194 // 0.25) and then lets go, it is accepted, we get a NSEventPhaseEnded, |
191 // and after that the block is called with amounts animating towards 1 | 195 // and after that the block is called with amounts animating towards 1 |
(...skipping 19 matching lines...) Expand all Loading... |
211 [theEvent trackSwipeEventWithOptions:NSEventSwipeTrackingLockDirection | 215 [theEvent trackSwipeEventWithOptions:NSEventSwipeTrackingLockDirection |
212 dampenAmountThresholdMin:-1 | 216 dampenAmountThresholdMin:-1 |
213 max:1 | 217 max:1 |
214 usingHandler:^(CGFloat gestureAmount, | 218 usingHandler:^(CGFloat gestureAmount, |
215 NSEventPhase phase, | 219 NSEventPhase phase, |
216 BOOL isComplete, | 220 BOOL isComplete, |
217 BOOL *stop) { | 221 BOOL *stop) { |
218 if (phase == NSEventPhaseBegan) { | 222 if (phase == NSEventPhaseBegan) { |
219 [historyOverlay showPanelForView: | 223 [historyOverlay showPanelForView: |
220 renderWidgetHost_->GetView()->GetNativeView()]; | 224 renderWidgetHost_->GetView()->GetNativeView()]; |
| 225 [windowController onHistoryOverlayShown]; |
221 return; | 226 return; |
222 } | 227 } |
223 | 228 |
224 BOOL ended = phase == NSEventPhaseEnded; | 229 BOOL ended = phase == NSEventPhaseEnded; |
225 | 230 |
226 // Dismiss the panel before navigation for immediate visual feedback. | 231 // Dismiss the panel before navigation for immediate visual feedback. |
227 [historyOverlay setProgress:gestureAmount]; | 232 [historyOverlay setProgress:gestureAmount]; |
228 if (ended) | 233 if (ended) |
229 [historyOverlay dismiss]; | 234 [historyOverlay dismiss]; |
230 | 235 |
231 // |gestureAmount| obeys -[NSEvent isDirectionInvertedFromDevice] | 236 // |gestureAmount| obeys -[NSEvent isDirectionInvertedFromDevice] |
232 // automatically. | 237 // automatically. |
233 Browser* browser = chrome::FindBrowserWithWindow( | 238 Browser* browser = chrome::FindBrowserWithWindow( |
234 historyOverlay.view.window); | 239 historyOverlay.view.window); |
235 if (ended && browser) { | 240 if (ended && browser) { |
236 if (goForward) | 241 if (goForward) |
237 chrome::GoForward(browser, CURRENT_TAB); | 242 chrome::GoForward(browser, CURRENT_TAB); |
238 else | 243 else |
239 chrome::GoBack(browser, CURRENT_TAB); | 244 chrome::GoBack(browser, CURRENT_TAB); |
240 } | 245 } |
241 | 246 |
242 if (isComplete) | 247 if (isComplete) { |
243 [historyOverlay release]; | 248 [historyOverlay release]; |
| 249 [windowController onHistoryOverlayHidden]; |
| 250 } |
244 }]; | 251 }]; |
245 return YES; | 252 return YES; |
246 } | 253 } |
247 } | 254 } |
248 return NO; | 255 return NO; |
249 } | 256 } |
250 | 257 |
251 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item | 258 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item |
252 isValidItem:(BOOL*)valid { | 259 isValidItem:(BOOL*)valid { |
253 SEL action = [item action]; | 260 SEL action = [item action]; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } | 349 } |
343 | 350 |
344 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { | 351 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { |
345 spellcheckEnabled_ = enabled; | 352 spellcheckEnabled_ = enabled; |
346 spellcheckChecked_ = checked; | 353 spellcheckChecked_ = checked; |
347 } | 354 } |
348 | 355 |
349 // END Spellchecking methods | 356 // END Spellchecking methods |
350 | 357 |
351 @end | 358 @end |
OLD | NEW |