| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 @synthesize skipNextScrollOffsetForHeader = skipNextScrollOffsetForHeader_; | 184 @synthesize skipNextScrollOffsetForHeader = skipNextScrollOffsetForHeader_; |
| 187 @synthesize delayedHideHeaderCount = delayedHideHeaderCount_; | 185 @synthesize delayedHideHeaderCount = delayedHideHeaderCount_; |
| 188 @synthesize sessionID = sessionID_; | 186 @synthesize sessionID = sessionID_; |
| 189 @synthesize userInteractionGestureRecognizer = | 187 @synthesize userInteractionGestureRecognizer = |
| 190 userInteractionGestureRecognizer_; | 188 userInteractionGestureRecognizer_; |
| 191 | 189 |
| 192 - (id)initWithDelegate:(id<FullScreenControllerDelegate>)delegate | 190 - (id)initWithDelegate:(id<FullScreenControllerDelegate>)delegate |
| 193 navigationManager:(NavigationManager*)navigationManager | 191 navigationManager:(NavigationManager*)navigationManager |
| 194 sessionID:(NSString*)sessionID { | 192 sessionID:(NSString*)sessionID { |
| 195 if (!gEnabledForTests) { | 193 if (!gEnabledForTests) { |
| 196 propertyReleaser_FullScreenController_.Init(self, | |
| 197 [FullScreenController class]); | |
| 198 [self release]; | 194 [self release]; |
| 199 return nil; | 195 return nil; |
| 200 } | 196 } |
| 201 if ((self = [super init])) { | 197 if ((self = [super init])) { |
| 202 propertyReleaser_FullScreenController_.Init(self, | |
| 203 [FullScreenController class]); | |
| 204 DCHECK(sessionID); | 198 DCHECK(sessionID); |
| 205 DCHECK(delegate); | 199 DCHECK(delegate); |
| 206 delegate_ = delegate; | 200 delegate_ = delegate; |
| 207 sessionID_ = [sessionID copy]; | 201 sessionID_ = [sessionID copy]; |
| 208 navigationManager_ = navigationManager; | 202 navigationManager_ = navigationManager; |
| 209 | 203 |
| 210 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 204 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 211 [center addObserver:self | 205 [center addObserver:self |
| 212 selector:@selector(keyboardStart:) | 206 selector:@selector(keyboardStart:) |
| 213 name:UIKeyboardWillShowNotification | 207 name:UIKeyboardWillShowNotification |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 305 |
| 312 - (void)invalidate { | 306 - (void)invalidate { |
| 313 delegate_ = nil; | 307 delegate_ = nil; |
| 314 navigationManager_ = NULL; | 308 navigationManager_ = NULL; |
| 315 [self.scrollViewProxy removeObserver:self]; | 309 [self.scrollViewProxy removeObserver:self]; |
| 316 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 310 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 317 } | 311 } |
| 318 | 312 |
| 319 - (void)dealloc { | 313 - (void)dealloc { |
| 320 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 314 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 315 base::mac::ReleaseProperties(self); |
| 321 [super dealloc]; | 316 [super dealloc]; |
| 322 } | 317 } |
| 323 | 318 |
| 324 - (CRWWebViewScrollViewProxy*)scrollViewProxy { | 319 - (CRWWebViewScrollViewProxy*)scrollViewProxy { |
| 325 return [webViewProxy_ scrollViewProxy]; | 320 return [webViewProxy_ scrollViewProxy]; |
| 326 } | 321 } |
| 327 | 322 |
| 328 - (CGFloat)headerHeight { | 323 - (CGFloat)headerHeight { |
| 329 return [self.delegate headerHeight]; | 324 return [self.delegate headerHeight]; |
| 330 } | 325 } |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 overscrollActionsInProgress_ = NO; | 814 overscrollActionsInProgress_ = NO; |
| 820 } | 815 } |
| 821 | 816 |
| 822 #pragma mark - Used for testing | 817 #pragma mark - Used for testing |
| 823 | 818 |
| 824 + (void)setEnabledForTests:(BOOL)enabled { | 819 + (void)setEnabledForTests:(BOOL)enabled { |
| 825 gEnabledForTests = enabled; | 820 gEnabledForTests = enabled; |
| 826 } | 821 } |
| 827 | 822 |
| 828 @end | 823 @end |
| OLD | NEW |