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_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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 14 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 16 #include "chrome/browser/extensions/extension_function.h" | 16 #include "chrome/browser/extensions/extension_function.h" |
| 17 #include "chrome/browser/extensions/extension_icon_manager.h" | 17 #include "chrome/browser/extensions/extension_icon_manager.h" |
| 18 #include "chrome/common/extensions/api/omnibox.h" | |
| 18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 20 | 21 |
| 21 class Profile; | 22 class Profile; |
| 22 class TemplateURL; | 23 class TemplateURL; |
| 23 class TemplateURLService; | 24 class TemplateURLService; |
| 24 | 25 |
| 25 namespace base { | 26 namespace base { |
| 26 class ListValue; | 27 class ListValue; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace content { | 30 namespace content { |
| 30 class WebContents; | 31 class WebContents; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace gfx { | 34 namespace gfx { |
| 34 class Image; | 35 class Image; |
| 35 } | 36 } |
| 36 | 37 |
| 37 namespace extensions { | 38 namespace extensions { |
| 38 | 39 |
| 40 namespace SetDefaultSuggestion = api::omnibox::SetDefaultSuggestion; | |
|
Devlin
2013/02/27 22:14:17
Don't set a namespace like this in the .h file (us
Aaron Jacobs
2013/02/27 23:01:58
Done.
| |
| 41 | |
| 39 // Event router class for events related to the omnibox API. | 42 // Event router class for events related to the omnibox API. |
| 40 class ExtensionOmniboxEventRouter { | 43 class ExtensionOmniboxEventRouter { |
| 41 public: | 44 public: |
| 42 // The user has just typed the omnibox keyword. This is sent exactly once in | 45 // The user has just typed the omnibox keyword. This is sent exactly once in |
| 43 // a given input session, before any OnInputChanged events. | 46 // a given input session, before any OnInputChanged events. |
| 44 static void OnInputStarted( | 47 static void OnInputStarted( |
| 45 Profile* profile, const std::string& extension_id); | 48 Profile* profile, const std::string& extension_id); |
| 46 | 49 |
| 47 // The user has changed what is typed into the omnibox while in an extension | 50 // The user has changed what is typed into the omnibox while in an extension |
| 48 // keyword session. Returns true if someone is listening to this event, and | 51 // keyword session. Returns true if someone is listening to this event, and |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 | 147 |
| 145 struct ExtensionOmniboxSuggestion { | 148 struct ExtensionOmniboxSuggestion { |
| 146 ExtensionOmniboxSuggestion(); | 149 ExtensionOmniboxSuggestion(); |
| 147 ~ExtensionOmniboxSuggestion(); | 150 ~ExtensionOmniboxSuggestion(); |
| 148 | 151 |
| 149 // Populate a suggestion value from a DictionaryValue. If |require_content| | 152 // Populate a suggestion value from a DictionaryValue. If |require_content| |
| 150 // is false, then we won't fail if |content| is missing, to support | 153 // is false, then we won't fail if |content| is missing, to support |
| 151 // default suggestions. | 154 // default suggestions. |
| 152 bool Populate(const base::DictionaryValue& value, bool require_content); | 155 bool Populate(const base::DictionaryValue& value, bool require_content); |
| 153 | 156 |
| 157 // Populate a suggestion value from Suggestion generated by JSON schema | |
| 158 // compiler (only sets the value of the description) | |
|
Devlin
2013/02/27 22:14:17
Comments should always be grammatically correct (i
Aaron Jacobs
2013/02/27 23:01:58
Done.
| |
| 159 bool PopulateFromSuggestion( | |
| 160 const SetDefaultSuggestion::Params::Suggestion& suggestion); | |
| 161 | |
| 154 // Converts a list of style ranges from the extension into the format expected | 162 // Converts a list of style ranges from the extension into the format expected |
| 155 // by the autocomplete system. | 163 // by the autocomplete system. |
| 156 bool ReadStylesFromValue(const base::ListValue& value); | 164 bool ReadStylesFromValue(const base::ListValue& value); |
| 157 | 165 |
| 158 // Converts this structure to a DictionaryValue suitable for saving to disk. | 166 // Converts this structure to a DictionaryValue suitable for saving to disk. |
| 159 scoped_ptr<base::DictionaryValue> ToValue() const; | 167 scoped_ptr<base::DictionaryValue> ToValue() const; |
| 160 | 168 |
| 161 // The text that gets put in the edit box. | 169 // The text that gets put in the edit box. |
| 162 string16 content; | 170 string16 content; |
| 163 | 171 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 184 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing. | 192 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing. |
| 185 void ApplyDefaultSuggestionForExtensionKeyword( | 193 void ApplyDefaultSuggestionForExtensionKeyword( |
| 186 Profile* profile, | 194 Profile* profile, |
| 187 const TemplateURL* keyword, | 195 const TemplateURL* keyword, |
| 188 const string16& remaining_input, | 196 const string16& remaining_input, |
| 189 AutocompleteMatch* match); | 197 AutocompleteMatch* match); |
| 190 | 198 |
| 191 } // namespace extensions | 199 } // namespace extensions |
| 192 | 200 |
| 193 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ | 201 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ |
| OLD | NEW |