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/memory/weak_ptr.h" | |
|
Avi (use Gerrit)
2013/10/02 22:27:52
not used; don't include
Cait (Slow)
2013/10/03 15:36:45
Done.
| |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 15 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 16 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 16 #include "chrome/browser/extensions/extension_function.h" | 17 #include "chrome/browser/extensions/extension_function.h" |
| 17 #include "chrome/browser/extensions/extension_icon_manager.h" | 18 #include "chrome/browser/extensions/extension_icon_manager.h" |
| 19 #include "chrome/browser/search_engines/template_url_service.h" | |
| 18 #include "chrome/common/extensions/api/omnibox.h" | 20 #include "chrome/common/extensions/api/omnibox.h" |
| 19 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 21 #include "ui/base/window_open_disposition.h" | 23 #include "ui/base/window_open_disposition.h" |
| 22 | 24 |
| 23 class Profile; | 25 class Profile; |
| 24 class TemplateURL; | 26 class TemplateURL; |
| 25 class TemplateURLService; | 27 class TemplateURLService; |
| 26 | 28 |
| 27 namespace base { | 29 namespace base { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 static ProfileKeyedAPIFactory<OmniboxAPI>* GetFactoryInstance(); | 93 static ProfileKeyedAPIFactory<OmniboxAPI>* GetFactoryInstance(); |
| 92 | 94 |
| 93 // Convenience method to get the OmniboxAPI for a profile. | 95 // Convenience method to get the OmniboxAPI for a profile. |
| 94 static OmniboxAPI* Get(Profile* profile); | 96 static OmniboxAPI* Get(Profile* profile); |
| 95 | 97 |
| 96 // content::NotificationObserver implementation. | 98 // content::NotificationObserver implementation. |
| 97 virtual void Observe(int type, | 99 virtual void Observe(int type, |
| 98 const content::NotificationSource& source, | 100 const content::NotificationSource& source, |
| 99 const content::NotificationDetails& details) OVERRIDE; | 101 const content::NotificationDetails& details) OVERRIDE; |
| 100 | 102 |
| 103 // BrowserContextKeyedService implementation. | |
| 104 virtual void Shutdown() OVERRIDE; | |
| 105 | |
| 101 // Returns the icon to display in the omnibox for the given extension. | 106 // Returns the icon to display in the omnibox for the given extension. |
| 102 gfx::Image GetOmniboxIcon(const std::string& extension_id); | 107 gfx::Image GetOmniboxIcon(const std::string& extension_id); |
| 103 | 108 |
| 104 // Returns the icon to display in the omnibox popup window for the given | 109 // Returns the icon to display in the omnibox popup window for the given |
| 105 // extension. | 110 // extension. |
| 106 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id); | 111 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id); |
| 107 | 112 |
| 108 private: | 113 private: |
| 109 friend class ProfileKeyedAPIFactory<OmniboxAPI>; | 114 friend class ProfileKeyedAPIFactory<OmniboxAPI>; |
| 110 | 115 |
| 111 typedef std::set<const Extension*> PendingExtensions; | 116 typedef std::set<const Extension*> PendingExtensions; |
| 112 | 117 |
| 118 void OnTemplateURLsLoaded(); | |
| 119 | |
| 113 // ProfileKeyedAPI implementation. | 120 // ProfileKeyedAPI implementation. |
| 114 static const char* service_name() { | 121 static const char* service_name() { |
| 115 return "OmniboxAPI"; | 122 return "OmniboxAPI"; |
| 116 } | 123 } |
| 117 static const bool kServiceRedirectedInIncognito = true; | 124 static const bool kServiceRedirectedInIncognito = true; |
| 118 | 125 |
| 119 Profile* profile_; | 126 Profile* profile_; |
| 120 | 127 |
| 121 TemplateURLService* url_service_; | 128 TemplateURLService* url_service_; |
| 122 | 129 |
| 123 // List of extensions waiting for the TemplateURLService to Load to | 130 // List of extensions waiting for the TemplateURLService to Load to |
| 124 // have keywords registered. | 131 // have keywords registered. |
| 125 PendingExtensions pending_extensions_; | 132 PendingExtensions pending_extensions_; |
| 126 | 133 |
| 127 content::NotificationRegistrar registrar_; | 134 content::NotificationRegistrar registrar_; |
| 128 | 135 |
| 129 // Keeps track of favicon-sized omnibox icons for extensions. | 136 // Keeps track of favicon-sized omnibox icons for extensions. |
| 130 ExtensionIconManager omnibox_icon_manager_; | 137 ExtensionIconManager omnibox_icon_manager_; |
| 131 ExtensionIconManager omnibox_popup_icon_manager_; | 138 ExtensionIconManager omnibox_popup_icon_manager_; |
| 132 | 139 |
| 140 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; | |
| 141 | |
| 133 DISALLOW_COPY_AND_ASSIGN(OmniboxAPI); | 142 DISALLOW_COPY_AND_ASSIGN(OmniboxAPI); |
| 134 }; | 143 }; |
| 135 | 144 |
| 136 template <> | 145 template <> |
| 137 void ProfileKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies(); | 146 void ProfileKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies(); |
| 138 | 147 |
| 139 class OmniboxSetDefaultSuggestionFunction : public SyncExtensionFunction { | 148 class OmniboxSetDefaultSuggestionFunction : public SyncExtensionFunction { |
| 140 public: | 149 public: |
| 141 DECLARE_EXTENSION_FUNCTION("omnibox.setDefaultSuggestion", | 150 DECLARE_EXTENSION_FUNCTION("omnibox.setDefaultSuggestion", |
| 142 OMNIBOX_SETDEFAULTSUGGESTION) | 151 OMNIBOX_SETDEFAULTSUGGESTION) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 157 AutocompleteMatch* match); | 166 AutocompleteMatch* match); |
| 158 | 167 |
| 159 // This function converts style information populated by the JSON schema | 168 // This function converts style information populated by the JSON schema |
| 160 // // compiler into an ACMatchClassifications object. | 169 // // compiler into an ACMatchClassifications object. |
| 161 ACMatchClassifications StyleTypesToACMatchClassifications( | 170 ACMatchClassifications StyleTypesToACMatchClassifications( |
| 162 const api::omnibox::SuggestResult &suggestion); | 171 const api::omnibox::SuggestResult &suggestion); |
| 163 | 172 |
| 164 } // namespace extensions | 173 } // namespace extensions |
| 165 | 174 |
| 166 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ | 175 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ |
| OLD | NEW |