| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_ | 5 #ifndef EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_ |
| 6 #define EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_ | 6 #define EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
| 9 #include "extensions/browser/extension_registry_observer.h" | 9 #include "extensions/browser/extension_registry_observer.h" |
| 10 | 10 |
| 11 namespace extensions { | 11 namespace extensions { |
| 12 class ExtensionRegistry; | 12 class ExtensionRegistry; |
| 13 | 13 |
| 14 // A helper class that listen for ExtensionRegistry notifications. | 14 // A helper class that listen for ExtensionRegistry notifications. |
| 15 class TestExtensionRegistryObserver : public ExtensionRegistryObserver { | 15 class TestExtensionRegistryObserver : public ExtensionRegistryObserver { |
| 16 public: | 16 public: |
| 17 explicit TestExtensionRegistryObserver(ExtensionRegistry* registry, | 17 explicit TestExtensionRegistryObserver(ExtensionRegistry* registry, |
| 18 const std::string& extension_id); | 18 const std::string& extension_id); |
| 19 virtual ~TestExtensionRegistryObserver(); | 19 ~TestExtensionRegistryObserver() override; |
| 20 | 20 |
| 21 void WaitForExtensionWillBeInstalled(); | 21 void WaitForExtensionWillBeInstalled(); |
| 22 void WaitForExtensionUninstalled(); | 22 void WaitForExtensionUninstalled(); |
| 23 void WaitForExtensionLoaded(); | 23 void WaitForExtensionLoaded(); |
| 24 void WaitForExtensionUnloaded(); | 24 void WaitForExtensionUnloaded(); |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 class Waiter; | 27 class Waiter; |
| 28 | 28 |
| 29 // ExtensionRegistryObserver. | 29 // ExtensionRegistryObserver. |
| 30 virtual void OnExtensionWillBeInstalled( | 30 void OnExtensionWillBeInstalled(content::BrowserContext* browser_context, |
| 31 content::BrowserContext* browser_context, | 31 const Extension* extension, |
| 32 const Extension* extension, | 32 bool is_update, |
| 33 bool is_update, | 33 bool from_ephemeral, |
| 34 bool from_ephemeral, | 34 const std::string& old_name) override; |
| 35 const std::string& old_name) override; | 35 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 36 virtual void OnExtensionUninstalled( | 36 const Extension* extension, |
| 37 content::BrowserContext* browser_context, | 37 extensions::UninstallReason reason) override; |
| 38 const Extension* extension, | 38 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 39 extensions::UninstallReason reason) override; | 39 const Extension* extension) override; |
| 40 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 40 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 41 const Extension* extension) override; | 41 const Extension* extension, |
| 42 virtual void OnExtensionUnloaded( | 42 UnloadedExtensionInfo::Reason reason) override; |
| 43 content::BrowserContext* browser_context, | |
| 44 const Extension* extension, | |
| 45 UnloadedExtensionInfo::Reason reason) override; | |
| 46 | 43 |
| 47 scoped_ptr<Waiter> will_be_installed_waiter_; | 44 scoped_ptr<Waiter> will_be_installed_waiter_; |
| 48 scoped_ptr<Waiter> uninstalled_waiter_; | 45 scoped_ptr<Waiter> uninstalled_waiter_; |
| 49 scoped_ptr<Waiter> loaded_waiter_; | 46 scoped_ptr<Waiter> loaded_waiter_; |
| 50 scoped_ptr<Waiter> unloaded_waiter_; | 47 scoped_ptr<Waiter> unloaded_waiter_; |
| 51 | 48 |
| 52 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 49 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 53 extension_registry_observer_; | 50 extension_registry_observer_; |
| 54 | 51 |
| 55 std::string extension_id_; | 52 std::string extension_id_; |
| 56 | 53 |
| 57 DISALLOW_COPY_AND_ASSIGN(TestExtensionRegistryObserver); | 54 DISALLOW_COPY_AND_ASSIGN(TestExtensionRegistryObserver); |
| 58 }; | 55 }; |
| 59 | 56 |
| 60 } // namespace extensions | 57 } // namespace extensions |
| 61 | 58 |
| 62 #endif // EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_ | 59 #endif // EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_ |
| OLD | NEW |