| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_CONTROLLER_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_CONTROLLER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_CONTROLLER_H_ | 6 #define IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/mac/scoped_nsobject.h" | |
| 12 #import "ios/chrome/browser/ui/native_content_controller.h" | 11 #import "ios/chrome/browser/ui/native_content_controller.h" |
| 13 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar.h" | 12 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar.h" |
| 14 #import "ios/chrome/browser/ui/ntp/new_tab_page_panel_protocol.h" | 13 #import "ios/chrome/browser/ui/ntp/new_tab_page_panel_protocol.h" |
| 15 #import "ios/chrome/browser/ui/toolbar/toolbar_owner.h" | 14 #import "ios/chrome/browser/ui/toolbar/toolbar_owner.h" |
| 16 #import "ios/public/provider/chrome/browser/voice/logo_animation_controller.h" | 15 #import "ios/public/provider/chrome/browser/voice/logo_animation_controller.h" |
| 17 | 16 |
| 18 namespace ios { | 17 namespace ios { |
| 19 class ChromeBrowserState; | 18 class ChromeBrowserState; |
| 20 } | 19 } |
| 21 | 20 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 48 // This protocol provides callbacks for when the NewTabPageController changes | 47 // This protocol provides callbacks for when the NewTabPageController changes |
| 49 // panels. | 48 // panels. |
| 50 @protocol NewTabPageControllerObserver | 49 @protocol NewTabPageControllerObserver |
| 51 // The current visible panel has changed. | 50 // The current visible panel has changed. |
| 52 - (void)selectedPanelDidChange; | 51 - (void)selectedPanelDidChange; |
| 53 @end | 52 @end |
| 54 | 53 |
| 55 // A controller for the New Tab Page user interface. Supports multiple "panels", | 54 // A controller for the New Tab Page user interface. Supports multiple "panels", |
| 56 // each with its own controller. The panels are created lazily. | 55 // each with its own controller. The panels are created lazily. |
| 57 // | 56 // |
| 58 // The scoped_nsobjects instance variables |*Controller_| are instances of | 57 // The strongly retained instance variables |*Controller_| are instances of |
| 59 // subclasses of NewTabPagePanelProtocol that are created lazily. | 58 // subclasses of NewTabPagePanelProtocol that are created lazily. |
| 60 // Each Panel is its own controller with the accessible views are added to the | 59 // Each Panel is its own controller with the accessible views are added to the |
| 61 // |newTabPageView_|. | 60 // |ntpView_|. |
| 62 // | 61 // |
| 63 // newTabPageView_ (aka |ntpView|) is a horizontally scrollable view that | 62 // newTabPageView_ is a horizontally scrollable view that contains the |
| 64 // contains the *PanelController instances available to the user at the moment. | 63 // *PanelController instances available to the user at the moment. A tab-page |
| 65 // A tab-page bar inside |ntpView| provides direct access to the | 64 // bar inside |ntpView| provides direct access to the *PanelControllers on the |
| 66 // *PanelControllers on the scrollable view. | 65 // scrollable view. |
| 67 // | 66 // |
| 68 // The currently visible *PanelController is accessible through | 67 // The currently visible *PanelController is accessible through |
| 69 // |currentController_|. | 68 // |currentController_|. |
| 70 // | 69 // |
| 71 @interface NewTabPageController | 70 @interface NewTabPageController |
| 72 : NativeContentController<LogoAnimationControllerOwnerOwner, | 71 : NativeContentController<LogoAnimationControllerOwnerOwner, |
| 73 NewTabPageBarDelegate, | 72 NewTabPageBarDelegate, |
| 74 NewTabPagePanelControllerDelegate, | 73 NewTabPagePanelControllerDelegate, |
| 75 ToolbarOwner, | 74 ToolbarOwner, |
| 76 UIGestureRecognizerDelegate, | 75 UIGestureRecognizerDelegate, |
| 77 UIScrollViewDelegate> { | 76 UIScrollViewDelegate> |
| 78 @private | |
| 79 base::scoped_nsobject<BookmarkHomeTabletNTPController> bookmarkController_; | |
| 80 base::scoped_nsobject<GoogleLandingViewController> googleLandingController_; | |
| 81 base::scoped_nsprotocol<id<NewTabPagePanelProtocol>> incognitoController_; | |
| 82 // The currently visible controller, one of the above. | |
| 83 id<NewTabPagePanelProtocol> currentController_; // weak | |
| 84 } | |
| 85 | 77 |
| 86 @property(nonatomic, assign) id<CRWSwipeRecognizerProvider> | 78 @property(nonatomic, weak) id<CRWSwipeRecognizerProvider> |
| 87 swipeRecognizerProvider; | 79 swipeRecognizerProvider; |
| 88 | 80 |
| 89 // Init with the given url (presumably "chrome://newtab") and loader object. | 81 // Init with the given url (presumably "chrome://newtab") and loader object. |
| 90 // |loader| may be nil, but isn't retained so it must outlive this controller. | 82 // |loader| may be nil, but isn't retained so it must outlive this controller. |
| 91 // Dominant color cache is passed to bookmark controller only, to optimize | 83 // Dominant color cache is passed to bookmark controller only, to optimize |
| 92 // favicon processing. | 84 // favicon processing. |
| 93 - (id)initWithUrl:(const GURL&)url | 85 - (id)initWithUrl:(const GURL&)url |
| 94 loader:(id<UrlLoader>)loader | 86 loader:(id<UrlLoader>)loader |
| 95 focuser:(id<OmniboxFocuser>)focuser | 87 focuser:(id<OmniboxFocuser>)focuser |
| 96 ntpObserver:(id<NewTabPageControllerObserver>)ntpObserver | 88 ntpObserver:(id<NewTabPageControllerObserver>)ntpObserver |
| (...skipping 10 matching lines...) Expand all Loading... |
| 107 // Returns |YES| if the current visible controller should show the keyboard | 99 // Returns |YES| if the current visible controller should show the keyboard |
| 108 // shield. | 100 // shield. |
| 109 - (BOOL)wantsKeyboardShield; | 101 - (BOOL)wantsKeyboardShield; |
| 110 | 102 |
| 111 // Returns |YES| if the current visible controller allows showing the location | 103 // Returns |YES| if the current visible controller allows showing the location |
| 112 // bar hint text. | 104 // bar hint text. |
| 113 - (BOOL)wantsLocationBarHintText; | 105 - (BOOL)wantsLocationBarHintText; |
| 114 | 106 |
| 115 @end | 107 @end |
| 116 | 108 |
| 109 #pragma mark - Testing |
| 110 |
| 111 @class NewTabPageView; |
| 112 |
| 113 @interface NewTabPageController (TestSupport) |
| 114 @property(nonatomic, strong) NewTabPageView* ntpView; |
| 115 |
| 116 - (id<NewTabPagePanelProtocol>)currentController; |
| 117 - (BookmarkHomeTabletNTPController*)bookmarkController; |
| 118 - (GoogleLandingViewController*)googleLandingController; |
| 119 - (id<NewTabPagePanelProtocol>)incognitoController; |
| 120 @end |
| 121 |
| 117 #endif // IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_CONTROLLER_H_ | 122 #endif // IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_CONTROLLER_H_ |
| OLD | NEW |