OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/timer.h" | 14 #include "base/timer.h" |
15 #include "chrome/browser/instant/instant_commit_type.h" | 15 #include "chrome/browser/instant/instant_commit_type.h" |
16 #include "chrome/browser/instant/instant_loader_delegate.h" | 16 #include "chrome/browser/instant/instant_loader_delegate.h" |
17 #include "chrome/browser/search_engines/template_url_id.h" | 17 #include "chrome/browser/search_engines/template_url_id.h" |
18 #include "chrome/common/page_transition_types.h" | 18 #include "chrome/common/page_transition_types.h" |
19 #include "gfx/native_widget_types.h" | 19 #include "gfx/native_widget_types.h" |
20 #include "gfx/rect.h" | 20 #include "gfx/rect.h" |
21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
22 | 22 |
23 struct AutocompleteMatch; | 23 struct AutocompleteMatch; |
24 class InstantDelegate; | 24 class InstantDelegate; |
25 class InstantLoaderManager; | 25 class InstantLoaderManager; |
26 class PrefService; | 26 class PrefService; |
27 class Profile; | 27 class Profile; |
28 class TabContents; | 28 class TabContents; |
| 29 class TabContentsWrapper; |
29 class TemplateURL; | 30 class TemplateURL; |
30 | 31 |
31 // InstantController maintains a TabContents that is intended to give a preview | 32 // InstantController maintains a TabContents that is intended to give a preview |
32 // of a URL. InstantController is owned by Browser. | 33 // of a URL. InstantController is owned by Browser. |
33 // | 34 // |
34 // At any time the TabContents maintained by InstantController may be destroyed | 35 // At any time the TabContents maintained by InstantController may be destroyed |
35 // by way of |DestroyPreviewContents|, which results in |HideInstant| being | 36 // by way of |DestroyPreviewContents|, which results in |HideInstant| being |
36 // invoked on the delegate. Similarly the preview may be committed at any time | 37 // invoked on the delegate. Similarly the preview may be committed at any time |
37 // by invoking |CommitCurrentPreview|, which results in |CommitInstant| | 38 // by invoking |CommitCurrentPreview|, which results in |CommitInstant| |
38 // being invoked on the delegate. | 39 // being invoked on the delegate. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Enables instant. | 71 // Enables instant. |
71 static void Enable(Profile* profile); | 72 static void Enable(Profile* profile); |
72 | 73 |
73 // Disables instant. | 74 // Disables instant. |
74 static void Disable(Profile* profile); | 75 static void Disable(Profile* profile); |
75 | 76 |
76 // Invoked as the user types in the omnibox with the url to navigate to. If | 77 // Invoked as the user types in the omnibox with the url to navigate to. If |
77 // the url is empty and there is a preview TabContents it is destroyed. If url | 78 // the url is empty and there is a preview TabContents it is destroyed. If url |
78 // is non-empty and the preview TabContents has not been created it is | 79 // is non-empty and the preview TabContents has not been created it is |
79 // created. | 80 // created. |
80 void Update(TabContents* tab_contents, | 81 void Update(TabContentsWrapper* tab_contents, |
81 const AutocompleteMatch& match, | 82 const AutocompleteMatch& match, |
82 const string16& user_text, | 83 const string16& user_text, |
83 string16* suggested_text); | 84 string16* suggested_text); |
84 | 85 |
85 // Sets the bounds of the omnibox (in screen coordinates). The bounds are | 86 // Sets the bounds of the omnibox (in screen coordinates). The bounds are |
86 // remembered until the preview is committed or destroyed. This is only used | 87 // remembered until the preview is committed or destroyed. This is only used |
87 // when showing results for a search provider that supports instant. | 88 // when showing results for a search provider that supports instant. |
88 void SetOmniboxBounds(const gfx::Rect& bounds); | 89 void SetOmniboxBounds(const gfx::Rect& bounds); |
89 | 90 |
90 // Destroys the preview TabContents. Does nothing if the preview TabContents | 91 // Destroys the preview TabContents. Does nothing if the preview TabContents |
(...skipping 22 matching lines...) Expand all Loading... |
113 | 114 |
114 // The autocomplete edit that was initiating the current instant session has | 115 // The autocomplete edit that was initiating the current instant session has |
115 // lost focus. Commit or discard the preview accordingly. | 116 // lost focus. Commit or discard the preview accordingly. |
116 void OnAutocompleteLostFocus(gfx::NativeView view_gaining_focus); | 117 void OnAutocompleteLostFocus(gfx::NativeView view_gaining_focus); |
117 | 118 |
118 // Releases the preview TabContents passing ownership to the caller. This is | 119 // Releases the preview TabContents passing ownership to the caller. This is |
119 // intended to be called when the preview TabContents is committed. This does | 120 // intended to be called when the preview TabContents is committed. This does |
120 // not notify the delegate. | 121 // not notify the delegate. |
121 // WARNING: be sure and invoke CompleteRelease after adding the returned | 122 // WARNING: be sure and invoke CompleteRelease after adding the returned |
122 // TabContents to a tabstrip. | 123 // TabContents to a tabstrip. |
123 TabContents* ReleasePreviewContents(InstantCommitType type); | 124 TabContentsWrapper* ReleasePreviewContents(InstantCommitType type); |
124 | 125 |
125 // Does cleanup after the preview contents has been added to the tabstrip. | 126 // Does cleanup after the preview contents has been added to the tabstrip. |
126 // Invoke this if you explicitly invoke ReleasePreviewContents. | 127 // Invoke this if you explicitly invoke ReleasePreviewContents. |
127 void CompleteRelease(TabContents* tab); | 128 void CompleteRelease(TabContents* tab); |
128 | 129 |
129 // TabContents the match is being shown for. | 130 // TabContents the match is being shown for. |
130 TabContents* tab_contents() const { return tab_contents_; } | 131 TabContentsWrapper* tab_contents() const { return tab_contents_; } |
131 | 132 |
132 // The preview TabContents; may be null. | 133 // The preview TabContents; may be null. |
133 TabContents* GetPreviewContents(); | 134 TabContentsWrapper* GetPreviewContents(); |
134 | 135 |
135 // Returns true if the preview TabContents is active. In some situations this | 136 // Returns true if the preview TabContents is active. In some situations this |
136 // may return false yet preview_contents() returns non-NULL. | 137 // may return false yet preview_contents() returns non-NULL. |
137 bool is_active() const { return is_active_; } | 138 bool is_active() const { return is_active_; } |
138 | 139 |
139 // Returns the transition type of the last AutocompleteMatch passed to Update. | 140 // Returns the transition type of the last AutocompleteMatch passed to Update. |
140 PageTransition::Type last_transition_type() const { | 141 PageTransition::Type last_transition_type() const { |
141 return last_transition_type_; | 142 return last_transition_type_; |
142 } | 143 } |
143 | 144 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // Clears the set of search engines blacklisted. | 187 // Clears the set of search engines blacklisted. |
187 void ClearBlacklist(); | 188 void ClearBlacklist(); |
188 | 189 |
189 // Returns the TemplateURL to use for the specified AutocompleteMatch, or NULL | 190 // Returns the TemplateURL to use for the specified AutocompleteMatch, or NULL |
190 // if non TemplateURL should be used. | 191 // if non TemplateURL should be used. |
191 const TemplateURL* GetTemplateURL(const AutocompleteMatch& match); | 192 const TemplateURL* GetTemplateURL(const AutocompleteMatch& match); |
192 | 193 |
193 InstantDelegate* delegate_; | 194 InstantDelegate* delegate_; |
194 | 195 |
195 // The TabContents last passed to |Update|. | 196 // The TabContents last passed to |Update|. |
196 TabContents* tab_contents_; | 197 TabContentsWrapper* tab_contents_; |
197 | 198 |
198 // Has notification been sent out that the preview TabContents is ready to be | 199 // Has notification been sent out that the preview TabContents is ready to be |
199 // shown? | 200 // shown? |
200 bool is_active_; | 201 bool is_active_; |
201 | 202 |
202 // See description above setter. | 203 // See description above setter. |
203 gfx::Rect omnibox_bounds_; | 204 gfx::Rect omnibox_bounds_; |
204 | 205 |
205 // See description above CommitOnMouseUp. | 206 // See description above CommitOnMouseUp. |
206 bool commit_on_mouse_up_; | 207 bool commit_on_mouse_up_; |
(...skipping 13 matching lines...) Expand all Loading... |
220 | 221 |
221 // URL last pased to ScheduleUpdate. | 222 // URL last pased to ScheduleUpdate. |
222 GURL scheduled_url_; | 223 GURL scheduled_url_; |
223 | 224 |
224 const Type type_; | 225 const Type type_; |
225 | 226 |
226 DISALLOW_COPY_AND_ASSIGN(InstantController); | 227 DISALLOW_COPY_AND_ASSIGN(InstantController); |
227 }; | 228 }; |
228 | 229 |
229 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 230 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |