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_NTP_NEW_TAB_PAGE_CONTROLLER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_CONTROLLER_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 #include <string> |
| 10 |
| 11 #include "base/mac/scoped_nsobject.h" |
| 12 #import "ios/chrome/browser/ui/native_content_controller.h" |
| 13 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar.h" |
| 14 #import "ios/chrome/browser/ui/ntp/new_tab_page_panel_protocol.h" |
| 15 #import "ios/chrome/browser/ui/toolbar/toolbar_owner.h" |
| 16 #import "ios/public/provider/chrome/browser/voice/logo_animation_controller.h" |
| 17 |
| 18 namespace ios { |
| 19 class ChromeBrowserState; |
| 20 } |
| 21 |
| 22 namespace NewTabPage { |
| 23 |
| 24 enum PanelIdentifier { |
| 25 kNone, |
| 26 kMostVisitedPanel, |
| 27 kBookmarksPanel, |
| 28 kOpenTabsPanel, |
| 29 kIncognitoPanel, |
| 30 }; |
| 31 |
| 32 // Converts from a NewTabPage::PanelIdentifier to a URL #fragment |
| 33 // and vice versa. |
| 34 PanelIdentifier IdentifierFromFragment(const std::string& fragment); |
| 35 std::string FragmentFromIdentifier(PanelIdentifier panel); |
| 36 |
| 37 } // namespace NewTabPage |
| 38 |
| 39 @protocol CRWSwipeRecognizerProvider; |
| 40 @class GoogleLandingController; |
| 41 @protocol NewTabPagePanelProtocol; |
| 42 @protocol OmniboxFocuser; |
| 43 @class TabModel; |
| 44 @protocol WebToolbarDelegate; |
| 45 @protocol UrlLoader; |
| 46 |
| 47 // This protocol provides callbacks for when the NewTabPageController changes |
| 48 // panels. |
| 49 @protocol NewTabPageControllerObserver |
| 50 // The current visible panel has changed. |
| 51 - (void)selectedPanelDidChange; |
| 52 @end |
| 53 |
| 54 // A controller for the New Tab Page user interface. Supports multiple "panels", |
| 55 // each with its own controller. The panels are created lazily. |
| 56 // |
| 57 // The scoped_nsobjects instance variables |*Controller_| are instances of |
| 58 // subclasses of NewTabPagePanelProtocol that are created lazily. |
| 59 // Each Panel is its own controller with the accessible views are added to the |
| 60 // |newTabPageView_|. |
| 61 // |
| 62 // newTabPageView_ (aka |ntpView|) is a horizontally scrollable view that |
| 63 // contains the *PanelController instances available to the user at the moment. |
| 64 // A tab-page bar inside |ntpView| provides direct access to the |
| 65 // *PanelControllers on the scrollable view. |
| 66 // |
| 67 // The currently visible *PanelController is accessible through |
| 68 // |currentController_|. |
| 69 // |
| 70 @interface NewTabPageController |
| 71 : NativeContentController<LogoAnimationControllerOwnerOwner, |
| 72 NewTabPageBarDelegate, |
| 73 NewTabPagePanelControllerDelegate, |
| 74 ToolbarOwner, |
| 75 UIGestureRecognizerDelegate, |
| 76 UIScrollViewDelegate> { |
| 77 @private |
| 78 base::scoped_nsprotocol<id<NewTabPagePanelProtocol>> bookmarkController_; |
| 79 base::scoped_nsobject<GoogleLandingController> googleLandingController_; |
| 80 base::scoped_nsprotocol<id<NewTabPagePanelProtocol>> incognitoController_; |
| 81 // The currently visible controller, one of the above. |
| 82 id<NewTabPagePanelProtocol> currentController_; // weak |
| 83 } |
| 84 |
| 85 @property(nonatomic, assign) id<CRWSwipeRecognizerProvider> |
| 86 swipeRecognizerProvider; |
| 87 |
| 88 // Init with the given url (presumably "chrome://newtab") and loader object. |
| 89 // |loader| may be nil, but isn't retained so it must outlive this controller. |
| 90 // Dominant color cache is passed to bookmark controller only, to optimize |
| 91 // favicon processing. |
| 92 - (id)initWithUrl:(const GURL&)url |
| 93 loader:(id<UrlLoader>)loader |
| 94 focuser:(id<OmniboxFocuser>)focuser |
| 95 ntpObserver:(id<NewTabPageControllerObserver>)ntpObserver |
| 96 browserState:(ios::ChromeBrowserState*)browserState |
| 97 colorCache:(NSMutableDictionary*)colorCache |
| 98 webToolbarDelegate:(id<WebToolbarDelegate>)webToolbarDelegate |
| 99 tabModel:(TabModel*)tabModel; |
| 100 |
| 101 // Select a panel based on the given |panelType|. |
| 102 - (void)selectPanel:(NewTabPage::PanelIdentifier)panelType; |
| 103 |
| 104 // Returns |YES| if the current visible controller should show the keyboard |
| 105 // shield. |
| 106 - (BOOL)wantsKeyboardShield; |
| 107 |
| 108 // Returns |YES| if the current visible controller allows showing the location |
| 109 // bar hint text. |
| 110 - (BOOL)wantsLocationBarHintText; |
| 111 |
| 112 @end |
| 113 |
| 114 #endif // IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_CONTROLLER_H_ |
OLD | NEW |