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_TAB_CONTENTS_MATCH_PREVIEW_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_MATCH_PREVIEW_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_MATCH_PREVIEW_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_MATCH_PREVIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/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/search_engines/template_url_id.h" | 13 #include "chrome/browser/search_engines/template_url_id.h" |
14 #include "chrome/common/page_transition_types.h" | 14 #include "chrome/common/page_transition_types.h" |
| 15 #include "gfx/rect.h" |
15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
16 | 17 |
17 struct AutocompleteMatch; | 18 struct AutocompleteMatch; |
18 class MatchPreviewDelegate; | 19 class MatchPreviewDelegate; |
19 class TabContents; | 20 class TabContents; |
20 | 21 |
21 // MatchPreview maintains a TabContents that is intended to give a preview of | 22 // MatchPreview maintains a TabContents that is intended to give a preview of |
22 // a URL. MatchPreview is owned by Browser. | 23 // a URL. MatchPreview is owned by Browser. |
23 // | 24 // |
24 // At any time the TabContents maintained by MatchPreview may be destroyed by | 25 // At any time the TabContents maintained by MatchPreview may be destroyed by |
(...skipping 11 matching lines...) Expand all Loading... |
36 | 37 |
37 // Invoked as the user types in the omnibox with the url to navigate to. If | 38 // Invoked as the user types in the omnibox with the url to navigate to. If |
38 // the url is empty and there is a preview TabContents it is destroyed. If url | 39 // the url is empty and there is a preview TabContents it is destroyed. If url |
39 // is non-empty and the preview TabContents has not been created it is | 40 // is non-empty and the preview TabContents has not been created it is |
40 // created. | 41 // created. |
41 void Update(TabContents* tab_contents, | 42 void Update(TabContents* tab_contents, |
42 const AutocompleteMatch& match, | 43 const AutocompleteMatch& match, |
43 const string16& user_text, | 44 const string16& user_text, |
44 string16* suggested_text); | 45 string16* suggested_text); |
45 | 46 |
| 47 // Sets the bounds of the omnibox (in screen coordinates). The bounds are |
| 48 // remembered until the preview is committed or destroyed. This is only used |
| 49 // when showing results for a search provider that supports instant. |
| 50 void SetOmniboxBounds(const gfx::Rect& bounds); |
| 51 |
46 // Destroys the preview TabContents. Does nothing if the preview TabContents | 52 // Destroys the preview TabContents. Does nothing if the preview TabContents |
47 // has not been created. | 53 // has not been created. |
48 void DestroyPreviewContents(); | 54 void DestroyPreviewContents(); |
49 | 55 |
50 // Invoked when the user does some gesture that should trigger making the | 56 // Invoked when the user does some gesture that should trigger making the |
51 // current previewed page the permanent page. | 57 // current previewed page the permanent page. |
52 void CommitCurrentPreview(); | 58 void CommitCurrentPreview(); |
53 | 59 |
54 // Releases the preview TabContents passing ownership to the caller. This is | 60 // Releases the preview TabContents passing ownership to the caller. This is |
55 // intended to be called when the preview TabContents is committed. This does | 61 // intended to be called when the preview TabContents is committed. This does |
(...skipping 22 matching lines...) Expand all Loading... |
78 // which results in updating the omnibox. | 84 // which results in updating the omnibox. |
79 void SetCompleteSuggestedText(const string16& suggested_text); | 85 void SetCompleteSuggestedText(const string16& suggested_text); |
80 | 86 |
81 // Invoked when the preview paints. This notifies the delegate the preview is | 87 // Invoked when the preview paints. This notifies the delegate the preview is |
82 // ready to be shown. | 88 // ready to be shown. |
83 void PreviewDidPaint(); | 89 void PreviewDidPaint(); |
84 | 90 |
85 // Invoked once the page has finished loading and the script has been sent. | 91 // Invoked once the page has finished loading and the script has been sent. |
86 void PageFinishedLoading(); | 92 void PageFinishedLoading(); |
87 | 93 |
| 94 // Returns the bounds of the omnibox in terms of the preview tab contents. |
| 95 gfx::Rect GetOmniboxBoundsInTermsOfPreview(); |
| 96 |
| 97 // Are we waiting for the preview page to finish loading? |
| 98 bool is_waiting_for_load() const { |
| 99 return frame_load_observer_.get() != NULL; |
| 100 } |
| 101 |
| 102 // Are we showing instant results? |
| 103 bool is_showing_instant() const { return template_url_id_ != 0; } |
| 104 |
88 MatchPreviewDelegate* delegate_; | 105 MatchPreviewDelegate* delegate_; |
89 | 106 |
90 // The TabContents last passed to |Update|. | 107 // The TabContents last passed to |Update|. |
91 TabContents* tab_contents_; | 108 TabContents* tab_contents_; |
92 | 109 |
93 // The url we're displaying. | 110 // The url we're displaying. |
94 GURL url_; | 111 GURL url_; |
95 | 112 |
96 // Delegate of the preview TabContents. Used to detect when the user does some | 113 // Delegate of the preview TabContents. Used to detect when the user does some |
97 // gesture on the TabContents and the preview needs to be activated. | 114 // gesture on the TabContents and the preview needs to be activated. |
98 scoped_ptr<TabContentsDelegateImpl> preview_tab_contents_delegate_; | 115 scoped_ptr<TabContentsDelegateImpl> preview_tab_contents_delegate_; |
99 | 116 |
100 // The preview TabContents; may be null. | 117 // The preview TabContents; may be null. |
101 scoped_ptr<TabContents> preview_contents_; | 118 scoped_ptr<TabContents> preview_contents_; |
102 | 119 |
103 // Has notification been sent out that the preview TabContents is ready to be | 120 // Has notification been sent out that the preview TabContents is ready to be |
104 // shown? | 121 // shown? |
105 bool is_active_; | 122 bool is_active_; |
106 | 123 |
107 // The text the user typed in the omnibox. | 124 // The text the user typed in the omnibox. |
108 string16 user_text_; | 125 string16 user_text_; |
109 | 126 |
110 // The latest suggestion from the page. | 127 // The latest suggestion from the page. |
111 string16 complete_suggested_text_; | 128 string16 complete_suggested_text_; |
112 | 129 |
113 // If we're showing instant results this is the ID of the TemplateURL driving | 130 // If we're showing instant results this is the ID of the TemplateURL driving |
114 // the results. A value of 0 means there is no TemplateURL. | 131 // the results. A value of 0 means there is no TemplateURL. |
115 TemplateURLID template_url_id_; | 132 TemplateURLID template_url_id_; |
116 | 133 |
| 134 // See description above setter. |
| 135 gfx::Rect omnibox_bounds_; |
| 136 |
117 scoped_ptr<FrameLoadObserver> frame_load_observer_; | 137 scoped_ptr<FrameLoadObserver> frame_load_observer_; |
118 | 138 |
119 DISALLOW_COPY_AND_ASSIGN(MatchPreview); | 139 DISALLOW_COPY_AND_ASSIGN(MatchPreview); |
120 }; | 140 }; |
121 | 141 |
122 #endif // CHROME_BROWSER_TAB_CONTENTS_MATCH_PREVIEW_H_ | 142 #endif // CHROME_BROWSER_TAB_CONTENTS_MATCH_PREVIEW_H_ |
OLD | NEW |