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_LOADER_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
6 #define CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/timer.h" | 12 #include "base/timer.h" |
13 #include "chrome/browser/instant/instant_commit_type.h" | 13 #include "chrome/browser/instant/instant_commit_type.h" |
14 #include "chrome/browser/search_engines/template_url_id.h" | 14 #include "chrome/browser/search_engines/template_url_id.h" |
15 #include "chrome/common/instant_types.h" | 15 #include "chrome/common/instant_types.h" |
16 #include "content/common/notification_observer.h" | 16 #include "content/common/notification_observer.h" |
17 #include "content/common/notification_registrar.h" | 17 #include "content/common/notification_registrar.h" |
18 #include "content/common/page_transition_types.h" | 18 #include "content/public/common/page_transition_types.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
21 | 21 |
22 class InstantLoaderDelegate; | 22 class InstantLoaderDelegate; |
23 class InstantLoaderManagerTest; | 23 class InstantLoaderManagerTest; |
24 class TabContents; | 24 class TabContents; |
25 class TabContentsWrapper; | 25 class TabContentsWrapper; |
26 class TemplateURL; | 26 class TemplateURL; |
27 | 27 |
28 // InstantLoader does the loading of a particular URL for InstantController. | 28 // InstantLoader does the loading of a particular URL for InstantController. |
(...skipping 14 matching lines...) Expand all Loading... |
43 | 43 |
44 InstantLoader(InstantLoaderDelegate* delegate, TemplateURLID id); | 44 InstantLoader(InstantLoaderDelegate* delegate, TemplateURLID id); |
45 virtual ~InstantLoader(); | 45 virtual ~InstantLoader(); |
46 | 46 |
47 // Invoked to load a URL. |tab_contents| is the TabContents the preview is | 47 // Invoked to load a URL. |tab_contents| is the TabContents the preview is |
48 // going to be shown on top of and potentially replace. Returns true if the | 48 // going to be shown on top of and potentially replace. Returns true if the |
49 // arguments differ from the last call to |Update|. | 49 // arguments differ from the last call to |Update|. |
50 bool Update(TabContentsWrapper* tab_contents, | 50 bool Update(TabContentsWrapper* tab_contents, |
51 const TemplateURL* template_url, | 51 const TemplateURL* template_url, |
52 const GURL& url, | 52 const GURL& url, |
53 PageTransition::Type transition_type, | 53 content::PageTransition transition_type, |
54 const string16& user_text, | 54 const string16& user_text, |
55 bool verbatim, | 55 bool verbatim, |
56 string16* suggested_text); | 56 string16* suggested_text); |
57 | 57 |
58 // Sets the bounds of the omnibox (in screen coordinates). The bounds are | 58 // Sets the bounds of the omnibox (in screen coordinates). The bounds are |
59 // remembered until the preview is committed or destroyed. This is only used | 59 // remembered until the preview is committed or destroyed. This is only used |
60 // when showing results for a search provider that supports instant. | 60 // when showing results for a search provider that supports instant. |
61 void SetOmniboxBounds(const gfx::Rect& bounds); | 61 void SetOmniboxBounds(const gfx::Rect& bounds); |
62 | 62 |
63 // Returns true if the mouse is down as the result of activating the preview | 63 // Returns true if the mouse is down as the result of activating the preview |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // Called to set up the |preview_contents_| based on |tab_contents| when it is | 173 // Called to set up the |preview_contents_| based on |tab_contents| when it is |
174 // created or replaced. | 174 // created or replaced. |
175 void SetupPreviewContents(TabContentsWrapper* tab_contents); | 175 void SetupPreviewContents(TabContentsWrapper* tab_contents); |
176 | 176 |
177 // Creates and sets the preview TabContentsWrapper. | 177 // Creates and sets the preview TabContentsWrapper. |
178 void CreatePreviewContents(TabContentsWrapper* tab_contents); | 178 void CreatePreviewContents(TabContentsWrapper* tab_contents); |
179 | 179 |
180 // Creates and loads the |template_url|'s instant URL. | 180 // Creates and loads the |template_url|'s instant URL. |
181 void LoadInstantURL(TabContentsWrapper* tab_contents, | 181 void LoadInstantURL(TabContentsWrapper* tab_contents, |
182 const TemplateURL* template_url, | 182 const TemplateURL* template_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 | 186 |
187 InstantLoaderDelegate* delegate_; | 187 InstantLoaderDelegate* delegate_; |
188 | 188 |
189 // If we're showing instant results this is the ID of the TemplateURL driving | 189 // If we're showing instant results this is the ID of the TemplateURL driving |
190 // the results. A value of 0 means there is no TemplateURL. | 190 // the results. A value of 0 means there is no TemplateURL. |
191 const TemplateURLID template_url_id_; | 191 const TemplateURLID template_url_id_; |
192 | 192 |
193 // The url we're displaying. | 193 // The url we're displaying. |
(...skipping 23 matching lines...) Expand all Loading... |
217 | 217 |
218 // See description above setter. | 218 // See description above setter. |
219 gfx::Rect omnibox_bounds_; | 219 gfx::Rect omnibox_bounds_; |
220 | 220 |
221 // Last bounds passed to the page. | 221 // Last bounds passed to the page. |
222 gfx::Rect last_omnibox_bounds_; | 222 gfx::Rect last_omnibox_bounds_; |
223 | 223 |
224 scoped_ptr<FrameLoadObserver> frame_load_observer_; | 224 scoped_ptr<FrameLoadObserver> frame_load_observer_; |
225 | 225 |
226 // Transition type of the match last passed to Update. | 226 // Transition type of the match last passed to Update. |
227 PageTransition::Type last_transition_type_; | 227 content::PageTransition last_transition_type_; |
228 | 228 |
229 // Timer used to update the bounds of the omnibox. | 229 // Timer used to update the bounds of the omnibox. |
230 base::OneShotTimer<InstantLoader> update_bounds_timer_; | 230 base::OneShotTimer<InstantLoader> update_bounds_timer_; |
231 | 231 |
232 // Used to get notifications about renderers coming and going. | 232 // Used to get notifications about renderers coming and going. |
233 NotificationRegistrar registrar_; | 233 NotificationRegistrar registrar_; |
234 | 234 |
235 // Last value of verbatim passed to |Update|. | 235 // Last value of verbatim passed to |Update|. |
236 bool verbatim_; | 236 bool verbatim_; |
237 | 237 |
238 // True if the page needs to be reloaded. | 238 // True if the page needs to be reloaded. |
239 bool needs_reload_; | 239 bool needs_reload_; |
240 | 240 |
241 DISALLOW_COPY_AND_ASSIGN(InstantLoader); | 241 DISALLOW_COPY_AND_ASSIGN(InstantLoader); |
242 }; | 242 }; |
243 | 243 |
244 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 244 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
OLD | NEW |