| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/fullscreen_controller.h" | 5 #import "ios/chrome/browser/ui/fullscreen_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/objc_property_releaser.h" | 10 #include "base/mac/objc_release_properties.h" |
| 11 #import "ios/chrome/browser/ui/browser_view_controller.h" | 11 #import "ios/chrome/browser/ui/browser_view_controller.h" |
| 12 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.
h" | 12 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.
h" |
| 13 #import "ios/chrome/browser/ui/tabs/tab_strip_controller.h" | 13 #import "ios/chrome/browser/ui/tabs/tab_strip_controller.h" |
| 14 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" | 14 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" |
| 15 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" | 15 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" |
| 16 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" | 16 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" |
| 17 #include "ios/web/public/navigation_item.h" | 17 #include "ios/web/public/navigation_item.h" |
| 18 #import "ios/web/public/navigation_manager.h" | 18 #import "ios/web/public/navigation_manager.h" |
| 19 #include "ios/web/public/ssl_status.h" | 19 #include "ios/web/public/ssl_status.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" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 BOOL keyboardIsVisible_; | 61 BOOL keyboardIsVisible_; |
| 62 // Used to detect that the OverscrollActionsController is displaying its UI. | 62 // Used to detect that the OverscrollActionsController is displaying its UI. |
| 63 // The FullScreenController is disabled when the OverscrollActionsController's | 63 // The FullScreenController is disabled when the OverscrollActionsController's |
| 64 // UI is displayed. | 64 // UI is displayed. |
| 65 BOOL overscrollActionsInProgress_; | 65 BOOL overscrollActionsInProgress_; |
| 66 // Counter used to keep track of the number of actions currently disabling | 66 // Counter used to keep track of the number of actions currently disabling |
| 67 // full screen. | 67 // full screen. |
| 68 uint fullScreenLock_; | 68 uint fullScreenLock_; |
| 69 // CRWWebViewProxy object allows web view manipulations. | 69 // CRWWebViewProxy object allows web view manipulations. |
| 70 base::scoped_nsprotocol<id<CRWWebViewProxy>> webViewProxy_; | 70 base::scoped_nsprotocol<id<CRWWebViewProxy>> webViewProxy_; |
| 71 base::mac::ObjCPropertyReleaser propertyReleaser_FullScreenController_; | |
| 72 } | 71 } |
| 73 | 72 |
| 74 // Access to the UIWebView's UIScrollView. | 73 // Access to the UIWebView's UIScrollView. |
| 75 @property(nonatomic, readonly) CRWWebViewScrollViewProxy* scrollViewProxy; | 74 @property(nonatomic, readonly) CRWWebViewScrollViewProxy* scrollViewProxy; |
| 76 // The navigation controller of the page. | 75 // The navigation controller of the page. |
| 77 @property(nonatomic, readonly, assign) NavigationManager* navigationManager; | 76 @property(nonatomic, readonly, assign) NavigationManager* navigationManager; |
| 78 // The gesture recognizer set on the scrollview to detect tap. Must be readwrite | 77 // The gesture recognizer set on the scrollview to detect tap. |
| 79 // for property releaser to work. | 78 @property(nonatomic, readonly, retain) |
| 80 @property(nonatomic, readwrite, retain) | |
| 81 UITapGestureRecognizer* userInteractionGestureRecognizer; | 79 UITapGestureRecognizer* userInteractionGestureRecognizer; |
| 82 // The delegate responsible for providing the header height and moving the | 80 // The delegate responsible for providing the header height and moving the |
| 83 // header. | 81 // header. |
| 84 @property(nonatomic, readonly) id<FullScreenControllerDelegate> delegate; | 82 @property(nonatomic, readonly) id<FullScreenControllerDelegate> delegate; |
| 85 // Current height of the header, in points. This is a pass-through method that | 83 // Current height of the header, in points. This is a pass-through method that |
| 86 // fetches the header height from the FullScreenControllerDelegate. | 84 // fetches the header height from the FullScreenControllerDelegate. |
| 87 @property(nonatomic, readonly) CGFloat headerHeight; | 85 @property(nonatomic, readonly) CGFloat headerHeight; |
| 88 // |top| field of UIScrollView.contentInset value caused by header. | 86 // |top| field of UIScrollView.contentInset value caused by header. |
| 89 // Always 0 for WKWebView, as it does not support contentInset. | 87 // Always 0 for WKWebView, as it does not support contentInset. |
| 90 @property(nonatomic, readonly) CGFloat topContentInsetCausedByHeader; | 88 @property(nonatomic, readonly) CGFloat topContentInsetCausedByHeader; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 @synthesize skipNextScrollOffsetForHeader = skipNextScrollOffsetForHeader_; | 182 @synthesize skipNextScrollOffsetForHeader = skipNextScrollOffsetForHeader_; |
| 185 @synthesize delayedHideHeaderCount = delayedHideHeaderCount_; | 183 @synthesize delayedHideHeaderCount = delayedHideHeaderCount_; |
| 186 @synthesize sessionID = sessionID_; | 184 @synthesize sessionID = sessionID_; |
| 187 @synthesize userInteractionGestureRecognizer = | 185 @synthesize userInteractionGestureRecognizer = |
| 188 userInteractionGestureRecognizer_; | 186 userInteractionGestureRecognizer_; |
| 189 | 187 |
| 190 - (id)initWithDelegate:(id<FullScreenControllerDelegate>)delegate | 188 - (id)initWithDelegate:(id<FullScreenControllerDelegate>)delegate |
| 191 navigationManager:(NavigationManager*)navigationManager | 189 navigationManager:(NavigationManager*)navigationManager |
| 192 sessionID:(NSString*)sessionID { | 190 sessionID:(NSString*)sessionID { |
| 193 if (!gEnabledForTests) { | 191 if (!gEnabledForTests) { |
| 194 propertyReleaser_FullScreenController_.Init(self, | |
| 195 [FullScreenController class]); | |
| 196 [self release]; | 192 [self release]; |
| 197 return nil; | 193 return nil; |
| 198 } | 194 } |
| 199 if ((self = [super init])) { | 195 if ((self = [super init])) { |
| 200 propertyReleaser_FullScreenController_.Init(self, | |
| 201 [FullScreenController class]); | |
| 202 DCHECK(sessionID); | 196 DCHECK(sessionID); |
| 203 DCHECK(delegate); | 197 DCHECK(delegate); |
| 204 delegate_ = delegate; | 198 delegate_ = delegate; |
| 205 sessionID_ = [sessionID copy]; | 199 sessionID_ = [sessionID copy]; |
| 206 navigationManager_ = navigationManager; | 200 navigationManager_ = navigationManager; |
| 207 | 201 |
| 208 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 202 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 209 [center addObserver:self | 203 [center addObserver:self |
| 210 selector:@selector(keyboardStart:) | 204 selector:@selector(keyboardStart:) |
| 211 name:UIKeyboardWillShowNotification | 205 name:UIKeyboardWillShowNotification |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 303 |
| 310 - (void)invalidate { | 304 - (void)invalidate { |
| 311 delegate_ = nil; | 305 delegate_ = nil; |
| 312 navigationManager_ = NULL; | 306 navigationManager_ = NULL; |
| 313 [self.scrollViewProxy removeObserver:self]; | 307 [self.scrollViewProxy removeObserver:self]; |
| 314 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 308 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 315 } | 309 } |
| 316 | 310 |
| 317 - (void)dealloc { | 311 - (void)dealloc { |
| 318 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 312 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 313 base::mac::ReleaseProperties(self); |
| 319 [super dealloc]; | 314 [super dealloc]; |
| 320 } | 315 } |
| 321 | 316 |
| 322 - (CRWWebViewScrollViewProxy*)scrollViewProxy { | 317 - (CRWWebViewScrollViewProxy*)scrollViewProxy { |
| 323 return [webViewProxy_ scrollViewProxy]; | 318 return [webViewProxy_ scrollViewProxy]; |
| 324 } | 319 } |
| 325 | 320 |
| 326 - (CGFloat)headerHeight { | 321 - (CGFloat)headerHeight { |
| 327 return [self.delegate headerHeight]; | 322 return [self.delegate headerHeight]; |
| 328 } | 323 } |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 overscrollActionsInProgress_ = NO; | 812 overscrollActionsInProgress_ = NO; |
| 818 } | 813 } |
| 819 | 814 |
| 820 #pragma mark - Used for testing | 815 #pragma mark - Used for testing |
| 821 | 816 |
| 822 + (void)setEnabledForTests:(BOOL)enabled { | 817 + (void)setEnabledForTests:(BOOL)enabled { |
| 823 gEnabledForTests = enabled; | 818 gEnabledForTests = enabled; |
| 824 } | 819 } |
| 825 | 820 |
| 826 @end | 821 @end |
| OLD | NEW |