OLD | NEW |
(Empty) | |
| 1 // Copyright 2012 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_TOOLBAR_WEB_TOOLBAR_CONTROLLER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_TOOLBAR_WEB_TOOLBAR_CONTROLLER_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 #include "ios/chrome/browser/ui/omnibox/location_bar_view_ios.h" |
| 11 #include "ios/chrome/browser/ui/omnibox/omnibox_popup_positioner.h" |
| 12 #include "ios/chrome/browser/ui/qr_scanner/qr_scanner_view_controller.h" |
| 13 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" |
| 14 #include "ios/public/provider/chrome/browser/voice/voice_search_controller_deleg
ate.h" |
| 15 |
| 16 @protocol PreloadProvider; |
| 17 @class Tab; |
| 18 @protocol ToolbarFrameDelegate; |
| 19 class ToolbarModelIOS; |
| 20 @protocol UrlLoader; |
| 21 |
| 22 namespace ios { |
| 23 class ChromeBrowserState; |
| 24 } |
| 25 |
| 26 namespace web { |
| 27 class WebState; |
| 28 } |
| 29 |
| 30 // Notification when the tab history popup is shown. |
| 31 extern NSString* const kTabHistoryPopupWillShowNotification; |
| 32 // Notification when the tab history popup is hidden. |
| 33 extern NSString* const kTabHistoryPopupWillHideNotification; |
| 34 // The brightness of the omnibox placeholder text in regular mode, |
| 35 // on an iPhone. |
| 36 extern const CGFloat kiPhoneOmniboxPlaceholderColorBrightness; |
| 37 |
| 38 // Delegate interface, to be implemented by the controller's delegate. |
| 39 @protocol WebToolbarDelegate<NSObject> |
| 40 @required |
| 41 // Called when the location bar gains keyboard focus. |
| 42 - (IBAction)locationBarDidBecomeFirstResponder:(id)sender; |
| 43 // Called when the location bar loses keyboard focus. |
| 44 - (IBAction)locationBarDidResignFirstResponder:(id)sender; |
| 45 // Called when the location bar receives a key press. |
| 46 - (IBAction)locationBarBeganEdit:(id)sender; |
| 47 // Called when the stack view controller is about to be shown. |
| 48 - (IBAction)prepareToEnterTabSwitcher:(id)sender; |
| 49 // Loads the text entered in the location bar as javascript. |
| 50 // Note: The JavaScript is executed asynchronously. |
| 51 - (void)loadJavaScriptFromLocationBar:(NSString*)script; |
| 52 // Returns the WebState. |
| 53 - (web::WebState*)currentWebState; |
| 54 // Called when the toolbar height changes. Other elements, such as the web view, |
| 55 // may need to adjust accordingly. This is called from within an animation |
| 56 // block. |
| 57 - (void)toolbarHeightChanged; |
| 58 - (ToolbarModelIOS*)toolbarModelIOS; |
| 59 // Sets the alpha for the toolbar's background views. |
| 60 - (void)updateToolbarBackgroundAlpha:(CGFloat)backgroundAlpha; |
| 61 // Sets the alpha for the toolbar's background views. |
| 62 - (void)updateToolbarControlsAlpha:(CGFloat)controlsAlpha; |
| 63 @optional |
| 64 // Called before the toolbar screenshot gets updated. |
| 65 - (void)willUpdateToolbarSnapshot; |
| 66 @end |
| 67 |
| 68 // This protocol provides callbacks for focusing and blurring the omnibox. |
| 69 @protocol OmniboxFocuser |
| 70 // Give focus to the omnibox, if it is visible. No-op if it is not visible. |
| 71 - (void)focusOmnibox; |
| 72 // Cancel omnibox edit (from shield tap or cancel button tap). |
| 73 - (void)cancelOmniboxEdit; |
| 74 // Give focus to the omnibox, but indicate that the focus event was initiated |
| 75 // from the fakebox on the Google landing page. |
| 76 - (void)focusFakebox; |
| 77 // Hides the toolbar when the fakebox is blurred. |
| 78 - (void)onFakeboxBlur; |
| 79 // Shows the toolbar when the fakebox has animated to full bleed. |
| 80 - (void)onFakeboxAnimationComplete; |
| 81 @end |
| 82 |
| 83 // Web-view specific toolbar, adding navigation controls like back/forward, |
| 84 // omnibox, etc. |
| 85 @interface WebToolbarController |
| 86 : ToolbarController<OmniboxFocuser, |
| 87 QRScannerViewControllerDelegate, |
| 88 VoiceSearchControllerDelegate> |
| 89 |
| 90 @property(nonatomic, assign) id<WebToolbarDelegate> delegate; |
| 91 @property(nonatomic, assign, readonly) id<UrlLoader> urlLoader; |
| 92 |
| 93 // Mark inherited initializer as unavailable. |
| 94 - (instancetype)initWithStyle:(ToolbarControllerStyle)style NS_UNAVAILABLE; |
| 95 |
| 96 // Create a new web toolbar controller whose omnibox is backed by |
| 97 // |browserState|. |
| 98 - (instancetype)initWithDelegate:(id<WebToolbarDelegate>)delegate |
| 99 urlLoader:(id<UrlLoader>)urlLoader |
| 100 browserState:(ios::ChromeBrowserState*)browserState |
| 101 preloadProvider:(id<PreloadProvider>)preloader |
| 102 NS_DESIGNATED_INITIALIZER; |
| 103 |
| 104 // Called when the browser state this object was initialized with is being |
| 105 // destroyed. |
| 106 - (void)browserStateDestroyed; |
| 107 |
| 108 // Update the visibility of the back/forward buttons, omnibox, etc. |
| 109 - (void)updateToolbarState; |
| 110 |
| 111 // Update the visibility of the toolbar before making a side swipe snapshot so |
| 112 // the toolbar looks appropriate for |tab|. This includes morphing the toolbar |
| 113 // to look like the new tab page header. |
| 114 - (void)updateToolbarForSideSwipeSnapshot:(Tab*)tab; |
| 115 |
| 116 // Remove any formatting added by -updateToolbarForSideSwipeSnapshot. |
| 117 - (void)resetToolbarAfterSideSwipeSnapshot; |
| 118 |
| 119 // Briefly animate the progress bar when a pre-rendered tab is displayed. |
| 120 - (void)showPrerenderingAnimation; |
| 121 |
| 122 // Hides or shows the toolbar controls. When controls are hidden, the toolbar |
| 123 // will be drawn as an empty bar with the usual background. |
| 124 - (void)setControlsHidden:(BOOL)hidden; |
| 125 |
| 126 // Set the alpha of the toolbar controls, for fading while tracking gestures. |
| 127 - (void)setControlsAlpha:(CGFloat)alpha; |
| 128 |
| 129 // Called when the current page starts loading. |
| 130 - (void)currentPageLoadStarted; |
| 131 |
| 132 // Called when the current tab changes or is closed. |
| 133 - (void)selectedTabChanged; |
| 134 |
| 135 // Returns the bound of the bookmark button. Used to position the bookmark |
| 136 // editor. |
| 137 - (CGRect)bookmarkButtonAnchorRect; |
| 138 |
| 139 // Returns the bookmark button's view. Used to position the bookmark editor. |
| 140 - (UIView*)bookmarkButtonView; |
| 141 |
| 142 // Returns visible omnibox frame in WebToolbarController's view coordinate |
| 143 // system. |
| 144 - (CGRect)visibleOmniboxFrame; |
| 145 |
| 146 // Returns a UIImage containing a snapshot of the view at the given width. If |
| 147 // |width| is 0, it uses the view's current width. Returns the cached snapshot |
| 148 // if it is up to date. |
| 149 - (UIImage*)snapshotWithWidth:(CGFloat)width; |
| 150 |
| 151 // Shows the tab history popup inside |view|. |
| 152 - (void)showTabHistoryPopupInView:(UIView*)view |
| 153 withSessionEntries:(NSArray*)sessionEntries |
| 154 forBackHistory:(BOOL)isBackHistory; |
| 155 |
| 156 // Dismisses the tab history popup. |
| 157 - (void)dismissTabHistoryPopup; |
| 158 |
| 159 // Returns whether omnibox is a first responder. |
| 160 - (BOOL)isOmniboxFirstResponder; |
| 161 |
| 162 // Returns whether the omnibox popup is currently displayed. |
| 163 - (BOOL)showingOmniboxPopup; |
| 164 |
| 165 - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection; |
| 166 |
| 167 @end |
| 168 |
| 169 #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_WEB_TOOLBAR_CONTROLLER_H_ |
OLD | NEW |