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

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: feedback 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>
11 10
12 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/scoped_observer.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "chrome/browser/autocomplete/autocomplete_match.h" 14 #include "chrome/browser/autocomplete/autocomplete_match.h"
15 #include "chrome/browser/extensions/chrome_extension_function.h" 15 #include "chrome/browser/extensions/chrome_extension_function.h"
16 #include "chrome/browser/extensions/extension_icon_manager.h" 16 #include "chrome/browser/extensions/extension_icon_manager.h"
17 #include "chrome/browser/search_engines/template_url_service.h" 17 #include "chrome/browser/search_engines/template_url_service.h"
18 #include "chrome/common/extensions/api/omnibox.h" 18 #include "chrome/common/extensions/api/omnibox.h"
19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h"
21 #include "extensions/browser/browser_context_keyed_api_factory.h" 19 #include "extensions/browser/browser_context_keyed_api_factory.h"
20 #include "extensions/browser/extension_registry_observer.h"
22 #include "ui/base/window_open_disposition.h" 21 #include "ui/base/window_open_disposition.h"
23 22
24 class Profile; 23 class Profile;
25 class TemplateURL; 24 class TemplateURL;
26 class TemplateURLService; 25 class TemplateURLService;
27 26
28 namespace base { 27 namespace base {
29 class ListValue; 28 class ListValue;
30 } 29 }
31 30
32 namespace content { 31 namespace content {
33 class BrowserContext; 32 class BrowserContext;
34 class WebContents; 33 class WebContents;
35 } 34 }
36 35
37 namespace gfx { 36 namespace gfx {
38 class Image; 37 class Image;
39 } 38 }
40 39
41 namespace extensions { 40 namespace extensions {
41 class ExtensionRegistry;
42 42
43 // Event router class for events related to the omnibox API. 43 // Event router class for events related to the omnibox API.
44 class ExtensionOmniboxEventRouter { 44 class ExtensionOmniboxEventRouter {
45 public: 45 public:
46 // The user has just typed the omnibox keyword. This is sent exactly once in 46 // The user has just typed the omnibox keyword. This is sent exactly once in
47 // a given input session, before any OnInputChanged events. 47 // a given input session, before any OnInputChanged events.
48 static void OnInputStarted( 48 static void OnInputStarted(
49 Profile* profile, const std::string& extension_id); 49 Profile* profile, const std::string& extension_id);
50 50
51 // The user has changed what is typed into the omnibox while in an extension 51 // 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) 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 RunImpl() OVERRIDE; 83 virtual bool RunImpl() OVERRIDE;
84 }; 84 };
85 85
86 class OmniboxAPI : public BrowserContextKeyedAPI, 86 class OmniboxAPI : public BrowserContextKeyedAPI,
87 public content::NotificationObserver { 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 // content::NotificationObserver implementation.
99 virtual void Observe(int type,
100 const content::NotificationSource& source,
101 const content::NotificationDetails& details) OVERRIDE;
102
103 // KeyedService implementation. 98 // KeyedService implementation.
104 virtual void Shutdown() OVERRIDE; 99 virtual void Shutdown() OVERRIDE;
105 100
106 // 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.
107 gfx::Image GetOmniboxIcon(const std::string& extension_id); 102 gfx::Image GetOmniboxIcon(const std::string& extension_id);
108 103
109 // 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
110 // extension. 105 // extension.
111 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id); 106 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id);
112 107
113 private: 108 private:
114 friend class BrowserContextKeyedAPIFactory<OmniboxAPI>; 109 friend class BrowserContextKeyedAPIFactory<OmniboxAPI>;
115 110
116 typedef std::set<const Extension*> PendingExtensions; 111 typedef std::set<const Extension*> PendingExtensions;
117 112
118 void OnTemplateURLsLoaded(); 113 void OnTemplateURLsLoaded();
119 114
115 // ExtensionRegistryObserver implementation.
116 virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
117 const Extension* extension) OVERRIDE;
118 virtual void OnExtensionUnloaded(
119 content::BrowserContext* browser_context,
120 const Extension* extension,
121 UnloadedExtensionInfo::Reason reason) OVERRIDE;
122
120 // BrowserContextKeyedAPI implementation. 123 // BrowserContextKeyedAPI implementation.
121 static const char* service_name() { 124 static const char* service_name() {
122 return "OmniboxAPI"; 125 return "OmniboxAPI";
123 } 126 }
124 static const bool kServiceRedirectedInIncognito = true; 127 static const bool kServiceRedirectedInIncognito = true;
125 128
126 Profile* profile_; 129 Profile* profile_;
127 130
128 TemplateURLService* url_service_; 131 TemplateURLService* url_service_;
129 132
130 // List of extensions waiting for the TemplateURLService to Load to 133 // List of extensions waiting for the TemplateURLService to Load to
131 // have keywords registered. 134 // have keywords registered.
132 PendingExtensions pending_extensions_; 135 PendingExtensions pending_extensions_;
133 136
134 content::NotificationRegistrar registrar_; 137 // Listen to extension load, unloaded notifications.
138 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
139 extension_registry_observer_;
135 140
136 // Keeps track of favicon-sized omnibox icons for extensions. 141 // Keeps track of favicon-sized omnibox icons for extensions.
137 ExtensionIconManager omnibox_icon_manager_; 142 ExtensionIconManager omnibox_icon_manager_;
138 ExtensionIconManager omnibox_popup_icon_manager_; 143 ExtensionIconManager omnibox_popup_icon_manager_;
139 144
140 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; 145 scoped_ptr<TemplateURLService::Subscription> template_url_sub_;
141 146
142 DISALLOW_COPY_AND_ASSIGN(OmniboxAPI); 147 DISALLOW_COPY_AND_ASSIGN(OmniboxAPI);
143 }; 148 };
144 149
(...skipping 21 matching lines...) Expand all
166 AutocompleteMatch* match); 171 AutocompleteMatch* match);
167 172
168 // This function converts style information populated by the JSON schema 173 // This function converts style information populated by the JSON schema
169 // // compiler into an ACMatchClassifications object. 174 // // compiler into an ACMatchClassifications object.
170 ACMatchClassifications StyleTypesToACMatchClassifications( 175 ACMatchClassifications StyleTypesToACMatchClassifications(
171 const api::omnibox::SuggestResult &suggestion); 176 const api::omnibox::SuggestResult &suggestion);
172 177
173 } // namespace extensions 178 } // namespace extensions
174 179
175 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ 180 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/downloads/downloads_api.cc ('k') | chrome/browser/extensions/api/omnibox/omnibox_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698