Chromium Code Reviews| Index: extensions/test/extension_test_notification_observer.h |
| diff --git a/chrome/browser/extensions/extension_test_notification_observer.h b/extensions/test/extension_test_notification_observer.h |
| similarity index 61% |
| rename from chrome/browser/extensions/extension_test_notification_observer.h |
| rename to extensions/test/extension_test_notification_observer.h |
| index d4b8d866ac05eead9c300f367e7a65b290623747..eff62098ba4c571e4a960f476dbd6398f51105bf 100644 |
| --- a/chrome/browser/extensions/extension_test_notification_observer.h |
| +++ b/extensions/test/extension_test_notification_observer.h |
| @@ -1,44 +1,38 @@ |
| -// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ |
| -#define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ |
| +#ifndef EXTENSIONS_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ |
| +#define EXTENSIONS_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ |
| #include <string> |
| #include "base/callback.h" |
| +#include "base/callback_list.h" |
| #include "base/compiler_specific.h" |
| -#include "chrome/browser/chrome_notification_types.h" |
| -#include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| -#include "chrome/browser/ui/browser.h" |
| -#include "chrome/browser/ui/location_bar/location_bar.h" |
| +#include "base/scoped_observer.h" |
| #include "content/public/browser/notification_details.h" |
|
Devlin
2016/10/06 15:52:17
Not all of these are needed, either.
Rahul Chaturvedi
2016/10/11 20:12:35
Done.
|
| #include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| #include "content/public/browser/notification_types.h" |
| +#include "extensions/browser/process_manager.h" |
| +#include "extensions/browser/process_manager_observer.h" |
| namespace content { |
| +class BrowserContext; |
| class WindowedNotificationObserver; |
| } |
| // Test helper class for observing extension-related events. |
|
Devlin
2016/10/06 15:52:17
extensions:: namespace?
Rahul Chaturvedi
2016/10/11 20:12:35
This is moved code, I would like to keep the origi
|
| -class ExtensionTestNotificationObserver |
| - : public content::NotificationObserver, |
| - public extensions::ExtensionActionAPI::Observer { |
| +class ExtensionTestNotificationObserver : public content::NotificationObserver { |
| public: |
| - explicit ExtensionTestNotificationObserver(Browser* browser); |
| + explicit ExtensionTestNotificationObserver(content::BrowserContext*); |
|
Devlin
2016/10/06 15:52:17
variable name
Rahul Chaturvedi
2016/10/11 20:12:35
Done.
|
| ~ExtensionTestNotificationObserver() override; |
| - // Wait for the number of visible page actions to change to |count|. |
| - bool WaitForPageActionVisibilityChangeTo(int count); |
| - |
| // Wait for an extension install error to be raised. Returns true if an |
| // error was raised. |
| bool WaitForExtensionInstallError(); |
| - // Waits until an extension is loaded and all view have loaded. |
| - void WaitForExtensionAndViewLoad(); |
| - |
| // Waits until an extension is loaded. |
| void WaitForExtensionLoad(); |
| @@ -53,15 +47,6 @@ class ExtensionTestNotificationObserver |
| // Wait for the crx installer to be done. Returns true if it really is done. |
| bool WaitForCrxInstallerDone(); |
| - // Wait for all extension views to load. |
| - bool WaitForExtensionViewsToLoad(); |
| - |
| - // Wait for extension to be idle. |
| - bool WaitForExtensionIdle(const std::string& extension_id); |
| - |
| - // Wait for extension to be not idle. |
| - bool WaitForExtensionNotIdle(const std::string& extension_id); |
| - |
| // Watch for the given event type from the given source. |
| // After calling this method, call Wait() to ensure that RunMessageLoop() is |
| // called appropriately and cleanup is performed. |
| @@ -84,12 +69,38 @@ class ExtensionTestNotificationObserver |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) override; |
| - private: |
| - class NotificationSet; |
| - |
| - Profile* GetProfile(); |
| - |
| - void WaitForNotification(int notification_type); |
| + protected: |
| + class NotificationSet : public content::NotificationObserver, |
| + public extensions::ProcessManagerObserver { |
| + public: |
| + NotificationSet(); |
| + ~NotificationSet() override; |
| + |
| + void Add(int type, const content::NotificationSource& source); |
| + void Add(int type); |
| + void AddExtensionFrameUnregistration(extensions::ProcessManager* manager); |
| + |
| + // Notified any time an Add()ed notification is received. |
| + // The details of the notification are dropped. |
| + base::CallbackList<void()>& callback_list() { return callback_list_; } |
|
Devlin
2016/10/06 15:52:17
non-const & return values are discouraged by style
Rahul Chaturvedi
2016/10/11 20:12:35
Moved code.
|
| + |
| + private: |
| + // content::NotificationObserver: |
| + void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) override; |
| + |
| + // extensions::ProcessManagerObserver: |
| + void OnExtensionFrameUnregistered( |
| + const std::string& extension_id, |
| + content::RenderFrameHost* render_frame_host) override; |
| + |
| + content::NotificationRegistrar notification_registrar_; |
| + base::CallbackList<void()> callback_list_; |
| + ScopedObserver<extensions::ProcessManager, |
| + extensions::ProcessManagerObserver> |
| + process_manager_observer_; |
|
Devlin
2016/10/06 15:52:17
DISALLOW_COPY_AND_ASSIGN?
Rahul Chaturvedi
2016/10/11 20:12:35
Done.
|
| + }; |
| // Wait for |condition_| to be met. |notification_set| is the set of |
| // notifications to wait for and to check |condition| when observing. This |
| @@ -98,15 +109,14 @@ class ExtensionTestNotificationObserver |
| void WaitForCondition(const base::Callback<bool(void)>& condition, |
| NotificationSet* notification_set); |
| + void WaitForNotification(int notification_type); |
| + |
| // Quits the message loop if |condition_| is met. |
| void MaybeQuit(); |
| - // extensions::ExtensionActionAPI::Observer: |
| - void OnPageActionsUpdated(content::WebContents* contents) override; |
| - |
| - Browser* browser_; |
| - Profile* profile_; |
| + content::BrowserContext* context_; |
| + private: |
| content::NotificationRegistrar registrar_; |
| std::unique_ptr<content::WindowedNotificationObserver> observer_; |
| @@ -123,4 +133,4 @@ class ExtensionTestNotificationObserver |
| base::Closure quit_closure_; |
|
Devlin
2016/10/06 15:52:17
DISALLOW_COPY_AND_ASSIGN?
Rahul Chaturvedi
2016/10/11 20:12:35
Done.
|
| }; |
| -#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ |
| +#endif // EXTENSIONS_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ |