| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.
h" | 5 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.
h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/mac/objc_property_releaser.h" | 11 #include "base/mac/objc_release_properties.h" |
| 12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #import "ios/chrome/browser/ui/browser_view_controller.h" | 14 #import "ios/chrome/browser/ui/browser_view_controller.h" |
| 15 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_view.h" | 15 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_view.h" |
| 16 #include "ios/chrome/browser/ui/rtl_geometry.h" | 16 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 17 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" | 17 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" |
| 18 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" | 18 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" |
| 19 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" | 19 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" |
| 20 #import "ios/web/public/web_state/crw_web_view_proxy.h" | 20 #import "ios/web/public/web_state/crw_web_view_proxy.h" |
| 21 | 21 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 base::scoped_nsobject<NSDictionary> _lockNotificationsCounterparts; | 156 base::scoped_nsobject<NSDictionary> _lockNotificationsCounterparts; |
| 157 // A view used to catch touches on the webview. | 157 // A view used to catch touches on the webview. |
| 158 base::scoped_nsobject<UIView> _dummyView; | 158 base::scoped_nsobject<UIView> _dummyView; |
| 159 // The proxy used to interact with the webview. | 159 // The proxy used to interact with the webview. |
| 160 base::scoped_nsprotocol<id<CRWWebViewProxy>> _webViewProxy; | 160 base::scoped_nsprotocol<id<CRWWebViewProxy>> _webViewProxy; |
| 161 // The proxy used to interact with the webview's scrollview. | 161 // The proxy used to interact with the webview's scrollview. |
| 162 base::scoped_nsobject<CRWWebViewScrollViewProxy> _webViewScrollViewProxy; | 162 base::scoped_nsobject<CRWWebViewScrollViewProxy> _webViewScrollViewProxy; |
| 163 // The scrollview driving the OverscrollActionsController when not using | 163 // The scrollview driving the OverscrollActionsController when not using |
| 164 // the scrollview from the CRWWebControllerObserver. | 164 // the scrollview from the CRWWebControllerObserver. |
| 165 base::scoped_nsobject<UIScrollView> _scrollview; | 165 base::scoped_nsobject<UIScrollView> _scrollview; |
| 166 base::mac::ObjCPropertyReleaser _propertyReleaser_OverscrollActionsController; | |
| 167 } | 166 } |
| 168 | 167 |
| 169 // The view displayed over the header view holding the actions. | 168 // The view displayed over the header view holding the actions. |
| 170 @property(nonatomic, retain) OverscrollActionsView* overscrollActionView; | 169 @property(nonatomic, retain) OverscrollActionsView* overscrollActionView; |
| 171 // Initial top inset added to the scrollview for the header. | 170 // Initial top inset added to the scrollview for the header. |
| 172 // This property is set from the delegate headerInset and cached on first | 171 // This property is set from the delegate headerInset and cached on first |
| 173 // call. The cached value is reset when the webview proxy is set. | 172 // call. The cached value is reset when the webview proxy is set. |
| 174 @property(nonatomic, readonly) CGFloat initialContentInset; | 173 @property(nonatomic, readonly) CGFloat initialContentInset; |
| 175 // Initial top inset for the header. | 174 // Initial top inset for the header. |
| 176 // This property is set from the delegate headerInset and cached on first | 175 // This property is set from the delegate headerInset and cached on first |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 @synthesize panPointScreenOrigin = _panPointScreenOrigin; | 233 @synthesize panPointScreenOrigin = _panPointScreenOrigin; |
| 235 @synthesize panGestureRecognizer = _panGestureRecognizer; | 234 @synthesize panGestureRecognizer = _panGestureRecognizer; |
| 236 | 235 |
| 237 - (instancetype)init { | 236 - (instancetype)init { |
| 238 return [self initWithScrollView:nil]; | 237 return [self initWithScrollView:nil]; |
| 239 } | 238 } |
| 240 | 239 |
| 241 - (instancetype)initWithScrollView:(UIScrollView*)scrollView { | 240 - (instancetype)initWithScrollView:(UIScrollView*)scrollView { |
| 242 self = [super init]; | 241 self = [super init]; |
| 243 if (self) { | 242 if (self) { |
| 244 _propertyReleaser_OverscrollActionsController.Init( | |
| 245 self, [OverscrollActionsController class]); | |
| 246 _overscrollActionView = | 243 _overscrollActionView = |
| 247 [[OverscrollActionsView alloc] initWithFrame:CGRectZero]; | 244 [[OverscrollActionsView alloc] initWithFrame:CGRectZero]; |
| 248 _overscrollActionView.delegate = self; | 245 _overscrollActionView.delegate = self; |
| 249 _scrollview.reset([scrollView retain]); | 246 _scrollview.reset([scrollView retain]); |
| 250 if (_scrollview) { | 247 if (_scrollview) { |
| 251 [self setup]; | 248 [self setup]; |
| 252 } | 249 } |
| 253 _lockIncrementNotifications.reset([[NSMutableSet alloc] init]); | 250 _lockIncrementNotifications.reset([[NSMutableSet alloc] init]); |
| 254 | 251 |
| 255 _lockNotificationsCounterparts.reset([@{ | 252 _lockNotificationsCounterparts.reset([@{ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 268 ios_internal::kSideSwipeWillStartNotification | 265 ios_internal::kSideSwipeWillStartNotification |
| 269 } retain]); | 266 } retain]); |
| 270 [self registerNotifications]; | 267 [self registerNotifications]; |
| 271 } | 268 } |
| 272 return self; | 269 return self; |
| 273 } | 270 } |
| 274 | 271 |
| 275 - (void)dealloc { | 272 - (void)dealloc { |
| 276 self.overscrollActionView.delegate = nil; | 273 self.overscrollActionView.delegate = nil; |
| 277 [self invalidate]; | 274 [self invalidate]; |
| 275 base::mac::ReleaseProperties(self); |
| 278 [super dealloc]; | 276 [super dealloc]; |
| 279 } | 277 } |
| 280 | 278 |
| 281 - (void)invalidate { | 279 - (void)invalidate { |
| 282 [self clear]; | 280 [self clear]; |
| 283 [self stopBounce]; | 281 [self stopBounce]; |
| 284 [self tearDown]; | 282 [self tearDown]; |
| 285 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 283 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 286 [self setWebViewInteractionEnabled:YES]; | 284 [self setWebViewInteractionEnabled:YES]; |
| 287 _delegate = nil; | 285 _delegate = nil; |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 _panGestureRecognizer.enabled = YES; | 871 _panGestureRecognizer.enabled = YES; |
| 874 [self scrollView].panGestureRecognizer.enabled = NO; | 872 [self scrollView].panGestureRecognizer.enabled = NO; |
| 875 [self scrollView].panGestureRecognizer.enabled = YES; | 873 [self scrollView].panGestureRecognizer.enabled = YES; |
| 876 [self startBounceWithInitialVelocity:CGPointZero]; | 874 [self startBounceWithInitialVelocity:CGPointZero]; |
| 877 [self.delegate | 875 [self.delegate |
| 878 overscrollActionsController:self | 876 overscrollActionsController:self |
| 879 didTriggerAction:self.overscrollActionView.selectedAction]; | 877 didTriggerAction:self.overscrollActionView.selectedAction]; |
| 880 } | 878 } |
| 881 | 879 |
| 882 @end | 880 @end |
| OLD | NEW |