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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_
6 #define EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_
8 #include "base/scoped_observer.h"
9 #include "extensions/browser/extension_registry_observer.h"
11 namespace extensions
{
12 class ExtensionRegistry
;
14 // A helper class that listen for ExtensionRegistry notifications.
15 class TestExtensionRegistryObserver
: public ExtensionRegistryObserver
{
17 explicit TestExtensionRegistryObserver(ExtensionRegistry
* registry
,
18 const std::string
& extension_id
);
19 virtual ~TestExtensionRegistryObserver();
21 void WaitForExtensionWillBeInstalled();
22 void WaitForExtensionUninstalled();
23 void WaitForExtensionLoaded();
24 void WaitForExtensionUnloaded();
29 // ExtensionRegistryObserver.
30 virtual void OnExtensionWillBeInstalled(
31 content::BrowserContext
* browser_context
,
32 const Extension
* extension
,
35 const std::string
& old_name
) OVERRIDE
;
36 virtual void OnExtensionUninstalled(
37 content::BrowserContext
* browser_context
,
38 const Extension
* extension
,
39 extensions::UninstallReason reason
) OVERRIDE
;
40 virtual void OnExtensionLoaded(content::BrowserContext
* browser_context
,
41 const Extension
* extension
) OVERRIDE
;
42 virtual void OnExtensionUnloaded(
43 content::BrowserContext
* browser_context
,
44 const Extension
* extension
,
45 UnloadedExtensionInfo::Reason reason
) OVERRIDE
;
47 scoped_ptr
<Waiter
> will_be_installed_waiter_
;
48 scoped_ptr
<Waiter
> uninstalled_waiter_
;
49 scoped_ptr
<Waiter
> loaded_waiter_
;
50 scoped_ptr
<Waiter
> unloaded_waiter_
;
52 ScopedObserver
<ExtensionRegistry
, ExtensionRegistryObserver
>
53 extension_registry_observer_
;
55 std::string extension_id_
;
57 DISALLOW_COPY_AND_ASSIGN(TestExtensionRegistryObserver
);
60 } // namespace extensions
62 #endif // EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_