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

Side by Side Diff: chrome/browser/ui/search/instant_page.h

Issue 17303003: InstantExtended: hook up InstantTab in incognito. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile errors. Created 7 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/search/instant_overlay.cc ('k') | chrome/browser/ui/search/instant_page.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_
6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "chrome/browser/ui/search/instant_ipc_sender.h"
14 #include "chrome/browser/ui/search/search_model_observer.h" 16 #include "chrome/browser/ui/search/search_model_observer.h"
15 #include "chrome/common/instant_types.h" 17 #include "chrome/common/instant_types.h"
16 #include "chrome/common/omnibox_focus_state.h" 18 #include "chrome/common/omnibox_focus_state.h"
17 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
18 #include "content/public/common/page_transition_types.h" 20 #include "content/public/common/page_transition_types.h"
19 21
20 class GURL; 22 class GURL;
21 23
22 namespace content { 24 namespace content {
23 struct FrameNavigateParams; 25 struct FrameNavigateParams;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 106
105 protected: 107 protected:
106 virtual ~Delegate(); 108 virtual ~Delegate();
107 }; 109 };
108 110
109 virtual ~InstantPage(); 111 virtual ~InstantPage();
110 112
111 // The WebContents corresponding to the page we're talking to. May be NULL. 113 // The WebContents corresponding to the page we're talking to. May be NULL.
112 content::WebContents* contents() const { return web_contents(); } 114 content::WebContents* contents() const { return web_contents(); }
113 115
116 // Used to send IPC messages to the page.
117 InstantIPCSender* sender() const { return ipc_sender_.get(); }
118
114 // Returns the Instant URL that was loaded for this page. Returns the empty 119 // Returns the Instant URL that was loaded for this page. Returns the empty
115 // string if no URL was explicitly loaded as is the case for InstantTab. 120 // string if no URL was explicitly loaded as is the case for InstantTab.
116 virtual const std::string& instant_url() const; 121 virtual const std::string& instant_url() const;
117 122
118 // Returns true if the page is known to support the Instant API. This starts 123 // Returns true if the page is known to support the Instant API. This starts
119 // out false, and is set to true whenever we get any message from the page. 124 // out false, and is set to true whenever we get any message from the page.
120 // Once true, it never becomes false (the page isn't expected to drop API 125 // Once true, it never becomes false (the page isn't expected to drop API
121 // support suddenly). 126 // support suddenly).
122 virtual bool supports_instant() const; 127 virtual bool supports_instant() const;
123 128
124 // Returns true if the page is the local NTP (i.e. its URL is 129 // Returns true if the page is the local NTP (i.e. its URL is
125 // chrome::kChromeSearchLocalNTPURL). 130 // chrome::kChromeSearchLocalNTPURL).
126 virtual bool IsLocal() const; 131 virtual bool IsLocal() const;
127 132
128 // Tells the page that the user typed |text| into the omnibox. If |verbatim|
129 // is false, the page predicts the query the user means to type and fetches
130 // results for the prediction. If |verbatim| is true, |text| is taken as the
131 // exact query (no prediction is made). |selection_start| and |selection_end|
132 // mark the inline autocompleted portion (i.e., blue highlighted text). The
133 // omnibox caret (cursor) is at |selection_end|.
134 virtual void Update(const string16& text,
135 size_t selection_start,
136 size_t selection_end,
137 bool verbatim);
138
139 // Tells the page that the user pressed Enter in the omnibox.
140 void Submit(const string16& text);
141
142 // Tells the page that the user clicked on it. Nothing is being cancelled; the
143 // poor choice of name merely reflects the IPC of the same (poor) name.
144 void Cancel(const string16& text);
145
146 // Tells the page the bounds of the omnibox dropdown (in screen coordinates).
147 // This is used by the page to offset the results to avoid them being covered
148 // by the omnibox dropdown.
149 void SetPopupBounds(const gfx::Rect& bounds);
150
151 // Tells the page the bounds of the omnibox (in screen coordinates). This is
152 // used by the page to align text or assets properly with the omnibox.
153 void SetOmniboxBounds(const gfx::Rect& bounds);
154
155 // Tells the page about the font information.
156 void InitializeFonts(); 133 void InitializeFonts();
157 134
158 // Tells the page about the available autocomplete results.
159 void SendAutocompleteResults(
160 const std::vector<InstantAutocompleteResult>& results);
161
162 // Tells the page that the user pressed Up or Down in the omnibox. |count| is
163 // a repeat count, negative for moving up, positive for moving down.
164 void UpOrDownKeyPressed(int count);
165
166 // Tells the page that the user pressed Esc key in the omnibox.
167 void EscKeyPressed();
168
169 // Tells the page that the user pressed Esc in the omnibox after having
170 // arrowed down in the suggestions. The page should reset the selection to
171 // the first suggestion. Arguments are the same as those for Update().
172 void CancelSelection(const string16& user_text,
173 size_t selection_start,
174 size_t selection_end,
175 bool verbatim);
176
177 // Tells the page about the current theme background.
178 void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info);
179
180 // Tells the page whether it is allowed to display Instant results.
181 void SetDisplayInstantResults(bool display_instant_results);
182
183 // Tells the page that the omnibox focus has changed.
184 void FocusChanged(OmniboxFocusState state, OmniboxFocusChangeReason reason);
185
186 // Tells the page that user input started or stopped.
187 void SetInputInProgress(bool input_in_progress);
188
189 // Tells the page about new Most Visited data.
190 void SendMostVisitedItems(
191 const std::vector<InstantMostVisitedItem>& items);
192
193 // Tells the page to toggle voice search.
194 void ToggleVoiceSearch();
195
196 protected: 135 protected:
197 InstantPage(Delegate* delegate, const std::string& instant_url); 136 InstantPage(Delegate* delegate, const std::string& instant_url,
137 bool is_incognito);
198 138
199 // Sets |web_contents| as the page to communicate with. |web_contents| may be 139 // Sets |web_contents| as the page to communicate with. |web_contents| may be
200 // NULL, which effectively stops all communication. 140 // NULL, which effectively stops all communication.
201 void SetContents(content::WebContents* web_contents); 141 void SetContents(content::WebContents* web_contents);
202 142
203 Delegate* delegate() const { return delegate_; } 143 Delegate* delegate() const { return delegate_; }
204 144
205 // These functions are called before processing messages received from the 145 // These functions are called before processing messages received from the
206 // page. By default, all messages are handled, but any derived classes may 146 // page. By default, all messages are handled, but any derived classes may
207 // choose to ignore some or all of the received messages by overriding these 147 // choose to ignore some or all of the received messages by overriding these
(...skipping 13 matching lines...) Expand all
221 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 161 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
222 DispatchRequestToDeleteMostVisitedItem); 162 DispatchRequestToDeleteMostVisitedItem);
223 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 163 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
224 DispatchRequestToUndoMostVisitedDeletion); 164 DispatchRequestToUndoMostVisitedDeletion);
225 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 165 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
226 DispatchRequestToUndoAllMostVisitedDeletions); 166 DispatchRequestToUndoAllMostVisitedDeletions);
227 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 167 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
228 IgnoreMessageIfThePageIsNotActive); 168 IgnoreMessageIfThePageIsNotActive);
229 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 169 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
230 IgnoreMessageReceivedFromThePage); 170 IgnoreMessageReceivedFromThePage);
171 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
172 IgnoreMessageReceivedFromIncognitoPage);
231 173
232 // Overridden from content::WebContentsObserver: 174 // Overridden from content::WebContentsObserver:
233 virtual void RenderViewCreated( 175 virtual void RenderViewCreated(
234 content::RenderViewHost* render_view_host) OVERRIDE; 176 content::RenderViewHost* render_view_host) OVERRIDE;
235 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 177 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
236 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 178 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
237 virtual void DidCommitProvisionalLoadForFrame( 179 virtual void DidCommitProvisionalLoadForFrame(
238 int64 frame_id, 180 int64 frame_id,
239 bool is_main_frame, 181 bool is_main_frame,
240 const GURL& url, 182 const GURL& url,
(...skipping 28 matching lines...) Expand all
269 content::PageTransition transition, 211 content::PageTransition transition,
270 WindowOpenDisposition disposition, 212 WindowOpenDisposition disposition,
271 bool is_search_type); 213 bool is_search_type);
272 void OnDeleteMostVisitedItem(int page_id, const GURL& url); 214 void OnDeleteMostVisitedItem(int page_id, const GURL& url);
273 void OnUndoMostVisitedDeletion(int page_id, const GURL& url); 215 void OnUndoMostVisitedDeletion(int page_id, const GURL& url);
274 void OnUndoAllMostVisitedDeletions(int page_id); 216 void OnUndoAllMostVisitedDeletions(int page_id);
275 217
276 void ClearContents(); 218 void ClearContents();
277 219
278 Delegate* const delegate_; 220 Delegate* const delegate_;
221 scoped_ptr<InstantIPCSender> ipc_sender_;
279 const std::string instant_url_; 222 const std::string instant_url_;
223 const bool is_incognito_;
280 224
281 DISALLOW_COPY_AND_ASSIGN(InstantPage); 225 DISALLOW_COPY_AND_ASSIGN(InstantPage);
282 }; 226 };
283 227
284 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ 228 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_overlay.cc ('k') | chrome/browser/ui/search/instant_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698