Chromium Code Reviews| 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_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 // WebUIMessageHandler implementation. | 44 // WebUIMessageHandler implementation. |
| 45 // Register our handler to get callbacks from javascript for | 45 // Register our handler to get callbacks from javascript for |
| 46 // startOmniboxQuery(). | 46 // startOmniboxQuery(). |
| 47 virtual void RegisterMessages() OVERRIDE; | 47 virtual void RegisterMessages() OVERRIDE; |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 // Gets called from the javascript when a user enters text into the | 50 // Gets called from the javascript when a user enters text into the |
| 51 // chrome://omnibox/ text box and clicks submit or hits enter. | 51 // chrome://omnibox/ text box and clicks submit or hits enter. |
| 52 // |three_element_input_string| is expected to be a three-element list: | 52 // |input| is expected to be a four-element list: |
| 53 // - first element: input string. | 53 // - first element: input string. |
| 54 // - second element: boolean indicating whether we should set | 54 // - second element: the cursor position. |
| 55 // - third element: boolean indicating whether we should set | |
| 55 // prevent_inline_autocomplete or not. | 56 // prevent_inline_autocomplete or not. |
| 56 // - third element: the cursor position. | 57 // - forth element: boolean indicating whether we should set prefer_keyword |
|
Evan Stade
2013/02/04 22:10:48
forth->fourth
Mark P
2013/02/04 22:12:50
Done.
| |
| 57 void StartOmniboxQuery(const base::ListValue* two_element_input_string); | 58 void StartOmniboxQuery(const base::ListValue* input); |
| 58 | 59 |
| 59 // Helper function for OnResultChanged(). | 60 // Helper function for OnResultChanged(). |
| 60 // Takes an iterator over AutocompleteMatches and packages them into | 61 // Takes an iterator over AutocompleteMatches and packages them into |
| 61 // the DictionaryValue output, all stored under the given prefix. | 62 // the DictionaryValue output, all stored under the given prefix. |
| 62 void AddResultToDictionary(const std::string& prefix, | 63 void AddResultToDictionary(const std::string& prefix, |
| 63 ACMatches::const_iterator result_it, | 64 ACMatches::const_iterator result_it, |
| 64 ACMatches::const_iterator end, | 65 ACMatches::const_iterator end, |
| 65 base::DictionaryValue* output); | 66 base::DictionaryValue* output); |
| 66 | 67 |
| 67 // Re-initializes the AutocompleteController in preparation for the | 68 // Re-initializes the AutocompleteController in preparation for the |
| 68 // next query. | 69 // next query. |
| 69 void ResetController(); | 70 void ResetController(); |
| 70 | 71 |
| 71 // The omnibox AutocompleteController that collects/sorts/dup- | 72 // The omnibox AutocompleteController that collects/sorts/dup- |
| 72 // eliminates the results as they come in. | 73 // eliminates the results as they come in. |
| 73 scoped_ptr<AutocompleteController> controller_; | 74 scoped_ptr<AutocompleteController> controller_; |
| 74 | 75 |
| 75 // Time the user's input was sent to the omnibox to start searching. | 76 // Time the user's input was sent to the omnibox to start searching. |
| 76 // Needed because we also pass timing information in the object we | 77 // Needed because we also pass timing information in the object we |
| 77 // hand back to the javascript. | 78 // hand back to the javascript. |
| 78 base::Time time_omnibox_started_; | 79 base::Time time_omnibox_started_; |
| 79 | 80 |
| 80 // The Profile* handed to us in our constructor. | 81 // The Profile* handed to us in our constructor. |
| 81 Profile* profile_; | 82 Profile* profile_; |
| 82 | 83 |
| 83 DISALLOW_COPY_AND_ASSIGN(OmniboxUIHandler); | 84 DISALLOW_COPY_AND_ASSIGN(OmniboxUIHandler); |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 #endif // CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ | 87 #endif // CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ |
| OLD | NEW |