| 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 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 class OmniboxSendSuggestionsFunction : public ChromeSyncExtensionFunction { | 75 class OmniboxSendSuggestionsFunction : public ChromeSyncExtensionFunction { |
| 76 public: | 76 public: |
| 77 DECLARE_EXTENSION_FUNCTION("omnibox.sendSuggestions", OMNIBOX_SENDSUGGESTIONS) | 77 DECLARE_EXTENSION_FUNCTION("omnibox.sendSuggestions", OMNIBOX_SENDSUGGESTIONS) |
| 78 | 78 |
| 79 protected: | 79 protected: |
| 80 virtual ~OmniboxSendSuggestionsFunction() {} | 80 virtual ~OmniboxSendSuggestionsFunction() {} |
| 81 | 81 |
| 82 // ExtensionFunction: | 82 // ExtensionFunction: |
| 83 virtual bool RunSync() OVERRIDE; | 83 virtual bool RunSync() override; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 class OmniboxAPI : public BrowserContextKeyedAPI, | 86 class OmniboxAPI : public BrowserContextKeyedAPI, |
| 87 public ExtensionRegistryObserver { | 87 public ExtensionRegistryObserver { |
| 88 public: | 88 public: |
| 89 explicit OmniboxAPI(content::BrowserContext* context); | 89 explicit OmniboxAPI(content::BrowserContext* context); |
| 90 virtual ~OmniboxAPI(); | 90 virtual ~OmniboxAPI(); |
| 91 | 91 |
| 92 // BrowserContextKeyedAPI implementation. | 92 // BrowserContextKeyedAPI implementation. |
| 93 static BrowserContextKeyedAPIFactory<OmniboxAPI>* GetFactoryInstance(); | 93 static BrowserContextKeyedAPIFactory<OmniboxAPI>* GetFactoryInstance(); |
| 94 | 94 |
| 95 // Convenience method to get the OmniboxAPI for a profile. | 95 // Convenience method to get the OmniboxAPI for a profile. |
| 96 static OmniboxAPI* Get(content::BrowserContext* context); | 96 static OmniboxAPI* Get(content::BrowserContext* context); |
| 97 | 97 |
| 98 // KeyedService implementation. | 98 // KeyedService implementation. |
| 99 virtual void Shutdown() OVERRIDE; | 99 virtual void Shutdown() override; |
| 100 | 100 |
| 101 // Returns the icon to display in the omnibox for the given extension. | 101 // Returns the icon to display in the omnibox for the given extension. |
| 102 gfx::Image GetOmniboxIcon(const std::string& extension_id); | 102 gfx::Image GetOmniboxIcon(const std::string& extension_id); |
| 103 | 103 |
| 104 // Returns the icon to display in the omnibox popup window for the given | 104 // Returns the icon to display in the omnibox popup window for the given |
| 105 // extension. | 105 // extension. |
| 106 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id); | 106 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id); |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 friend class BrowserContextKeyedAPIFactory<OmniboxAPI>; | 109 friend class BrowserContextKeyedAPIFactory<OmniboxAPI>; |
| 110 | 110 |
| 111 typedef std::set<const Extension*> PendingExtensions; | 111 typedef std::set<const Extension*> PendingExtensions; |
| 112 | 112 |
| 113 void OnTemplateURLsLoaded(); | 113 void OnTemplateURLsLoaded(); |
| 114 | 114 |
| 115 // ExtensionRegistryObserver implementation. | 115 // ExtensionRegistryObserver implementation. |
| 116 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 116 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 117 const Extension* extension) OVERRIDE; | 117 const Extension* extension) override; |
| 118 virtual void OnExtensionUnloaded( | 118 virtual void OnExtensionUnloaded( |
| 119 content::BrowserContext* browser_context, | 119 content::BrowserContext* browser_context, |
| 120 const Extension* extension, | 120 const Extension* extension, |
| 121 UnloadedExtensionInfo::Reason reason) OVERRIDE; | 121 UnloadedExtensionInfo::Reason reason) override; |
| 122 | 122 |
| 123 // BrowserContextKeyedAPI implementation. | 123 // BrowserContextKeyedAPI implementation. |
| 124 static const char* service_name() { | 124 static const char* service_name() { |
| 125 return "OmniboxAPI"; | 125 return "OmniboxAPI"; |
| 126 } | 126 } |
| 127 static const bool kServiceRedirectedInIncognito = true; | 127 static const bool kServiceRedirectedInIncognito = true; |
| 128 | 128 |
| 129 Profile* profile_; | 129 Profile* profile_; |
| 130 | 130 |
| 131 TemplateURLService* url_service_; | 131 TemplateURLService* url_service_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 152 | 152 |
| 153 class OmniboxSetDefaultSuggestionFunction : public ChromeSyncExtensionFunction { | 153 class OmniboxSetDefaultSuggestionFunction : public ChromeSyncExtensionFunction { |
| 154 public: | 154 public: |
| 155 DECLARE_EXTENSION_FUNCTION("omnibox.setDefaultSuggestion", | 155 DECLARE_EXTENSION_FUNCTION("omnibox.setDefaultSuggestion", |
| 156 OMNIBOX_SETDEFAULTSUGGESTION) | 156 OMNIBOX_SETDEFAULTSUGGESTION) |
| 157 | 157 |
| 158 protected: | 158 protected: |
| 159 virtual ~OmniboxSetDefaultSuggestionFunction() {} | 159 virtual ~OmniboxSetDefaultSuggestionFunction() {} |
| 160 | 160 |
| 161 // ExtensionFunction: | 161 // ExtensionFunction: |
| 162 virtual bool RunSync() OVERRIDE; | 162 virtual bool RunSync() override; |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 // If the extension has set a custom default suggestion via | 165 // If the extension has set a custom default suggestion via |
| 166 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing. | 166 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing. |
| 167 void ApplyDefaultSuggestionForExtensionKeyword( | 167 void ApplyDefaultSuggestionForExtensionKeyword( |
| 168 Profile* profile, | 168 Profile* profile, |
| 169 const TemplateURL* keyword, | 169 const TemplateURL* keyword, |
| 170 const base::string16& remaining_input, | 170 const base::string16& remaining_input, |
| 171 AutocompleteMatch* match); | 171 AutocompleteMatch* match); |
| 172 | 172 |
| 173 // This function converts style information populated by the JSON schema | 173 // This function converts style information populated by the JSON schema |
| 174 // // compiler into an ACMatchClassifications object. | 174 // // compiler into an ACMatchClassifications object. |
| 175 ACMatchClassifications StyleTypesToACMatchClassifications( | 175 ACMatchClassifications StyleTypesToACMatchClassifications( |
| 176 const api::omnibox::SuggestResult &suggestion); | 176 const api::omnibox::SuggestResult &suggestion); |
| 177 | 177 |
| 178 } // namespace extensions | 178 } // namespace extensions |
| 179 | 179 |
| 180 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ | 180 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ |
| OLD | NEW |