OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_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 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 | 41 |
42 // InstantController maintains a WebContents that is intended to give a preview | 42 // InstantController maintains a WebContents that is intended to give a preview |
43 // of search suggestions and results. InstantController is owned by Browser via | 43 // of search suggestions and results. InstantController is owned by Browser via |
44 // BrowserInstantController. | 44 // BrowserInstantController. |
45 class InstantController { | 45 class InstantController { |
46 public: | 46 public: |
47 // The URL for the local omnibox popup. | 47 // The URL for the local omnibox popup. |
48 static const char* kLocalOmniboxPopupURL; | 48 static const char* kLocalOmniboxPopupURL; |
49 | 49 |
| 50 // The key used to store search terms data in the NavigationEntry to be later |
| 51 // displayed in the Omnibox. With the context of the user's exact query, |
| 52 // InstantController sets the correct search terms to be displayed. |
| 53 static const char* kInstantExtendedSearchTermsKey; |
| 54 |
50 // |use_local_preview_only| will force the use of kLocalOmniboxPopupURL as the | 55 // |use_local_preview_only| will force the use of kLocalOmniboxPopupURL as the |
51 // instant URL and is only applicable if |extended_enabled| is true. | 56 // instant URL and is only applicable if |extended_enabled| is true. |
52 InstantController(chrome::BrowserInstantController* browser, | 57 InstantController(chrome::BrowserInstantController* browser, |
53 bool extended_enabled, | 58 bool extended_enabled, |
54 bool use_local_preview_only); | 59 bool use_local_preview_only); |
55 ~InstantController(); | 60 ~InstantController(); |
56 | 61 |
| 62 const string16& last_omnibox_text() const { return last_omnibox_text_; } |
| 63 |
57 // Invoked as the user types into the omnibox. |user_text| is what the user | 64 // Invoked as the user types into the omnibox. |user_text| is what the user |
58 // has typed. |full_text| is what the omnibox is showing. These may differ if | 65 // has typed. |full_text| is what the omnibox is showing. These may differ if |
59 // the user typed only some text, and the rest was inline autocompleted. If | 66 // the user typed only some text, and the rest was inline autocompleted. If |
60 // |verbatim| is true, search results are shown for the exact omnibox text, | 67 // |verbatim| is true, search results are shown for the exact omnibox text, |
61 // rather than the best guess as to what the user means. Returns true if the | 68 // rather than the best guess as to what the user means. Returns true if the |
62 // update is accepted (i.e., if |match| is a search rather than a URL). | 69 // update is accepted (i.e., if |match| is a search rather than a URL). |
63 // |is_keyword_search| is true if keyword searching is in effect. | 70 // |is_keyword_search| is true if keyword searching is in effect. |
64 bool Update(const AutocompleteMatch& match, | 71 bool Update(const AutocompleteMatch& match, |
65 const string16& user_text, | 72 const string16& user_text, |
66 const string16& full_text, | 73 const string16& full_text, |
(...skipping 19 matching lines...) Expand all Loading... |
86 // negative for moving up, positive for moving down. Returns true if Instant | 93 // negative for moving up, positive for moving down. Returns true if Instant |
87 // handled the key press. | 94 // handled the key press. |
88 bool OnUpOrDownKeyPressed(int count); | 95 bool OnUpOrDownKeyPressed(int count); |
89 | 96 |
90 // The preview WebContents. May be NULL. InstantController retains ownership. | 97 // The preview WebContents. May be NULL. InstantController retains ownership. |
91 content::WebContents* GetPreviewContents() const; | 98 content::WebContents* GetPreviewContents() const; |
92 | 99 |
93 // Returns true if the Instant preview is showing a search results preview. | 100 // Returns true if the Instant preview is showing a search results preview. |
94 bool IsPreviewingSearchResults() const; | 101 bool IsPreviewingSearchResults() const; |
95 | 102 |
| 103 // Returns true if an instant extended search is currently being done. |
| 104 bool IsInstantExtendedSearch() const; |
| 105 |
96 // If the preview is showing search results, commits the preview, calling | 106 // If the preview is showing search results, commits the preview, calling |
97 // CommitInstant() on the browser, and returns true. Else, returns false. | 107 // CommitInstant() on the browser, and returns true. Else, returns false. |
98 bool CommitIfPossible(InstantCommitType type); | 108 bool CommitIfPossible(InstantCommitType type); |
99 | 109 |
100 // Called to indicate that the omnibox focus state changed with the given | 110 // Called to indicate that the omnibox focus state changed with the given |
101 // |reason|. If |focus_state| is FOCUS_NONE, |view_gaining_focus| is set to | 111 // |reason|. If |focus_state| is FOCUS_NONE, |view_gaining_focus| is set to |
102 // the view gaining focus. | 112 // the view gaining focus. |
103 void OmniboxFocusChanged(OmniboxFocusState focus_state, | 113 void OmniboxFocusChanged(OmniboxFocusState focus_state, |
104 OmniboxFocusChangeReason reason, | 114 OmniboxFocusChangeReason reason, |
105 gfx::NativeView view_gaining_focus); | 115 gfx::NativeView view_gaining_focus); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 331 |
322 // Whether to allow the preview to show search suggestions. In general, the | 332 // Whether to allow the preview to show search suggestions. In general, the |
323 // preview is allowed to show search suggestions whenever |search_mode_| is | 333 // preview is allowed to show search suggestions whenever |search_mode_| is |
324 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. | 334 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. |
325 bool allow_preview_to_show_search_suggestions_; | 335 bool allow_preview_to_show_search_suggestions_; |
326 | 336 |
327 DISALLOW_COPY_AND_ASSIGN(InstantController); | 337 DISALLOW_COPY_AND_ASSIGN(InstantController); |
328 }; | 338 }; |
329 | 339 |
330 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 340 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |