OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_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 <string> | 9 #include <string> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 static const char* const kInstantHeader; | 47 static const char* const kInstantHeader; |
48 static const char* const kInstantHeaderValue; | 48 static const char* const kInstantHeaderValue; |
49 | 49 |
50 // |group| is an identifier suffixed to histograms to distinguish field trial | 50 // |group| is an identifier suffixed to histograms to distinguish field trial |
51 // statistics from regular operation; can be a blank string. | 51 // statistics from regular operation; can be a blank string. |
52 InstantLoader(InstantLoaderDelegate* delegate, | 52 InstantLoader(InstantLoaderDelegate* delegate, |
53 TemplateURLID id, | 53 TemplateURLID id, |
54 const std::string& group); | 54 const std::string& group); |
55 virtual ~InstantLoader(); | 55 virtual ~InstantLoader(); |
56 | 56 |
57 // Invoked to load a URL. |tab_contents| is the TabContents the preview is | 57 // Invoked to load a URL. |tab_contents| is the TabContentsWrapper the preview |
58 // going to be shown on top of and potentially replace. Returns true if the | 58 // is going to be shown on top of and potentially replace. Returns true if the |
59 // arguments differ from the last call to |Update|. | 59 // arguments differ from the last call to |Update|. |
60 bool Update(TabContentsWrapper* tab_contents, | 60 bool Update(TabContentsWrapper* tab_contents, |
61 const TemplateURL* template_url, | 61 const TemplateURL* template_url, |
62 const GURL& url, | 62 const GURL& url, |
63 content::PageTransition transition_type, | 63 content::PageTransition transition_type, |
64 const string16& user_text, | 64 const string16& user_text, |
65 bool verbatim, | 65 bool verbatim, |
66 string16* suggested_text); | 66 string16* suggested_text); |
67 | 67 |
68 // Sets the bounds of the omnibox (in screen coordinates). The bounds are | 68 // Sets the bounds of the omnibox (in screen coordinates). The bounds are |
69 // remembered until the preview is committed or destroyed. This is only used | 69 // remembered until the preview is committed or destroyed. This is only used |
70 // when showing results for a search provider that supports instant. | 70 // when showing results for a search provider that supports instant. |
71 void SetOmniboxBounds(const gfx::Rect& bounds); | 71 void SetOmniboxBounds(const gfx::Rect& bounds); |
72 | 72 |
73 // Returns true if the mouse is down as the result of activating the preview | 73 // Returns true if the mouse is down as the result of activating the preview |
74 // content. | 74 // content. |
75 bool IsMouseDownFromActivate(); | 75 bool IsMouseDownFromActivate(); |
76 | 76 |
77 // Releases the preview TabContents passing ownership to the caller. This is | 77 // Releases the preview TabContentsWrapper passing ownership to the caller. |
78 // intended to be called when the preview TabContents is committed. This does | 78 // This is intended to be called when the preview TabContentsWrapper is |
79 // not notify the delegate. |tab_contents| is the underlying tab onto which | 79 // committed. This does not notify the delegate. |tab_contents| is the |
80 // the preview will be committed. It can be NULL when the underlying tab is | 80 // underlying tab onto which the preview will be committed. It can be NULL |
81 // irrelevant, for example when |type| is INSTANT_COMMIT_DESTROY. | 81 // when the underlying tab is irrelevant, for example when |type| is |
| 82 // INSTANT_COMMIT_DESTROY. |
82 TabContentsWrapper* ReleasePreviewContents(InstantCommitType type, | 83 TabContentsWrapper* ReleasePreviewContents(InstantCommitType type, |
83 TabContentsWrapper* tab_contents); | 84 TabContentsWrapper* tab_contents); |
84 | 85 |
85 // Calls through to method of same name on delegate. | 86 // Calls through to method of same name on delegate. |
86 bool ShouldCommitInstantOnMouseUp(); | 87 bool ShouldCommitInstantOnMouseUp(); |
87 void CommitInstantLoader(); | 88 void CommitInstantLoader(); |
88 | 89 |
89 // Preload |template_url|'s instant URL, if the loader doesn't already have | 90 // Preload |template_url|'s instant URL, if the loader doesn't already have |
90 // a |preview_contents()| for it. | 91 // a |preview_contents()| for it. |
91 void MaybeLoadInstantURL(TabContentsWrapper* tab_contents, | 92 void MaybeLoadInstantURL(TabContentsWrapper* tab_contents, |
92 const TemplateURL* template_url); | 93 const TemplateURL* template_url); |
93 | 94 |
94 // Returns true if the preview NavigationController's TabContents has a | 95 // Returns true if the preview NavigationController's WebContents has a |
95 // pending NavigationEntry. | 96 // pending NavigationEntry. |
96 bool IsNavigationPending() const; | 97 bool IsNavigationPending() const; |
97 | 98 |
98 // content::NotificationObserver: | 99 // content::NotificationObserver: |
99 virtual void Observe(int type, | 100 virtual void Observe(int type, |
100 const content::NotificationSource& source, | 101 const content::NotificationSource& source, |
101 const content::NotificationDetails& details) OVERRIDE; | 102 const content::NotificationDetails& details) OVERRIDE; |
102 | 103 |
103 // The preview TabContents; may be null. | 104 // The preview TabContentsWrapper; may be null. |
104 TabContentsWrapper* preview_contents() const { | 105 TabContentsWrapper* preview_contents() const { |
105 return preview_contents_.get(); | 106 return preview_contents_.get(); |
106 } | 107 } |
107 | 108 |
108 // Returns true if the preview TabContents is ready to be shown. A non-instant | 109 // Returns true if the preview TabContentsWrapper is ready to be shown. A |
109 // loader is ready once the renderer paints, otherwise it isn't ready until we | 110 // non-instant loader is ready once the renderer paints, otherwise it isn't |
110 // get a response back from the page. | 111 // ready until we get a response back from the page. |
111 bool ready() const { return ready_; } | 112 bool ready() const { return ready_; } |
112 | 113 |
113 // Returns true if the current load returned a 200. | 114 // Returns true if the current load returned a 200. |
114 bool http_status_ok() const { return http_status_ok_; } | 115 bool http_status_ok() const { return http_status_ok_; } |
115 | 116 |
116 // Returns true if the url needs to be reloaded. This is set to true for | 117 // Returns true if the url needs to be reloaded. This is set to true for |
117 // downloads. | 118 // downloads. |
118 bool needs_reload() const { return needs_reload_; } | 119 bool needs_reload() const { return needs_reload_; } |
119 | 120 |
120 const GURL& url() const { return url_; } | 121 const GURL& url() const { return url_; } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 201 |
201 InstantLoaderDelegate* delegate_; | 202 InstantLoaderDelegate* delegate_; |
202 | 203 |
203 // If we're showing instant results this is the ID of the TemplateURL driving | 204 // If we're showing instant results this is the ID of the TemplateURL driving |
204 // the results. A value of 0 means there is no TemplateURL. | 205 // the results. A value of 0 means there is no TemplateURL. |
205 const TemplateURLID template_url_id_; | 206 const TemplateURLID template_url_id_; |
206 | 207 |
207 // The url we're displaying. | 208 // The url we're displaying. |
208 GURL url_; | 209 GURL url_; |
209 | 210 |
210 // Delegate of the preview TabContents. Used to detect when the user does some | 211 // Delegate of the preview WebContents. Used to detect when the user does some |
211 // gesture on the TabContents and the preview needs to be activated. | 212 // gesture on the WebContents and the preview needs to be activated. |
212 scoped_ptr<TabContentsDelegateImpl> preview_tab_contents_delegate_; | 213 scoped_ptr<TabContentsDelegateImpl> preview_tab_contents_delegate_; |
213 | 214 |
214 // The preview TabContents; may be null. | 215 // The preview TabContentsWrapper; may be null. |
215 scoped_ptr<TabContentsWrapper> preview_contents_; | 216 scoped_ptr<TabContentsWrapper> preview_contents_; |
216 | 217 |
217 // Is the preview_contents ready to be shown? | 218 // Is the preview_contents ready to be shown? |
218 bool ready_; | 219 bool ready_; |
219 | 220 |
220 // Was the last status code a 200? | 221 // Was the last status code a 200? |
221 bool http_status_ok_; | 222 bool http_status_ok_; |
222 | 223 |
223 // The text the user typed in the omnibox, stripped of the leading ?, if any. | 224 // The text the user typed in the omnibox, stripped of the leading ?, if any. |
224 string16 user_text_; | 225 string16 user_text_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 std::string group_; | 257 std::string group_; |
257 | 258 |
258 // The session storage namespace identifier of the original tab contents that | 259 // The session storage namespace identifier of the original tab contents that |
259 // the preview_contents_ was based upon. | 260 // the preview_contents_ was based upon. |
260 scoped_refptr<content::SessionStorageNamespace> session_storage_namespace_; | 261 scoped_refptr<content::SessionStorageNamespace> session_storage_namespace_; |
261 | 262 |
262 DISALLOW_COPY_AND_ASSIGN(InstantLoader); | 263 DISALLOW_COPY_AND_ASSIGN(InstantLoader); |
263 }; | 264 }; |
264 | 265 |
265 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 266 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
OLD | NEW |