Remove ...LOADED_DEPRECATED and its friends
Use ExtensionRegistryObserver instead of NOTIFICATION_EXTENSION_LOADED_DEPRECATED
from ExtensionTestNotificationObserver.
Also, Remove ExtensionTestNotificationObserver::WaitForExtensionLoad()
since it has a possibility to catch unexpected extension's loaded
notification. Instead of that, use TestExtensionRegistryObserver.
BUG=411568
TEST=browser_tests
Review-Url: https://codereview.chromium.org/2753513006
Cr-Commit-Position: refs/heads/master@{#464703}
diff --git a/extensions/test/extension_test_notification_observer.h b/extensions/test/extension_test_notification_observer.h
index 418d567a..fe2aa8e 100644
--- a/extensions/test/extension_test_notification_observer.h
+++ b/extensions/test/extension_test_notification_observer.h
@@ -14,6 +14,7 @@
#include "base/scoped_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/process_manager_observer.h"
namespace content {
@@ -23,10 +24,12 @@
}
namespace extensions {
+class ExtensionRegistry;
class ProcessManager;
// Test helper class for observing extension-related events.
-class ExtensionTestNotificationObserver : public content::NotificationObserver {
+class ExtensionTestNotificationObserver : public content::NotificationObserver,
+ ExtensionRegistryObserver {
public:
explicit ExtensionTestNotificationObserver(content::BrowserContext* context);
~ExtensionTestNotificationObserver() override;
@@ -35,9 +38,6 @@
// error was raised.
bool WaitForExtensionInstallError();
- // Waits until an extension is loaded.
- void WaitForExtensionLoad();
-
// Waits for an extension load error. Returns true if the error really
// happened.
bool WaitForExtensionLoadError();
@@ -67,11 +67,16 @@
last_loaded_extension_id_ = last_loaded_extension_id;
}
- // content::NotificationObserver
+ // content::NotificationObserver:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
+ // ExtensionRegistryObserver:
+ void OnExtensionLoaded(content::BrowserContext* browser_context,
+ const Extension* extension) override;
+ void OnShutdown(ExtensionRegistry* registry) override;
+
protected:
class NotificationSet : public content::NotificationObserver,
public extensions::ProcessManagerObserver {
@@ -136,6 +141,10 @@
// The closure to quit the currently-running message loop.
base::Closure quit_closure_;
+ // Listens to extension loaded notifications.
+ ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+ registry_observer_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionTestNotificationObserver);
};