Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: chrome/browser/extensions/api/omnibox/omnibox_api.h

Issue 244473002: Remove NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED from c/b/e/api (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/scoped_observer.h"
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/chrome_extension_function.h" 16 #include "chrome/browser/extensions/chrome_extension_function.h"
16 #include "chrome/browser/extensions/extension_icon_manager.h" 17 #include "chrome/browser/extensions/extension_icon_manager.h"
17 #include "chrome/browser/search_engines/template_url_service.h" 18 #include "chrome/browser/search_engines/template_url_service.h"
18 #include "chrome/common/extensions/api/omnibox.h" 19 #include "chrome/common/extensions/api/omnibox.h"
19 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
21 #include "extensions/browser/browser_context_keyed_api_factory.h" 22 #include "extensions/browser/browser_context_keyed_api_factory.h"
23 #include "extensions/browser/extension_registry_observer.h"
22 #include "ui/base/window_open_disposition.h" 24 #include "ui/base/window_open_disposition.h"
23 25
24 class Profile; 26 class Profile;
25 class TemplateURL; 27 class TemplateURL;
26 class TemplateURLService; 28 class TemplateURLService;
27 29
28 namespace base { 30 namespace base {
29 class ListValue; 31 class ListValue;
30 } 32 }
31 33
32 namespace content { 34 namespace content {
33 class BrowserContext; 35 class BrowserContext;
34 class WebContents; 36 class WebContents;
35 } 37 }
36 38
37 namespace gfx { 39 namespace gfx {
38 class Image; 40 class Image;
39 } 41 }
40 42
41 namespace extensions { 43 namespace extensions {
44 class ExtensionRegistry;
42 45
43 // Event router class for events related to the omnibox API. 46 // Event router class for events related to the omnibox API.
44 class ExtensionOmniboxEventRouter { 47 class ExtensionOmniboxEventRouter {
45 public: 48 public:
46 // The user has just typed the omnibox keyword. This is sent exactly once in 49 // The user has just typed the omnibox keyword. This is sent exactly once in
47 // a given input session, before any OnInputChanged events. 50 // a given input session, before any OnInputChanged events.
48 static void OnInputStarted( 51 static void OnInputStarted(
49 Profile* profile, const std::string& extension_id); 52 Profile* profile, const std::string& extension_id);
50 53
51 // The user has changed what is typed into the omnibox while in an extension 54 // The user has changed what is typed into the omnibox while in an extension
(...skipping 25 matching lines...) Expand all
77 DECLARE_EXTENSION_FUNCTION("omnibox.sendSuggestions", OMNIBOX_SENDSUGGESTIONS) 80 DECLARE_EXTENSION_FUNCTION("omnibox.sendSuggestions", OMNIBOX_SENDSUGGESTIONS)
78 81
79 protected: 82 protected:
80 virtual ~OmniboxSendSuggestionsFunction() {} 83 virtual ~OmniboxSendSuggestionsFunction() {}
81 84
82 // ExtensionFunction: 85 // ExtensionFunction:
83 virtual bool RunImpl() OVERRIDE; 86 virtual bool RunImpl() OVERRIDE;
84 }; 87 };
85 88
86 class OmniboxAPI : public BrowserContextKeyedAPI, 89 class OmniboxAPI : public BrowserContextKeyedAPI,
87 public content::NotificationObserver { 90 public ExtensionRegistryObserver {
88 public: 91 public:
89 explicit OmniboxAPI(content::BrowserContext* context); 92 explicit OmniboxAPI(content::BrowserContext* context);
90 virtual ~OmniboxAPI(); 93 virtual ~OmniboxAPI();
91 94
92 // BrowserContextKeyedAPI implementation. 95 // BrowserContextKeyedAPI implementation.
93 static BrowserContextKeyedAPIFactory<OmniboxAPI>* GetFactoryInstance(); 96 static BrowserContextKeyedAPIFactory<OmniboxAPI>* GetFactoryInstance();
94 97
95 // Convenience method to get the OmniboxAPI for a profile. 98 // Convenience method to get the OmniboxAPI for a profile.
96 static OmniboxAPI* Get(content::BrowserContext* context); 99 static OmniboxAPI* Get(content::BrowserContext* context);
97 100
98 // content::NotificationObserver implementation.
99 virtual void Observe(int type,
100 const content::NotificationSource& source,
101 const content::NotificationDetails& details) OVERRIDE;
102
103 // KeyedService implementation. 101 // KeyedService implementation.
104 virtual void Shutdown() OVERRIDE; 102 virtual void Shutdown() OVERRIDE;
105 103
106 // Returns the icon to display in the omnibox for the given extension. 104 // Returns the icon to display in the omnibox for the given extension.
107 gfx::Image GetOmniboxIcon(const std::string& extension_id); 105 gfx::Image GetOmniboxIcon(const std::string& extension_id);
108 106
109 // Returns the icon to display in the omnibox popup window for the given 107 // Returns the icon to display in the omnibox popup window for the given
110 // extension. 108 // extension.
111 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id); 109 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id);
112 110
113 private: 111 private:
114 friend class BrowserContextKeyedAPIFactory<OmniboxAPI>; 112 friend class BrowserContextKeyedAPIFactory<OmniboxAPI>;
115 113
116 typedef std::set<const Extension*> PendingExtensions; 114 typedef std::set<const Extension*> PendingExtensions;
117 115
118 void OnTemplateURLsLoaded(); 116 void OnTemplateURLsLoaded();
119 117
118 // ExtensionRegistryObserver implementation.
119 virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
120 const Extension* extension) OVERRIDE;
121 virtual void OnExtensionUnloaded(
122 content::BrowserContext* browser_context,
123 const Extension* extension,
124 UnloadedExtensionInfo::Reason reason) OVERRIDE;
125
120 // BrowserContextKeyedAPI implementation. 126 // BrowserContextKeyedAPI implementation.
121 static const char* service_name() { 127 static const char* service_name() {
122 return "OmniboxAPI"; 128 return "OmniboxAPI";
123 } 129 }
124 static const bool kServiceRedirectedInIncognito = true; 130 static const bool kServiceRedirectedInIncognito = true;
125 131
126 Profile* profile_; 132 Profile* profile_;
127 133
128 TemplateURLService* url_service_; 134 TemplateURLService* url_service_;
129 135
130 // List of extensions waiting for the TemplateURLService to Load to 136 // List of extensions waiting for the TemplateURLService to Load to
131 // have keywords registered. 137 // have keywords registered.
132 PendingExtensions pending_extensions_; 138 PendingExtensions pending_extensions_;
133 139
134 content::NotificationRegistrar registrar_; 140 // Listen to extension load, unloaded notifications.
141 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
142 scoped_extension_registry_observer_;
135 143
136 // Keeps track of favicon-sized omnibox icons for extensions. 144 // Keeps track of favicon-sized omnibox icons for extensions.
137 ExtensionIconManager omnibox_icon_manager_; 145 ExtensionIconManager omnibox_icon_manager_;
138 ExtensionIconManager omnibox_popup_icon_manager_; 146 ExtensionIconManager omnibox_popup_icon_manager_;
139 147
140 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; 148 scoped_ptr<TemplateURLService::Subscription> template_url_sub_;
141 149
142 DISALLOW_COPY_AND_ASSIGN(OmniboxAPI); 150 DISALLOW_COPY_AND_ASSIGN(OmniboxAPI);
143 }; 151 };
144 152
(...skipping 21 matching lines...) Expand all
166 AutocompleteMatch* match); 174 AutocompleteMatch* match);
167 175
168 // This function converts style information populated by the JSON schema 176 // This function converts style information populated by the JSON schema
169 // // compiler into an ACMatchClassifications object. 177 // // compiler into an ACMatchClassifications object.
170 ACMatchClassifications StyleTypesToACMatchClassifications( 178 ACMatchClassifications StyleTypesToACMatchClassifications(
171 const api::omnibox::SuggestResult &suggestion); 179 const api::omnibox::SuggestResult &suggestion);
172 180
173 } // namespace extensions 181 } // namespace extensions
174 182
175 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ 183 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698