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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "base/task.h" | 16 #include "base/task.h" |
17 #include "chrome/browser/instant/instant_commit_type.h" | 17 #include "chrome/browser/instant/instant_commit_type.h" |
18 #include "chrome/browser/instant/instant_loader_delegate.h" | 18 #include "chrome/browser/instant/instant_loader_delegate.h" |
19 #include "chrome/browser/search_engines/template_url_id.h" | 19 #include "chrome/browser/search_engines/template_url_id.h" |
20 #include "chrome/common/instant_types.h" | 20 #include "chrome/common/instant_types.h" |
21 #include "content/common/page_transition_types.h" | 21 #include "content/public/common/page_transition_types.h" |
22 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
23 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
24 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
25 | 25 |
26 struct AutocompleteMatch; | 26 struct AutocompleteMatch; |
27 class InstantDelegate; | 27 class InstantDelegate; |
28 class InstantLoader; | 28 class InstantLoader; |
29 class InstantTest; | 29 class InstantTest; |
30 class PrefService; | 30 class PrefService; |
31 class Profile; | 31 class Profile; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 // Returns true if |Update| has been invoked without a corresponding call to | 144 // Returns true if |Update| has been invoked without a corresponding call to |
145 // |DestroyPreviewContents| or |CommitCurrentPreview|. | 145 // |DestroyPreviewContents| or |CommitCurrentPreview|. |
146 bool is_active() const { return is_active_; } | 146 bool is_active() const { return is_active_; } |
147 | 147 |
148 // Returns true if the preview TabContents is ready to be displayed. In some | 148 // Returns true if the preview TabContents is ready to be displayed. In some |
149 // situations this may return false yet GetPreviewContents() returns non-NULL. | 149 // situations this may return false yet GetPreviewContents() returns non-NULL. |
150 bool is_displayable() const { return is_displayable_; } | 150 bool is_displayable() const { return is_displayable_; } |
151 | 151 |
152 // Returns the transition type of the last AutocompleteMatch passed to Update. | 152 // Returns the transition type of the last AutocompleteMatch passed to Update. |
153 PageTransition::Type last_transition_type() const { | 153 content::PageTransition last_transition_type() const { |
154 return last_transition_type_; | 154 return last_transition_type_; |
155 } | 155 } |
156 | 156 |
157 // InstantLoaderDelegate | 157 // InstantLoaderDelegate |
158 virtual void InstantStatusChanged(InstantLoader* loader) OVERRIDE; | 158 virtual void InstantStatusChanged(InstantLoader* loader) OVERRIDE; |
159 virtual void SetSuggestedTextFor(InstantLoader* loader, | 159 virtual void SetSuggestedTextFor(InstantLoader* loader, |
160 const string16& text, | 160 const string16& text, |
161 InstantCompleteBehavior behavior) OVERRIDE; | 161 InstantCompleteBehavior behavior) OVERRIDE; |
162 virtual gfx::Rect GetInstantBounds() OVERRIDE; | 162 virtual gfx::Rect GetInstantBounds() OVERRIDE; |
163 virtual bool ShouldCommitInstantOnMouseUp() OVERRIDE; | 163 virtual bool ShouldCommitInstantOnMouseUp() OVERRIDE; |
164 virtual void CommitInstantLoader(InstantLoader* loader) OVERRIDE; | 164 virtual void CommitInstantLoader(InstantLoader* loader) OVERRIDE; |
165 virtual void InstantLoaderDoesntSupportInstant( | 165 virtual void InstantLoaderDoesntSupportInstant( |
166 InstantLoader* loader) OVERRIDE; | 166 InstantLoader* loader) OVERRIDE; |
167 virtual void AddToBlacklist(InstantLoader* loader, | 167 virtual void AddToBlacklist(InstantLoader* loader, |
168 const GURL& url) OVERRIDE; | 168 const GURL& url) OVERRIDE; |
169 virtual void SwappedTabContents(InstantLoader* loader) OVERRIDE; | 169 virtual void SwappedTabContents(InstantLoader* loader) OVERRIDE; |
170 | 170 |
171 private: | 171 private: |
172 friend class InstantTest; | 172 friend class InstantTest; |
173 | 173 |
174 typedef std::set<std::string> HostBlacklist; | 174 typedef std::set<std::string> HostBlacklist; |
175 | 175 |
176 // Updates |is_displayable_| and if necessary notifies the delegate. | 176 // Updates |is_displayable_| and if necessary notifies the delegate. |
177 void UpdateIsDisplayable(); | 177 void UpdateIsDisplayable(); |
178 | 178 |
179 // Updates InstantLoaderManager and its current InstantLoader. This is invoked | 179 // Updates InstantLoaderManager and its current InstantLoader. This is invoked |
180 // internally from Update. | 180 // internally from Update. |
181 void UpdateLoader(const TemplateURL* template_url, | 181 void UpdateLoader(const TemplateURL* template_url, |
182 const GURL& url, | 182 const GURL& url, |
183 PageTransition::Type transition_type, | 183 content::PageTransition transition_type, |
184 const string16& user_text, | 184 const string16& user_text, |
185 bool verbatim, | 185 bool verbatim, |
186 string16* suggested_text); | 186 string16* suggested_text); |
187 | 187 |
188 // Returns true if instant should be used for the specified match. Instant is | 188 // Returns true if instant should be used for the specified match. Instant is |
189 // only used if |match| corresponds to the default search provider. | 189 // only used if |match| corresponds to the default search provider. |
190 bool ShouldUseInstant(const AutocompleteMatch& match); | 190 bool ShouldUseInstant(const AutocompleteMatch& match); |
191 | 191 |
192 // Returns true if |template_url| is a valid TemplateURL for use by instant. | 192 // Returns true if |template_url| is a valid TemplateURL for use by instant. |
193 bool IsValidInstantTemplateURL(const TemplateURL* template_url); | 193 bool IsValidInstantTemplateURL(const TemplateURL* template_url); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // True if |loader_| is ready to be displayed. | 225 // True if |loader_| is ready to be displayed. |
226 bool is_displayable_; | 226 bool is_displayable_; |
227 | 227 |
228 // See description above setter. | 228 // See description above setter. |
229 gfx::Rect omnibox_bounds_; | 229 gfx::Rect omnibox_bounds_; |
230 | 230 |
231 // See description above CommitOnMouseUp. | 231 // See description above CommitOnMouseUp. |
232 bool commit_on_mouse_up_; | 232 bool commit_on_mouse_up_; |
233 | 233 |
234 // See description above getter. | 234 // See description above getter. |
235 PageTransition::Type last_transition_type_; | 235 content::PageTransition last_transition_type_; |
236 | 236 |
237 // The IDs of any search engines that don't support instant. We assume all | 237 // The IDs of any search engines that don't support instant. We assume all |
238 // search engines support instant, but if we determine an engine doesn't | 238 // search engines support instant, but if we determine an engine doesn't |
239 // support instant it is added to this list. The list is cleared out on every | 239 // support instant it is added to this list. The list is cleared out on every |
240 // reset/commit. | 240 // reset/commit. |
241 std::set<TemplateURLID> blacklisted_ids_; | 241 std::set<TemplateURLID> blacklisted_ids_; |
242 | 242 |
243 // Used by ScheduleForDestroy; see it for details. | 243 // Used by ScheduleForDestroy; see it for details. |
244 ScopedRunnableMethodFactory<InstantController> destroy_factory_; | 244 ScopedRunnableMethodFactory<InstantController> destroy_factory_; |
245 | 245 |
246 // List of InstantLoaders to destroy. See ScheduleForDestroy for details. | 246 // List of InstantLoaders to destroy. See ScheduleForDestroy for details. |
247 ScopedVector<InstantLoader> loaders_to_destroy_; | 247 ScopedVector<InstantLoader> loaders_to_destroy_; |
248 | 248 |
249 DISALLOW_COPY_AND_ASSIGN(InstantController); | 249 DISALLOW_COPY_AND_ASSIGN(InstantController); |
250 }; | 250 }; |
251 | 251 |
252 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 252 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |