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

Unified Diff: chrome/browser/extensions/api/omnibox/omnibox_api.cc

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/omnibox/omnibox_api.cc
diff --git a/chrome/browser/extensions/api/omnibox/omnibox_api.cc b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
index 5d23e5f8c220266cc44c8449a48f1e924e48d31b..12682e27cbd6a4893aaac2731e25aeb7b494daff 100644
--- a/chrome/browser/extensions/api/omnibox/omnibox_api.cc
+++ b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
@@ -176,13 +176,9 @@ void ExtensionOmniboxEventRouter::OnInputCancelled(
OmniboxAPI::OmniboxAPI(content::BrowserContext* context)
: profile_(Profile::FromBrowserContext(context)),
- url_service_(TemplateURLServiceFactory::GetForProfile(profile_)) {
- registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
- content::Source<Profile>(profile_));
- registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
- content::Source<Profile>(profile_));
+ url_service_(TemplateURLServiceFactory::GetForProfile(profile_)),
+ scoped_extension_registry_observer_(this) {
+ scoped_extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
if (url_service_) {
template_url_sub_ = url_service_->RegisterOnLoadedCallback(
base::Bind(&OmniboxAPI::OnTemplateURLsLoaded,
@@ -216,42 +212,34 @@ OmniboxAPI* OmniboxAPI::Get(content::BrowserContext* context) {
return BrowserContextKeyedAPIFactory<OmniboxAPI>::Get(context);
}
-void OmniboxAPI::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (type == chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED) {
- const Extension* extension =
- content::Details<const Extension>(details).ptr();
- const std::string& keyword = OmniboxInfo::GetKeyword(extension);
- if (!keyword.empty()) {
- // Load the omnibox icon so it will be ready to display in the URL bar.
- omnibox_popup_icon_manager_.LoadIcon(profile_, extension);
- omnibox_icon_manager_.LoadIcon(profile_, extension);
-
- if (url_service_) {
- url_service_->Load();
- if (url_service_->loaded()) {
- url_service_->RegisterOmniboxKeyword(extension->id(),
- extension->name(),
- keyword);
- } else {
- pending_extensions_.insert(extension);
- }
+void OmniboxAPI::OnExtensionLoaded(content::BrowserContext* browser_context,
+ const Extension* extension) {
+ const std::string& keyword = OmniboxInfo::GetKeyword(extension);
+ if (!keyword.empty()) {
+ // Load the omnibox icon so it will be ready to display in the URL bar.
+ omnibox_popup_icon_manager_.LoadIcon(profile_, extension);
+ omnibox_icon_manager_.LoadIcon(profile_, extension);
+
+ if (url_service_) {
+ url_service_->Load();
+ if (url_service_->loaded()) {
+ url_service_->RegisterOmniboxKeyword(
+ extension->id(), extension->name(), keyword);
+ } else {
+ pending_extensions_.insert(extension);
}
}
- } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) {
- const Extension* extension =
- content::Details<UnloadedExtensionInfo>(details)->extension;
- if (!OmniboxInfo::GetKeyword(extension).empty()) {
- if (url_service_) {
- if (url_service_->loaded())
- url_service_->UnregisterOmniboxKeyword(extension->id());
- else
- pending_extensions_.erase(extension);
- }
- }
- } else {
- NOTREACHED();
+ }
+}
+
+void OmniboxAPI::OnExtensionUnloaded(content::BrowserContext* browser_context,
+ const Extension* extension,
+ UnloadedExtensionInfo::Reason reason) {
+ if (!OmniboxInfo::GetKeyword(extension).empty() && url_service_) {
+ if (url_service_->loaded())
+ url_service_->UnregisterOmniboxKeyword(extension->id());
+ else
+ pending_extensions_.erase(extension);
}
}

Powered by Google App Engine
This is Rietveld 408576698