OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 virtual void CommitInstantLoader(InstantLoader* loader) OVERRIDE; | 186 virtual void CommitInstantLoader(InstantLoader* loader) OVERRIDE; |
187 virtual void InstantLoaderDoesntSupportInstant( | 187 virtual void InstantLoaderDoesntSupportInstant( |
188 InstantLoader* loader) OVERRIDE; | 188 InstantLoader* loader) OVERRIDE; |
189 virtual void AddToBlacklist(InstantLoader* loader, | 189 virtual void AddToBlacklist(InstantLoader* loader, |
190 const GURL& url) OVERRIDE; | 190 const GURL& url) OVERRIDE; |
191 virtual void SwappedTabContents(InstantLoader* loader) OVERRIDE; | 191 virtual void SwappedTabContents(InstantLoader* loader) OVERRIDE; |
192 | 192 |
193 private: | 193 private: |
194 friend class InstantTest; | 194 friend class InstantTest; |
195 | 195 |
| 196 enum PreviewCondition { |
| 197 PREVIEW_CONDITION_SUCCESS, |
| 198 PREVIEW_CONDITION_INVALID_TEMPLATE_URL, |
| 199 PREVIEW_CONDITION_JAVASCRIPT_SCHEME, |
| 200 PREVIEW_CONDITION_EXTENSION_KEYWORD, |
| 201 PREVIEW_CONDITION_BLACKLISTED, |
| 202 PREVIEW_CONDITION_INSTANT_SEARCH_ONLY, |
| 203 }; |
| 204 |
196 typedef std::set<std::string> HostBlacklist; | 205 typedef std::set<std::string> HostBlacklist; |
197 | 206 |
198 // Updates |displayable_loader_| and if necessary notifies the delegate. | 207 // Updates |displayable_loader_| and if necessary notifies the delegate. |
199 void UpdateDisplayableLoader(); | 208 void UpdateDisplayableLoader(); |
200 | 209 |
201 // Returns the TabContents of the pending loader (or NULL). This is only used | 210 // Returns the TabContents of the pending loader (or NULL). This is only used |
202 // for testing. | 211 // for testing. |
203 TabContentsWrapper* GetPendingPreviewContents(); | 212 TabContentsWrapper* GetPendingPreviewContents(); |
204 | 213 |
205 // Returns true if we should update immediately. | 214 // Returns true if we should update immediately. |
(...skipping 15 matching lines...) Expand all Loading... |
221 | 230 |
222 // Updates InstantLoaderManager and its current InstantLoader. This is invoked | 231 // Updates InstantLoaderManager and its current InstantLoader. This is invoked |
223 // internally from Update. | 232 // internally from Update. |
224 void UpdateLoader(const TemplateURL* template_url, | 233 void UpdateLoader(const TemplateURL* template_url, |
225 const GURL& url, | 234 const GURL& url, |
226 PageTransition::Type transition_type, | 235 PageTransition::Type transition_type, |
227 const string16& user_text, | 236 const string16& user_text, |
228 bool verbatim, | 237 bool verbatim, |
229 string16* suggested_text); | 238 string16* suggested_text); |
230 | 239 |
231 // Returns true if a preview should be shown for |match|. If |match| has | 240 // Returns a PreviewCondition indicating why we might decide not to show a |
232 // a TemplateURL that supports the instant API it is set in |template_url|. | 241 // preview for |match|. If |match| has a TemplateURL that supports the instant |
233 bool ShouldShowPreviewFor(const AutocompleteMatch& match, | 242 // API it is set in |template_url|. |
234 const TemplateURL** template_url); | 243 PreviewCondition GetPreviewConditionFor(const AutocompleteMatch& match, |
| 244 const TemplateURL** template_url); |
235 | 245 |
236 // Marks the specified search engine id as not supporting instant. | 246 // Marks the specified search engine id as not supporting instant. |
237 void BlacklistFromInstant(TemplateURLID id); | 247 void BlacklistFromInstant(TemplateURLID id); |
238 | 248 |
239 // Returns true if the specified id has been blacklisted from supporting | 249 // Returns true if the specified id has been blacklisted from supporting |
240 // instant. | 250 // instant. |
241 bool IsBlacklistedFromInstant(TemplateURLID id); | 251 bool IsBlacklistedFromInstant(TemplateURLID id); |
242 | 252 |
243 // Clears the set of search engines blacklisted. | 253 // Clears the set of search engines blacklisted. |
244 void ClearBlacklist(); | 254 void ClearBlacklist(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 ScopedVector<InstantLoader> loaders_to_destroy_; | 311 ScopedVector<InstantLoader> loaders_to_destroy_; |
302 | 312 |
303 // The set of hosts that we don't use instant with. This is shared across all | 313 // The set of hosts that we don't use instant with. This is shared across all |
304 // instances and only maintained for the current session. | 314 // instances and only maintained for the current session. |
305 static HostBlacklist* host_blacklist_; | 315 static HostBlacklist* host_blacklist_; |
306 | 316 |
307 DISALLOW_COPY_AND_ASSIGN(InstantController); | 317 DISALLOW_COPY_AND_ASSIGN(InstantController); |
308 }; | 318 }; |
309 | 319 |
310 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 320 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |