| 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_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 14 #include "chrome/browser/extensions/extension_function.h" | 14 #include "chrome/browser/extensions/extension_function.h" |
| 15 | 15 |
| 16 class TabContents; | |
| 17 class TemplateURL; | 16 class TemplateURL; |
| 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class ListValue; | 19 class ListValue; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace content { |
| 23 class WebContents; |
| 24 } |
| 25 |
| 22 namespace extensions { | 26 namespace extensions { |
| 23 | 27 |
| 24 // Event router class for events related to the omnibox API. | 28 // Event router class for events related to the omnibox API. |
| 25 class ExtensionOmniboxEventRouter { | 29 class ExtensionOmniboxEventRouter { |
| 26 public: | 30 public: |
| 27 // The user has just typed the omnibox keyword. This is sent exactly once in | 31 // The user has just typed the omnibox keyword. This is sent exactly once in |
| 28 // a given input session, before any OnInputChanged events. | 32 // a given input session, before any OnInputChanged events. |
| 29 static void OnInputStarted( | 33 static void OnInputStarted( |
| 30 Profile* profile, const std::string& extension_id); | 34 Profile* profile, const std::string& extension_id); |
| 31 | 35 |
| 32 // The user has changed what is typed into the omnibox while in an extension | 36 // The user has changed what is typed into the omnibox while in an extension |
| 33 // keyword session. Returns true if someone is listening to this event, and | 37 // keyword session. Returns true if someone is listening to this event, and |
| 34 // thus we have some degree of confidence we'll get a response. | 38 // thus we have some degree of confidence we'll get a response. |
| 35 static bool OnInputChanged( | 39 static bool OnInputChanged( |
| 36 Profile* profile, | 40 Profile* profile, |
| 37 const std::string& extension_id, | 41 const std::string& extension_id, |
| 38 const std::string& input, int suggest_id); | 42 const std::string& input, int suggest_id); |
| 39 | 43 |
| 40 // The user has accepted the omnibox input. | 44 // The user has accepted the omnibox input. |
| 41 static void OnInputEntered( | 45 static void OnInputEntered( |
| 42 TabContents* tab_contents, | 46 content::WebContents* web_contents, |
| 43 const std::string& extension_id, | 47 const std::string& extension_id, |
| 44 const std::string& input); | 48 const std::string& input); |
| 45 | 49 |
| 46 // The user has cleared the keyword, or closed the omnibox popup. This is | 50 // The user has cleared the keyword, or closed the omnibox popup. This is |
| 47 // sent at most once in a give input session, after any OnInputChanged events. | 51 // sent at most once in a give input session, after any OnInputChanged events. |
| 48 static void OnInputCancelled( | 52 static void OnInputCancelled( |
| 49 Profile* profile, const std::string& extension_id); | 53 Profile* profile, const std::string& extension_id); |
| 50 | 54 |
| 51 private: | 55 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(ExtensionOmniboxEventRouter); | 56 DISALLOW_COPY_AND_ASSIGN(ExtensionOmniboxEventRouter); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing. | 120 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing. |
| 117 void ApplyDefaultSuggestionForExtensionKeyword( | 121 void ApplyDefaultSuggestionForExtensionKeyword( |
| 118 Profile* profile, | 122 Profile* profile, |
| 119 const TemplateURL* keyword, | 123 const TemplateURL* keyword, |
| 120 const string16& remaining_input, | 124 const string16& remaining_input, |
| 121 AutocompleteMatch* match); | 125 AutocompleteMatch* match); |
| 122 | 126 |
| 123 } // namespace extensions | 127 } // namespace extensions |
| 124 | 128 |
| 125 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ | 129 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ |
| OLD | NEW |