| 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. |
| 51 static const std::string kSearchTermsKey; |
| 52 |
| 50 // |use_local_preview_only| will force the use of kLocalOmniboxPopupURL as the | 53 // |use_local_preview_only| will force the use of kLocalOmniboxPopupURL as the |
| 51 // instant URL and is only applicable if |extended_enabled| is true. | 54 // instant URL and is only applicable if |extended_enabled| is true. |
| 52 InstantController(chrome::BrowserInstantController* browser, | 55 InstantController(chrome::BrowserInstantController* browser, |
| 53 bool extended_enabled, | 56 bool extended_enabled, |
| 54 bool use_local_preview_only); | 57 bool use_local_preview_only); |
| 55 ~InstantController(); | 58 ~InstantController(); |
| 56 | 59 |
| 60 const string16& last_omnibox_text() const { return last_omnibox_text_; } |
| 61 |
| 57 // Invoked as the user types into the omnibox. |user_text| is what the user | 62 // 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 | 63 // 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 | 64 // 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, | 65 // |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 | 66 // 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). | 67 // 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. | 68 // |is_keyword_search| is true if keyword searching is in effect. |
| 64 bool Update(const AutocompleteMatch& match, | 69 bool Update(const AutocompleteMatch& match, |
| 65 const string16& user_text, | 70 const string16& user_text, |
| 66 const string16& full_text, | 71 const string16& full_text, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 86 // negative for moving up, positive for moving down. Returns true if Instant | 91 // negative for moving up, positive for moving down. Returns true if Instant |
| 87 // handled the key press. | 92 // handled the key press. |
| 88 bool OnUpOrDownKeyPressed(int count); | 93 bool OnUpOrDownKeyPressed(int count); |
| 89 | 94 |
| 90 // The preview WebContents. May be NULL. InstantController retains ownership. | 95 // The preview WebContents. May be NULL. InstantController retains ownership. |
| 91 content::WebContents* GetPreviewContents() const; | 96 content::WebContents* GetPreviewContents() const; |
| 92 | 97 |
| 93 // Returns true if the Instant preview is showing a search results preview. | 98 // Returns true if the Instant preview is showing a search results preview. |
| 94 bool IsPreviewingSearchResults() const; | 99 bool IsPreviewingSearchResults() const; |
| 95 | 100 |
| 101 // Returns true if an instant extended search is currently being done. |
| 102 bool IsInstantExtendedSearch() const; |
| 103 |
| 96 // If the preview is showing search results, commits the preview, calling | 104 // If the preview is showing search results, commits the preview, calling |
| 97 // CommitInstant() on the browser, and returns true. Else, returns false. | 105 // CommitInstant() on the browser, and returns true. Else, returns false. |
| 98 bool CommitIfPossible(InstantCommitType type); | 106 bool CommitIfPossible(InstantCommitType type); |
| 99 | 107 |
| 100 // Called to indicate that the omnibox focus state changed with the given | 108 // 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 | 109 // |reason|. If |focus_state| is FOCUS_NONE, |view_gaining_focus| is set to |
| 102 // the view gaining focus. | 110 // the view gaining focus. |
| 103 void OmniboxFocusChanged(OmniboxFocusState focus_state, | 111 void OmniboxFocusChanged(OmniboxFocusState focus_state, |
| 104 OmniboxFocusChangeReason reason, | 112 OmniboxFocusChangeReason reason, |
| 105 gfx::NativeView view_gaining_focus); | 113 gfx::NativeView view_gaining_focus); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 329 |
| 322 // Whether to allow the preview to show search suggestions. In general, the | 330 // Whether to allow the preview to show search suggestions. In general, the |
| 323 // preview is allowed to show search suggestions whenever |search_mode_| is | 331 // preview is allowed to show search suggestions whenever |search_mode_| is |
| 324 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. | 332 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. |
| 325 bool allow_preview_to_show_search_suggestions_; | 333 bool allow_preview_to_show_search_suggestions_; |
| 326 | 334 |
| 327 DISALLOW_COPY_AND_ASSIGN(InstantController); | 335 DISALLOW_COPY_AND_ASSIGN(InstantController); |
| 328 }; | 336 }; |
| 329 | 337 |
| 330 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 338 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| OLD | NEW |