Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: ios/chrome/browser/ui/fullscreen_controller.mm

Issue 2804703002: [ObjC ARC] Converts ios/chrome/browser/ui:ui_internal_arc to ARC. (Closed)
Patch Set: git cl w Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/ui/crw_web_view_proxy.h" 20 #import "ios/web/public/web_state/ui/crw_web_view_proxy.h"
21 #import "ios/web/web_state/ui/crw_web_controller.h" 21 #import "ios/web/web_state/ui/crw_web_controller.h"
22 22
23 #if !defined(__has_feature) || !__has_feature(objc_arc)
24 #error "This file requires ARC support."
25 #endif
26
23 NSString* const kSetupForTestingWillCloseAllTabsNotification = 27 NSString* const kSetupForTestingWillCloseAllTabsNotification =
24 @"kSetupForTestingWillCloseAllTabsNotification"; 28 @"kSetupForTestingWillCloseAllTabsNotification";
25 29
26 using web::NavigationManager; 30 using web::NavigationManager;
27 31
28 namespace { 32 namespace {
29 33
30 class ScopedIncrementer { 34 class ScopedIncrementer {
31 public: 35 public:
32 explicit ScopedIncrementer(int* value) : value_(value) { ++(*value_); } 36 explicit ScopedIncrementer(int* value) : value_(value) { ++(*value_); }
(...skipping 27 matching lines...) Expand all
60 // Used to detect if the keyboard is visible. 64 // Used to detect if the keyboard is visible.
61 BOOL keyboardIsVisible_; 65 BOOL keyboardIsVisible_;
62 // Used to detect that the OverscrollActionsController is displaying its UI. 66 // Used to detect that the OverscrollActionsController is displaying its UI.
63 // The FullScreenController is disabled when the OverscrollActionsController's 67 // The FullScreenController is disabled when the OverscrollActionsController's
64 // UI is displayed. 68 // UI is displayed.
65 BOOL overscrollActionsInProgress_; 69 BOOL overscrollActionsInProgress_;
66 // Counter used to keep track of the number of actions currently disabling 70 // Counter used to keep track of the number of actions currently disabling
67 // full screen. 71 // full screen.
68 uint fullScreenLock_; 72 uint fullScreenLock_;
69 // CRWWebViewProxy object allows web view manipulations. 73 // CRWWebViewProxy object allows web view manipulations.
70 base::scoped_nsprotocol<id<CRWWebViewProxy>> webViewProxy_; 74 id<CRWWebViewProxy> webViewProxy_;
71 base::mac::ObjCPropertyReleaser propertyReleaser_FullScreenController_;
72 } 75 }
73 76
74 // Access to the UIWebView's UIScrollView. 77 // Access to the UIWebView's UIScrollView.
75 @property(nonatomic, readonly) CRWWebViewScrollViewProxy* scrollViewProxy; 78 @property(unsafe_unretained, nonatomic, readonly)
79 CRWWebViewScrollViewProxy* scrollViewProxy;
76 // The navigation controller of the page. 80 // The navigation controller of the page.
77 @property(nonatomic, readonly, assign) NavigationManager* navigationManager; 81 @property(nonatomic, readonly, assign) NavigationManager* navigationManager;
78 // The gesture recognizer set on the scrollview to detect tap. Must be readwrite 82 // The gesture recognizer set on the scrollview to detect tap. Must be readwrite
79 // for property releaser to work. 83 // for property releaser to work.
80 @property(nonatomic, readwrite, retain) 84 @property(nonatomic, readwrite, strong)
81 UITapGestureRecognizer* userInteractionGestureRecognizer; 85 UITapGestureRecognizer* userInteractionGestureRecognizer;
82 // The delegate responsible for providing the header height and moving the 86 // The delegate responsible for providing the header height and moving the
83 // header. 87 // header.
84 @property(nonatomic, readonly) id<FullScreenControllerDelegate> delegate; 88 @property(unsafe_unretained, nonatomic, readonly)
89 id<FullScreenControllerDelegate>
90 delegate;
85 // Current height of the header, in points. This is a pass-through method that 91 // Current height of the header, in points. This is a pass-through method that
86 // fetches the header height from the FullScreenControllerDelegate. 92 // fetches the header height from the FullScreenControllerDelegate.
87 @property(nonatomic, readonly) CGFloat headerHeight; 93 @property(nonatomic, readonly) CGFloat headerHeight;
88 // |top| field of UIScrollView.contentInset value caused by header. 94 // |top| field of UIScrollView.contentInset value caused by header.
89 // Always 0 for WKWebView, as it does not support contentInset. 95 // Always 0 for WKWebView, as it does not support contentInset.
90 @property(nonatomic, readonly) CGFloat topContentInsetCausedByHeader; 96 @property(nonatomic, readonly) CGFloat topContentInsetCausedByHeader;
91 // Last known y offset of the content in the scroll view during a scroll. Used 97 // Last known y offset of the content in the scroll view during a scroll. Used
92 // to infer the direction of the current scroll. 98 // to infer the direction of the current scroll.
93 @property(nonatomic, assign) CGFloat previousContentOffset; 99 @property(nonatomic, assign) CGFloat previousContentOffset;
94 // Last known y offset requested on the scroll view. In general the same value 100 // Last known y offset requested on the scroll view. In general the same value
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 @synthesize isFullScreenDisabledForLoading = isFullScreenDisabledForLoading_; 189 @synthesize isFullScreenDisabledForLoading = isFullScreenDisabledForLoading_;
184 @synthesize skipNextScrollOffsetForHeader = skipNextScrollOffsetForHeader_; 190 @synthesize skipNextScrollOffsetForHeader = skipNextScrollOffsetForHeader_;
185 @synthesize delayedHideHeaderCount = delayedHideHeaderCount_; 191 @synthesize delayedHideHeaderCount = delayedHideHeaderCount_;
186 @synthesize sessionID = sessionID_; 192 @synthesize sessionID = sessionID_;
187 @synthesize userInteractionGestureRecognizer = 193 @synthesize userInteractionGestureRecognizer =
188 userInteractionGestureRecognizer_; 194 userInteractionGestureRecognizer_;
189 195
190 - (id)initWithDelegate:(id<FullScreenControllerDelegate>)delegate 196 - (id)initWithDelegate:(id<FullScreenControllerDelegate>)delegate
191 navigationManager:(NavigationManager*)navigationManager 197 navigationManager:(NavigationManager*)navigationManager
192 sessionID:(NSString*)sessionID { 198 sessionID:(NSString*)sessionID {
193 if (!gEnabledForTests) { 199 if (!gEnabledForTests) {
sdefresne 2017/04/06 11:23:45 Remove braces as the rest of the file does not use
stkhapugin 2017/04/07 13:02:09 Done.
194 propertyReleaser_FullScreenController_.Init(self,
195 [FullScreenController class]);
196 [self release];
197 return nil; 200 return nil;
198 } 201 }
199 if ((self = [super init])) { 202 if ((self = [super init])) {
200 propertyReleaser_FullScreenController_.Init(self,
201 [FullScreenController class]);
202 DCHECK(sessionID); 203 DCHECK(sessionID);
203 DCHECK(delegate); 204 DCHECK(delegate);
204 delegate_ = delegate; 205 delegate_ = delegate;
205 sessionID_ = [sessionID copy]; 206 sessionID_ = [sessionID copy];
206 navigationManager_ = navigationManager; 207 navigationManager_ = navigationManager;
207 208
208 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 209 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
209 [center addObserver:self 210 [center addObserver:self
210 selector:@selector(keyboardStart:) 211 selector:@selector(keyboardStart:)
211 name:UIKeyboardWillShowNotification 212 name:UIKeyboardWillShowNotification
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 310
310 - (void)invalidate { 311 - (void)invalidate {
311 delegate_ = nil; 312 delegate_ = nil;
312 navigationManager_ = NULL; 313 navigationManager_ = NULL;
313 [self.scrollViewProxy removeObserver:self]; 314 [self.scrollViewProxy removeObserver:self];
314 [[NSNotificationCenter defaultCenter] removeObserver:self]; 315 [[NSNotificationCenter defaultCenter] removeObserver:self];
315 } 316 }
316 317
317 - (void)dealloc { 318 - (void)dealloc {
318 [[NSNotificationCenter defaultCenter] removeObserver:self]; 319 [[NSNotificationCenter defaultCenter] removeObserver:self];
319 [super dealloc];
320 } 320 }
321 321
322 - (CRWWebViewScrollViewProxy*)scrollViewProxy { 322 - (CRWWebViewScrollViewProxy*)scrollViewProxy {
323 return [webViewProxy_ scrollViewProxy]; 323 return [webViewProxy_ scrollViewProxy];
324 } 324 }
325 325
326 - (CGFloat)headerHeight { 326 - (CGFloat)headerHeight {
327 return [self.delegate headerHeight]; 327 return [self.delegate headerHeight];
328 } 328 }
329 329
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 693
694 [self setContentViewTopContentPadding:topInset]; 694 [self setContentViewTopContentPadding:topInset];
695 } 695 }
696 696
697 #pragma mark - 697 #pragma mark -
698 #pragma mark CRWWebControllerObserver methods 698 #pragma mark CRWWebControllerObserver methods
699 699
700 - (void)setWebViewProxy:(id<CRWWebViewProxy>)webViewProxy 700 - (void)setWebViewProxy:(id<CRWWebViewProxy>)webViewProxy
701 controller:(CRWWebController*)webController { 701 controller:(CRWWebController*)webController {
702 DCHECK([webViewProxy scrollViewProxy]); 702 DCHECK([webViewProxy scrollViewProxy]);
703 webViewProxy_.reset([webViewProxy retain]); 703 webViewProxy_ = webViewProxy;
704 [[webViewProxy scrollViewProxy] addObserver:self]; 704 [[webViewProxy scrollViewProxy] addObserver:self];
705 } 705 }
706 706
707 - (void)pageLoaded:(CRWWebController*)webController { 707 - (void)pageLoaded:(CRWWebController*)webController {
708 [self enableFullScreen]; 708 [self enableFullScreen];
709 web::WebState* webState = webController.webState; 709 web::WebState* webState = webController.webState;
710 if (webState) { 710 if (webState) {
711 BOOL MIMETypeIsPDF = webState->GetContentsMimeType() == "application/pdf"; 711 BOOL MIMETypeIsPDF = webState->GetContentsMimeType() == "application/pdf";
712 [webViewProxy_ setShouldUseInsetForTopPadding:MIMETypeIsPDF]; 712 [webViewProxy_ setShouldUseInsetForTopPadding:MIMETypeIsPDF];
713 } 713 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 overscrollActionsInProgress_ = NO; 813 overscrollActionsInProgress_ = NO;
814 } 814 }
815 815
816 #pragma mark - Used for testing 816 #pragma mark - Used for testing
817 817
818 + (void)setEnabledForTests:(BOOL)enabled { 818 + (void)setEnabledForTests:(BOOL)enabled {
819 gEnabledForTests = enabled; 819 gEnabledForTests = enabled;
820 } 820 }
821 821
822 @end 822 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698