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

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

Issue 2590473002: Upstream Chrome on iOS source code [5/11]. (Closed)
Patch Set: Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef IOS_CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_
6 #define IOS_CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_
7
8 #import <UIKit/UIKit.h>
9
10 #import "ios/web/public/web_state/crw_web_controller_observer.h"
11 #import "ios/web/public/web_state/crw_web_view_scroll_view_proxy.h"
12
13 namespace ios_internal {
14 // Duration of the toolbar animation.
15 const NSTimeInterval kToolbarAnimationDuration = 0.3;
16 } // namespace ios_internal
17
18 @class CRWWebViewScrollViewProxy;
19 @class FullScreenController;
20
21 namespace web {
22 class NavigationManager;
23 }
24
25 // Notification when the application is set up for testing.
26 extern NSString* const kSetupForTestingWillCloseAllTabsNotification;
27
28 @protocol FullScreenControllerDelegate<NSObject>
29
30 @required
31 // Called every time the header view needs to be moved in place according to
32 // the offset. The offset is a value between 0.0 (fully visible) and
33 // headerHeight (fully hidden). If animate is YES it is preferable for the
34 // delegate to slide the view in place instead of simply snapping it there. If
35 // animate is NO the view tracks touches on the screen and as such should be
36 // immediate.
37 - (void)fullScreenController:(FullScreenController*)fullscreenController
38 drawHeaderViewFromOffset:(CGFloat)headerOffset
39 animate:(BOOL)animate;
40
41 // Called when there is a need to move the header in place and scroll the
42 // webViewProxy's scroll view at the same time. Should always be animated.
43 // Only happens during a call to -setHeaderHeight:visible:onScrollView:. If
44 // |changeTopContentPadding| is YES, then in addition to scrolling, delegate
45 // should also update webViewProxy's topContentPadding.
46 - (void)fullScreenController:(FullScreenController*)fullScreenController
47 drawHeaderViewFromOffset:(CGFloat)headerOffset
48 onWebViewProxy:(id<CRWWebViewProxy>)webViewProxy
49 changeTopContentPadding:(BOOL)changeTopContentPadding
50 scrollingToOffset:(CGFloat)contentOffset;
51
52 // Called to retrieve the current height of the header. Only called from
53 // -setHeaderVisible:, so that method needs to be explicitly called when the
54 // height changes.
55 - (CGFloat)headerHeight;
56
57 // Tests if the session ID matches the current tab.
58 - (BOOL)isTabWithIDCurrent:(NSString*)sessionID;
59
60 // Current offset of the header. A value between 0.0 (fully visible) and
61 // headerHeight (fully hidden).
62 - (CGFloat)currentHeaderOffset;
63
64 @end
65
66 // This class will track a scrollview to make a header disappear on scroll down
67 // and reappear on scroll up. This class expects the scrollview to have the
68 // FullScreenController instance set as an observer right after the call to
69 // -initWithDelegate:scrollView:
70 //
71 // It also assumes the header is a view rendering itself on top of the scroll
72 // view, the delegate will simply move it out of view as needed. The delegate is
73 // called every time the header view needs to be moved.
74 @interface FullScreenController
75 : NSObject<CRWWebControllerObserver, CRWWebViewScrollViewProxyObserver>
76
77 // If set to YES this slightly alters the behaviour on drag down to pull the
78 // header to visible on the fist pixel moved. If set to NO (the default) there
79 // is a slight threshold before activating.
80 @property(nonatomic, assign) BOOL immediateDragDown;
81
82 // Designated initializer.
83 - (id)initWithDelegate:(id<FullScreenControllerDelegate>)delegate
84 navigationManager:(web::NavigationManager*)navigationManager
85 sessionID:(NSString*)sessionID;
86
87 // Used to clear state maintained by the controller and de-register from
88 // notifications. After this call the controller cease to function and will
89 // clear its delegate.
90 - (void)invalidate;
91
92 // Shows or hides the header as directed by |visible|. If necessary the delegate
93 // will be called synchronously with the desired offset and animate set to YES.
94 // This method can be called when it is desirable to show or hide the header
95 // programmatically. It must be called when the header size changes.
96 - (void)moveHeaderToRestingPosition:(BOOL)visible;
97
98 // Disabling full screen will pull the header to visible and keep it there no
99 // matter what the scrollview is doing.
100 - (void)disableFullScreen;
101 // Enabling fullscreen will reverse the effect of a call to -disableFullScreen.
102 // The toolbar will stay on screen until a move pushes it out.
103 - (void)enableFullScreen;
104
105 // Skip next attempt to correct the scroll offset for the toolbar height. This
106 // is necessary when programatically scrolling down the y offset.
107 - (void)shouldSkipNextScrollOffsetForHeader;
108
109 // Update the insets during animation. When |forceUpdate| is set to NO, a faster
110 // workaround implemention is used to update the content's offset. That
111 // implemention does not cause a full update. |forceUpdate| should only be set
112 // to |NO| when -setToolbarInsetsForHeaderOffset is called
113 // in quick succession during scroll callbacks.
114 - (void)setToolbarInsetsForHeaderOffset:(CGFloat)headerOffset
115 forceUpdate:(BOOL)forceUpdate;
116
117 // Set the content offset of the underlying UIScrollView so that the content
118 // is not hidden by the header. The header will be moved to its visible position
119 // without animation if it is not already fully visible.
120 - (void)moveContentBelowHeader;
121 @end
122
123 @interface FullScreenController (UsedForTesting)
124 // Enables/Disables the FullScreenController in tests. The unit tests do not set
125 // the delegate which is crucial for methods to work on the controller.
126 // This a temporary solution.
127 // TODO(shreyasv): Find a better solution/remove this when FullScreenController
128 // moves to Tab.
129 + (void)setEnabledForTests:(BOOL)enabled;
130 // Sets the hide omnibox delay. If set to 0.0, the omnibox is hidden
131 // synchronously.
132 + (void)setHideOmniboxDelaySeconds:(double)hideOmniboxDelaySeconds;
133 // Resets the hide omnibox delay to its default value.
134 + (void)resetHideOmniboxDelaySeconds;
135 @end
136
137 #endif // IOS_CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698