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

Side by Side Diff: chrome/browser/instant/instant_controller.h

Issue 11421079: Persist the Instant API to committed search result pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
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 CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_
6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ 6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/timer.h" 17 #include "base/timer.h"
18 #include "chrome/browser/instant/instant_commit_type.h" 18 #include "chrome/browser/instant/instant_commit_type.h"
19 #include "chrome/browser/instant/instant_model.h" 19 #include "chrome/browser/instant/instant_model.h"
20 #include "chrome/common/instant_types.h" 20 #include "chrome/common/instant_types.h"
21 #include "chrome/common/search_types.h" 21 #include "chrome/common/search_types.h"
22 #include "content/public/common/page_transition_types.h" 22 #include "content/public/common/page_transition_types.h"
23 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
24 #include "ui/gfx/native_widget_types.h" 24 #include "ui/gfx/native_widget_types.h"
25 #include "ui/gfx/rect.h" 25 #include "ui/gfx/rect.h"
26 26
27 struct AutocompleteMatch; 27 struct AutocompleteMatch;
28 class AutocompleteProvider; 28 class AutocompleteProvider;
29 class InstantClient;
29 class InstantLoader; 30 class InstantLoader;
30 class TabContents; 31 class TabContents;
31 class TemplateURL; 32 class TemplateURL;
32 struct ThemeBackgroundInfo; 33 struct ThemeBackgroundInfo;
33 34
34 namespace chrome { 35 namespace chrome {
35 class BrowserInstantController; 36 class BrowserInstantController;
36 } 37 }
37 38
38 // InstantController maintains a WebContents that is intended to give a preview 39 // InstantController maintains a WebContents that is intended to give a preview
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 87
87 // The omnibox has gained focus. Preload the default search engine, in 88 // The omnibox has gained focus. Preload the default search engine, in
88 // anticipation of the user typing a query. 89 // anticipation of the user typing a query.
89 void OmniboxGotFocus(); 90 void OmniboxGotFocus();
90 91
91 // The search mode in the active tab has changed. Pass the message down to 92 // The search mode in the active tab has changed. Pass the message down to
92 // the loader which will notify the renderer. 93 // the loader which will notify the renderer.
93 void SearchModeChanged(const chrome::search::Mode& old_mode, 94 void SearchModeChanged(const chrome::search::Mode& old_mode,
94 const chrome::search::Mode& new_mode); 95 const chrome::search::Mode& new_mode);
95 96
96 // The user switched tabs. Hide the preview if needed. 97 // The user switched tabs. Hide the preview if needed.
sky 2012/11/27 01:07:51 Update comment.
sreeram 2012/11/29 07:33:19 Done.
97 void ActiveTabChanged(); 98 void ActiveTabChanged();
98 99
99 // Sets whether Instant should show result previews. 100 // Sets whether Instant should show result previews.
100 void SetInstantEnabled(bool instant_enabled); 101 void SetInstantEnabled(bool instant_enabled);
101 102
102 // The theme has changed. Pass the message down to the loader which will 103 // The theme has changed. Pass the message down to the loader which will
103 // notify the renderer. 104 // notify the renderer.
104 void ThemeChanged(const ThemeBackgroundInfo& theme_info); 105 void ThemeChanged(const ThemeBackgroundInfo& theme_info);
105 106
106 // The theme area height has changed. Pass the message down to the loader 107 // The theme area height has changed. Pass the message down to the loader
107 // which will notify the renderer. 108 // which will notify the renderer.
108 void ThemeAreaHeightChanged(int height); 109 void ThemeAreaHeightChanged(int height);
109 110
110 // Returns the transition type of the last AutocompleteMatch passed to Update. 111 // Returns the transition type of the last AutocompleteMatch passed to Update.
111 content::PageTransition last_transition_type() const { 112 content::PageTransition last_transition_type() const {
112 return last_transition_type_; 113 return last_transition_type_;
113 } 114 }
114 115
115 const InstantModel* model() const { return &model_; } 116 const InstantModel* model() const { return &model_; }
116 117
117 // Invoked by InstantLoader when it has suggested text. 118 // Invoked by InstantLoader when it has suggested text.
Jered 2012/11/27 19:21:57 InstantLoader -> client
sreeram 2012/11/29 07:33:19 Done.
118 void SetSuggestions(InstantLoader* loader, 119 void SetSuggestions(InstantClient* client,
119 const std::vector<InstantSuggestion>& suggestions); 120 const std::vector<InstantSuggestion>& suggestions);
120 121
121 // Invoked by InstantLoader to commit the preview. 122 // Invoked by InstantLoader to commit the preview.
122 void CommitInstantLoader(InstantLoader* loader); 123 void CommitInstantLoader(InstantLoader* loader);
123 124
124 // Invoked by InstantLoader to request that the preview be shown. 125 // Invoked by InstantLoader to request that the preview be shown.
125 void ShowInstantPreview(InstantLoader* loader, 126 void ShowInstantPreview(InstantLoader* loader,
126 InstantShownReason reason, 127 InstantShownReason reason,
127 int height, 128 int height,
128 InstantSizeUnits units); 129 InstantSizeUnits units);
129 130
130 // Invoked by InstantLoader when it has determined whether or not the page 131 // Invoked by InstantLoader when it has determined whether or not the page
Jered 2012/11/27 19:21:57 InstantLoader -> client
sreeram 2012/11/29 07:33:19 Done.
131 // supports the Instant API. 132 // supports the Instant API.
132 void InstantSupportDetermined(InstantLoader* loader, bool supports_instant); 133 void InstantSupportDetermined(InstantClient* client, bool supports_instant);
133 134
134 // Invoked by InstantLoader when it has swapped a different TabContents into 135 // Invoked by InstantLoader when it has swapped a different TabContents into
135 // the preview, usually because a prerendered page was navigated to. 136 // the preview, usually because a prerendered page was navigated to.
136 void SwappedTabContents(InstantLoader* loader); 137 void SwappedTabContents(InstantLoader* loader);
137 138
138 // Invoked by InstantLoader when the preview gains focus, usually due to the 139 // Invoked by InstantLoader when the preview gains focus, usually due to the
139 // user clicking on it. 140 // user clicking on it.
140 void InstantLoaderContentsFocused(InstantLoader* loader); 141 void InstantLoaderContentsFocused(InstantLoader* loader);
141 142
142 #if defined(UNIT_TEST) 143 #if defined(UNIT_TEST)
143 // Accessors used only in tests. 144 // Accessors used only in tests.
144 InstantLoader* loader() const { return loader_.get(); } 145 InstantLoader* loader() const { return loader_.get(); }
145 #endif 146 #endif
146 147
147 private: 148 private:
148 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); 149 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh);
149 150
151 void ResetClient();
152
150 // Creates a new loader if necessary, using the instant_url property of the 153 // Creates a new loader if necessary, using the instant_url property of the
151 // |template_url| (for example, if the Instant URL has changed since the last 154 // |template_url| (for example, if the Instant URL has changed since the last
152 // time the loader was created). Returns false if the |template_url| doesn't 155 // time the loader was created). Returns false if the |template_url| doesn't
153 // have a valid Instant URL; true otherwise. 156 // have a valid Instant URL; true otherwise.
154 bool ResetLoader(const TemplateURL* template_url, 157 bool ResetLoader(const TemplateURL* template_url,
155 const TabContents* active_tab); 158 const TabContents* active_tab);
156 159
157 // Ensures that the |loader_| uses the default Instant URL, recreating it if 160 // Ensures that the |loader_| uses the default Instant URL, recreating it if
158 // necessary, and returns true. Returns false if the Instant URL could not be 161 // necessary, and returns true. Returns false if the Instant URL could not be
159 // determined or the active tab is NULL (browser is shutting down). 162 // determined or the active tab is NULL (browser is shutting down).
(...skipping 19 matching lines...) Expand all
179 // Send the omnibox dropdown bounds to the page. 182 // Send the omnibox dropdown bounds to the page.
180 void SendBoundsToPage(); 183 void SendBoundsToPage();
181 184
182 // If |template_url| is a valid TemplateURL for use with Instant, fills in 185 // If |template_url| is a valid TemplateURL for use with Instant, fills in
183 // |instant_url| and returns true; returns false otherwise. 186 // |instant_url| and returns true; returns false otherwise.
184 // Note: If the command-line switch kInstantURL is set, this method uses its 187 // Note: If the command-line switch kInstantURL is set, this method uses its
185 // value for |instant_url| and returns true without examining |template_url|. 188 // value for |instant_url| and returns true without examining |template_url|.
186 bool GetInstantURL(const TemplateURL* template_url, 189 bool GetInstantURL(const TemplateURL* template_url,
187 std::string* instant_url) const; 190 std::string* instant_url) const;
188 191
192 InstantClient* CurrentClient() const;
193
189 chrome::BrowserInstantController* const browser_; 194 chrome::BrowserInstantController* const browser_;
190 195
191 // Whether the extended API and regular API are enabled. If both are false, 196 // Whether the extended API and regular API are enabled. If both are false,
192 // Instant is effectively disabled. 197 // Instant is effectively disabled.
193 const bool extended_enabled_; 198 const bool extended_enabled_;
194 bool instant_enabled_; 199 bool instant_enabled_;
195 200
196 InstantModel model_; 201 InstantModel model_;
samarth 2012/11/27 18:09:43 Worth clarifying somewhere that model_ only reflec
sreeram 2012/11/29 07:33:19 Done.
197 202
203 scoped_ptr<InstantClient> client_;
sky 2012/11/27 01:07:51 Since InstantLoader is also an InstantClient using
sreeram 2012/11/29 07:33:19 Done.
198 scoped_ptr<InstantLoader> loader_; 204 scoped_ptr<InstantLoader> loader_;
Jered 2012/11/27 19:21:57 It feels funny to me that InstantController owns c
sreeram 2012/11/29 07:33:19 Ack. As per previous comments, I've kept the owner
199 205
200 // The most recent user_text passed to Update(). 206 // The most recent user_text passed to Update().
201 string16 last_user_text_; 207 string16 last_user_text_;
202 208
203 // The most recent full_text passed to Update(). 209 // The most recent full_text passed to Update().
204 string16 last_full_text_; 210 string16 last_full_text_;
205 211
206 // The most recent verbatim passed to Update(). 212 // The most recent verbatim passed to Update().
207 bool last_verbatim_; 213 bool last_verbatim_;
208 214
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 255
250 // The timestamp at which query editing began. This value is used when the 256 // The timestamp at which query editing began. This value is used when the
251 // first set of suggestions is processed and cleared when the overlay is 257 // first set of suggestions is processed and cleared when the overlay is
252 // hidden. 258 // hidden.
253 base::Time first_interaction_time_; 259 base::Time first_interaction_time_;
254 260
255 DISALLOW_COPY_AND_ASSIGN(InstantController); 261 DISALLOW_COPY_AND_ASSIGN(InstantController);
256 }; 262 };
257 263
258 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ 264 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698