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

Side by Side Diff: ios/chrome/browser/ui/contextual_search/contextual_search_controller.h

Issue 2588713002: Upstream Chrome on iOS source code [4/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 2015 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_CONTEXTUAL_SEARCH_CONTEXTUAL_SEARCH_CONTROLLER_H_
6 #define IOS_CHROME_BROWSER_UI_CONTEXTUAL_SEARCH_CONTEXTUAL_SEARCH_CONTROLLER_H_
7
8 #import <UIKit/UIKit.h>
9
10 #include "base/ios/block_types.h"
11 #include "base/strings/string16.h"
12 #include "ios/chrome/browser/ui/contextual_search/panel_configuration.h"
13
14 namespace ios {
15 class ChromeBrowserState;
16 }
17
18 namespace web {
19 class WebState;
20 }
21
22 class GURL;
23 @class Tab;
24 @class TouchToSearchPermissionsMediator;
25
26 namespace ContextualSearch {
27 // Possible reason for panel state changes.
28 enum StateChangeReason {
29 UNKNOWN,
30 RESET,
31 BACK_PRESS, // This is Android-only; we should never use this value.
32 TEXT_SELECT_TAP,
33 TEXT_SELECT_LONG_PRESS,
34 INVALID_SELECTION,
35 BASE_PAGE_TAP,
36 BASE_PAGE_SCROLL,
37 SEARCH_BAR_TAP,
38 SERP_NAVIGATION,
39 TAB_PROMOTION,
40 CLICK,
41 SWIPE, // Moved by going to the nearest state when a drag ends.
42 FLING, // Moved by interpolating a drag with velocity.
43 OPTIN,
44 OPTOUT
45 };
46 } // namespace ContextualSearch
47
48 @class ContextualSearchController;
49 @class ContextualSearchPanelView;
50 @class ContextualSearchResultsView;
51
52 @protocol ContextualSearchTabProvider<NSObject>
53 // Disassociate the internal Tab object from this view and return it.
54 - (Tab*)releaseTab;
55 @end
56
57 @protocol ContextualSearchControllerDelegate<NSObject>
58
59 // Called by the controller when it has tab content for the delegate to load
60 // and display as a new tab; the content is provided by -releaseSearchTab.
61 // |focusInput| indicates that the after promoting the tab, the delegate must
62 // focus the main input.
63 - (void)promotePanelToTabProvidedBy:(id<ContextualSearchTabProvider>)tabProvider
64 focusInput:(BOOL)focusInput;
65
66 // Called by the controller when it has a link for the delegate to load
67 // and display as a new tab.
68 - (void)createTabFromContextualSearchController:(const GURL&)url;
69
70 // Provides the current height of the headers at the top of the screen.
71 - (CGFloat)currentHeaderHeight;
72
73 @end
74
75 // Controller for handling contextual search gestures.
76 @interface ContextualSearchController : NSObject
77
78 // YES if contextual search is enabled on the current WebState.
79 @property(readonly) BOOL enabled;
80
81 // The current web state being watched for contextual search events.
82 // Only tests should set this directly; for general use, use -setTab:, which
83 // will set this property with the tab's webState.
84 @property(nonatomic, assign) web::WebState* webState;
85
86 // The panel view that this controller should populate with subviews and use.
87 // Owned by its superview. Setting this will have the controller create subviews
88 // for the panel; code that sets this property is responsible for disposing of
89 // the old panel and its views.
90 // This property can only be assigned a non-nil value, and can only be assigned
91 // a value when its current value is nil.
92 @property(nonatomic, assign) ContextualSearchPanelView* panel;
93
94 // Designated initializer.
95 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
96 delegate:(id<ContextualSearchControllerDelegate>)
97 delegate;
98
99 // Set the Tab to be used as the opener for the search results tab. |opener|'s
100 // lifetime should be greater than the reciever's. |opener| can be nil.
101 - (void)setTab:(Tab*)tab;
102
103 // Enable or disable contextual search for the current WebState. If
104 // |enabled| is YES, contextual search may still not be enabled for a number of
105 // reasons; the -enabled property will indicate the current status.
106 // This method functions asynchronously.
107 - (void)enableContextualSearch:(BOOL)enabled;
108
109 // Reset the pane to be offscreen when tabs change.
110 - (void)movePanelOffscreen;
111
112 // Destroy the receiver.
113 // Any following call is not supported.
114 - (void)close;
115
116 @end
117
118 // Testing category that allows a permissions class to be injected.
119 @interface ContextualSearchController (Testing)
120
121 - (void)setPermissions:(TouchToSearchPermissionsMediator*)permissions;
122
123 @end
124
125 #endif // IOS_CHROME_BROWSER_UI_CONTEXTUAL_SEARCH_CONTEXTUAL_SEARCH_CONTROLLER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698