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

Unified Diff: chrome/browser/extensions/api/spellcheck/spellcheck_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/spellcheck/spellcheck_api.cc
diff --git a/chrome/browser/extensions/api/spellcheck/spellcheck_api.cc b/chrome/browser/extensions/api/spellcheck/spellcheck_api.cc
index a249b4a26603091e5a5135dda531125b01220044..e5077495a77bde3b1fd84310e47eb0b0da35cbd7 100644
--- a/chrome/browser/extensions/api/spellcheck/spellcheck_api.cc
+++ b/chrome/browser/extensions/api/spellcheck/spellcheck_api.cc
@@ -12,6 +12,7 @@
#include "chrome/common/extensions/api/spellcheck/spellcheck_handler.h"
#include "content/public/browser/notification_details.h"
limasdf 2014/04/24 17:46:48 I think i can kill this includes. will upload soon
#include "content/public/browser/notification_source.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/common/manifest_constants.h"
namespace extensions {
@@ -40,13 +41,10 @@ SpellcheckService::DictionaryFormat GetDictionaryFormat(std::string format) {
} // namespace
-SpellcheckAPI::SpellcheckAPI(content::BrowserContext* context) {
- Profile* profile = Profile::FromBrowserContext(context);
- registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
- content::Source<Profile>(profile));
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
- content::Source<Profile>(profile));
+SpellcheckAPI::SpellcheckAPI(content::BrowserContext* context)
+ : extension_registry_observer_(this) {
+ extension_registry_observer_.Add(
+ ExtensionRegistry::Get(Profile::FromBrowserContext(context)));
}
SpellcheckAPI::~SpellcheckAPI() {
@@ -61,41 +59,32 @@ SpellcheckAPI::GetFactoryInstance() {
return g_factory.Pointer();
}
-void SpellcheckAPI::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- Profile* profile = content::Source<Profile>(source).ptr();
- SpellcheckService* spellcheck = NULL;
- switch (type) {
- case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
- const Extension* extension = content::Details<Extension>(details).ptr();
- SpellcheckDictionaryInfo* spellcheck_info =
- GetSpellcheckDictionaryInfo(extension);
- if (spellcheck_info) {
- // TODO(rlp): Handle load failure. =
- spellcheck = SpellcheckServiceFactory::GetForContext(profile);
- spellcheck->LoadExternalDictionary(
- spellcheck_info->language,
- spellcheck_info->locale,
- spellcheck_info->path,
- GetDictionaryFormat(spellcheck_info->format));
- }
- break;
- }
- case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
- const Extension* extension =
- content::Details<UnloadedExtensionInfo>(details)->extension;
- SpellcheckDictionaryInfo* spellcheck_info =
- GetSpellcheckDictionaryInfo(extension);
- if (spellcheck_info) {
- // TODO(rlp): Handle unload failure.
- spellcheck = SpellcheckServiceFactory::GetForContext(profile);
- spellcheck->UnloadExternalDictionary(spellcheck_info->path);
- }
- break;
- }
- default:
- NOTREACHED();
+void SpellcheckAPI::OnExtensionLoaded(content::BrowserContext* browser_context,
+ const Extension* extension) {
+ SpellcheckDictionaryInfo* spellcheck_info =
+ GetSpellcheckDictionaryInfo(extension);
+ if (spellcheck_info) {
+ // TODO(rlp): Handle load failure. =
+ SpellcheckService* spellcheck =
+ SpellcheckServiceFactory::GetForContext(browser_context);
+ spellcheck->LoadExternalDictionary(
+ spellcheck_info->language,
+ spellcheck_info->locale,
+ spellcheck_info->path,
+ GetDictionaryFormat(spellcheck_info->format));
+ }
+}
+void SpellcheckAPI::OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ UnloadedExtensionInfo::Reason reason) {
+ SpellcheckDictionaryInfo* spellcheck_info =
+ GetSpellcheckDictionaryInfo(extension);
+ if (spellcheck_info) {
+ // TODO(rlp): Handle unload failure.
+ SpellcheckService* spellcheck =
+ SpellcheckServiceFactory::GetForContext(browser_context);
+ spellcheck->UnloadExternalDictionary(spellcheck_info->path);
}
}

Powered by Google App Engine
This is Rietveld 408576698