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_BROWSER_VIEW_BROWSER_VIEW_CONTROLLER_H_
6 #define IOS_CHROME_BROWSER_UI_BROWSER_VIEW_BROWSER_VIEW_CONTROLLER_H_
7 
8 #import <UIKit/UIKit.h>
9 
10 #import "base/ios/block_types.h"
11 #import "ios/chrome/browser/ui/find_bar/find_bar_coordinator.h"
12 #import "ios/chrome/browser/ui/gestures/view_revealing_vertical_pan_handler.h"
13 #import "ios/chrome/browser/ui/page_info/requirements/page_info_presentation.h"
14 #import "ios/chrome/browser/ui/settings/sync/utils/sync_presenter.h"
15 #import "ios/chrome/browser/ui/thumb_strip/thumb_strip_attacher.h"
16 #import "ios/chrome/browser/ui/toolbar/toolbar_coordinator_delegate.h"
17 #import "ios/public/provider/chrome/browser/voice/logo_animation_controller.h"
18 
19 @protocol ActivityServicePositioner;
20 class Browser;
21 @class BrowserContainerViewController;
22 @class BrowserViewControllerDependencyFactory;
23 @class CommandDispatcher;
24 @class ToolbarAccessoryPresenter;
25 
26 // The top-level view controller for the browser UI. Manages other controllers
27 // which implement the interface.
28 @interface BrowserViewController
29     : UIViewController <LogoAnimationControllerOwnerOwner,
30                         FindBarPresentationDelegate,
31                         PageInfoPresentation,
32                         SyncPresenter,
33                         ThumbStripAttacher,
34                         ToolbarCoordinatorDelegate>
35 
36 // Initializes a new BVC from its nib. |model| must not be nil. The
37 // webUsageSuspended property for this BVC will be based on |model|, and future
38 // changes to |model|'s suspension state should be made through this BVC
39 // instead of directly on the model.
40 // TODO(crbug.com/992582): Remove references to model objects from this class.
41 - (instancetype)initWithBrowser:(Browser*)browser
42                  dependencyFactory:
43                      (BrowserViewControllerDependencyFactory*)factory
44     browserContainerViewController:
45         (BrowserContainerViewController*)browserContainerViewController
46                         dispatcher:(CommandDispatcher*)dispatcher
47     NS_DESIGNATED_INITIALIZER;
48 
49 - (instancetype)initWithNibName:(NSString*)nibNameOrNil
50                          bundle:(NSBundle*)nibBundleOrNil NS_UNAVAILABLE;
51 
52 - (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
53 
54 // Command dispatcher.
55 @property(nonatomic, weak) CommandDispatcher* commandDispatcher;
56 
57 // Returns whether or not text to speech is playing.
58 @property(nonatomic, assign, readonly, getter=isPlayingTTS) BOOL playingTTS;
59 
60 // The container used for infobar banner overlays.
61 @property(nonatomic, strong)
62     UIViewController* infobarBannerOverlayContainerViewController;
63 
64 // The container used for infobar modal overlays.
65 @property(nonatomic, strong)
66     UIViewController* infobarModalOverlayContainerViewController;
67 
68 // Presenter used to display accessories over the toolbar (e.g. Find In Page).
69 @property(nonatomic, strong)
70     ToolbarAccessoryPresenter* toolbarAccessoryPresenter;
71 
72 // Positioner for activity services attached to the toolbar.
73 @property(nonatomic, readonly) id<ActivityServicePositioner>
74     activityServicePositioner;
75 
76 // Whether the receiver is currently the primary BVC.
77 - (void)setPrimary:(BOOL)primary;
78 
79 // Called when the user explicitly opens the tab switcher.
80 - (void)userEnteredTabSwitcher;
81 
82 // Opens a new tab as if originating from |originPoint| and |focusOmnibox|.
83 - (void)openNewTabFromOriginPoint:(CGPoint)originPoint
84                      focusOmnibox:(BOOL)focusOmnibox;
85 
86 // Adds |tabAddedCompletion| to the completion block (if any) that will be run
87 // the next time a tab is added to the TabModel this object was initialized
88 // with.
89 - (void)appendTabAddedCompletion:(ProceduralBlock)tabAddedCompletion;
90 
91 // Informs the BVC that a new foreground tab is about to be opened. This is
92 // intended to be called before setWebUsageSuspended:NO in cases where a new tab
93 // is about to appear in order to allow the BVC to avoid doing unnecessary work
94 // related to showing the previously selected tab.
95 - (void)expectNewForegroundTab;
96 
97 // Shows the voice search UI.
98 - (void)startVoiceSearch;
99 
100 @end
101 
102 #endif  // IOS_CHROME_BROWSER_UI_BROWSER_VIEW_BROWSER_VIEW_CONTROLLER_H_
103