Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / extension_warning_service.cc
index 2acda5f..ab929a2 100644 (file)
@@ -4,27 +4,24 @@
 
 #include "chrome/browser/extensions/extension_warning_service.h"
 
-#include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/profiles/profile_manager.h"
 #include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_service.h"
+#include "extensions/browser/extension_registry.h"
 #include "extensions/browser/extension_system.h"
-#include "extensions/common/extension.h"
 
 using content::BrowserThread;
 
 namespace extensions {
 
 ExtensionWarningService::ExtensionWarningService(Profile* profile)
-    : profile_(profile) {
+    : profile_(profile), extension_registry_observer_(this) {
   DCHECK(CalledOnValidThread());
   if (profile_) {
-    registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
-        content::Source<Profile>(profile_->GetOriginalProfile()));
+    extension_registry_observer_.Add(
+        ExtensionRegistry::Get(profile_->GetOriginalProfile()));
   }
 }
 
@@ -93,7 +90,7 @@ void ExtensionWarningService::AddWarnings(
 void ExtensionWarningService::NotifyWarningsOnUI(
     void* profile_id,
     const ExtensionWarningSet& warnings) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   Profile* profile = reinterpret_cast<Profile*>(profile_id);
   if (!profile ||
       !g_browser_process->profile_manager() ||
@@ -119,26 +116,15 @@ void ExtensionWarningService::NotifyWarningsChanged() {
   FOR_EACH_OBSERVER(Observer, observer_list_, ExtensionWarningsChanged());
 }
 
-void ExtensionWarningService::Observe(
-    int type,
-    const content::NotificationSource& source,
-    const content::NotificationDetails& details) {
-  switch (type) {
-    case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
-      const Extension* extension =
-          content::Details<extensions::UnloadedExtensionInfo>(details)->
-          extension;
-      // Unloading one extension might have solved the problems of others.
-      // Therefore, we clear warnings of this type for all extensions.
-      std::set<ExtensionWarning::WarningType> warning_types =
-          GetWarningTypesAffectingExtension(extension->id());
-      ClearWarnings(warning_types);
-      break;
-    }
-    default:
-      NOTREACHED();
-      break;
-  }
+void ExtensionWarningService::OnExtensionUnloaded(
+    content::BrowserContext* browser_context,
+    const Extension* extension,
+    UnloadedExtensionInfo::Reason reason) {
+  // Unloading one extension might have solved the problems of others.
+  // Therefore, we clear warnings of this type for all extensions.
+  std::set<ExtensionWarning::WarningType> warning_types =
+      GetWarningTypesAffectingExtension(extension->id());
+  ClearWarnings(warning_types);
 }
 
 }  // namespace extensions