Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(746)

Side by Side Diff: extensions/test/extension_test_notification_observer.h

Issue 2753513006: Remove ...LOADED_DEPRECATED and its friends (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ 5 #ifndef EXTENSIONS_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
6 #define EXTENSIONS_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ 6 #define EXTENSIONS_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/callback_list.h" 12 #include "base/callback_list.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/scoped_observer.h" 14 #include "base/scoped_observer.h"
15 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
17 #include "extensions/browser/extension_registry_observer.h"
17 #include "extensions/browser/process_manager_observer.h" 18 #include "extensions/browser/process_manager_observer.h"
18 19
19 namespace content { 20 namespace content {
20 class BrowserContext; 21 class BrowserContext;
21 class NotificationDetails; 22 class NotificationDetails;
22 class WindowedNotificationObserver; 23 class WindowedNotificationObserver;
23 } 24 }
24 25
25 namespace extensions { 26 namespace extensions {
27 class ExtensionRegistry;
26 class ProcessManager; 28 class ProcessManager;
27 29
28 // Test helper class for observing extension-related events. 30 // Test helper class for observing extension-related events.
29 class ExtensionTestNotificationObserver : public content::NotificationObserver { 31 class ExtensionTestNotificationObserver : public content::NotificationObserver,
32 ExtensionRegistryObserver {
30 public: 33 public:
31 explicit ExtensionTestNotificationObserver(content::BrowserContext* context); 34 explicit ExtensionTestNotificationObserver(content::BrowserContext* context);
32 ~ExtensionTestNotificationObserver() override; 35 ~ExtensionTestNotificationObserver() override;
33 36
34 // Wait for an extension install error to be raised. Returns true if an 37 // Wait for an extension install error to be raised. Returns true if an
35 // error was raised. 38 // error was raised.
36 bool WaitForExtensionInstallError(); 39 bool WaitForExtensionInstallError();
37 40
38 // Waits until an extension is loaded.
39 void WaitForExtensionLoad();
40
41 // Waits for an extension load error. Returns true if the error really 41 // Waits for an extension load error. Returns true if the error really
42 // happened. 42 // happened.
43 bool WaitForExtensionLoadError(); 43 bool WaitForExtensionLoadError();
44 44
45 // Wait for the specified extension to crash. Returns true if it really 45 // Wait for the specified extension to crash. Returns true if it really
46 // crashed. 46 // crashed.
47 bool WaitForExtensionCrash(const std::string& extension_id); 47 bool WaitForExtensionCrash(const std::string& extension_id);
48 48
49 // Wait for the crx installer to be done. Returns true if it really is done. 49 // Wait for the crx installer to be done. Returns true if it really is done.
50 bool WaitForCrxInstallerDone(); 50 bool WaitForCrxInstallerDone();
51 51
52 // Watch for the given event type from the given source. 52 // Watch for the given event type from the given source.
53 // After calling this method, call Wait() to ensure that RunMessageLoop() is 53 // After calling this method, call Wait() to ensure that RunMessageLoop() is
54 // called appropriately and cleanup is performed. 54 // called appropriately and cleanup is performed.
55 void Watch(int type, const content::NotificationSource& source); 55 void Watch(int type, const content::NotificationSource& source);
56 56
57 // After registering one or more event types with Watch(), call 57 // After registering one or more event types with Watch(), call
58 // this method to run the message loop and perform cleanup. 58 // this method to run the message loop and perform cleanup.
59 void Wait(); 59 void Wait();
60 60
61 const std::string& last_loaded_extension_id() { 61 const std::string& last_loaded_extension_id() {
62 return last_loaded_extension_id_; 62 return last_loaded_extension_id_;
63 } 63 }
64 void set_last_loaded_extension_id( 64 void set_last_loaded_extension_id(
65 const std::string& last_loaded_extension_id) { 65 const std::string& last_loaded_extension_id) {
66 last_loaded_extension_id_ = last_loaded_extension_id; 66 last_loaded_extension_id_ = last_loaded_extension_id;
67 } 67 }
68 68
69 // content::NotificationObserver 69 // content::NotificationObserver:
70 void Observe(int type, 70 void Observe(int type,
71 const content::NotificationSource& source, 71 const content::NotificationSource& source,
72 const content::NotificationDetails& details) override; 72 const content::NotificationDetails& details) override;
73 73
74 // ExtensionRegistryObserver:
75 void OnExtensionLoaded(content::BrowserContext* browser_context,
76 const Extension* extension) override;
77 void OnShutdown(ExtensionRegistry* registry) override;
78
74 protected: 79 protected:
75 class NotificationSet : public content::NotificationObserver, 80 class NotificationSet : public content::NotificationObserver,
76 public extensions::ProcessManagerObserver { 81 public extensions::ProcessManagerObserver {
77 public: 82 public:
78 NotificationSet(); 83 NotificationSet();
79 ~NotificationSet() override; 84 ~NotificationSet() override;
80 85
81 void Add(int type, const content::NotificationSource& source); 86 void Add(int type, const content::NotificationSource& source);
82 void Add(int type); 87 void Add(int type);
83 void AddExtensionFrameUnregistration(extensions::ProcessManager* manager); 88 void AddExtensionFrameUnregistration(extensions::ProcessManager* manager);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 int extension_load_errors_observed_; 133 int extension_load_errors_observed_;
129 int crx_installers_done_observed_; 134 int crx_installers_done_observed_;
130 135
131 // The condition for which we are waiting. This should be checked in any 136 // The condition for which we are waiting. This should be checked in any
132 // observing methods that could trigger it. 137 // observing methods that could trigger it.
133 base::Callback<bool(void)> condition_; 138 base::Callback<bool(void)> condition_;
134 139
135 // The closure to quit the currently-running message loop. 140 // The closure to quit the currently-running message loop.
136 base::Closure quit_closure_; 141 base::Closure quit_closure_;
137 142
143 // Listens to extension loaded notifications.
144 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
145 registry_observer_;
146
138 DISALLOW_COPY_AND_ASSIGN(ExtensionTestNotificationObserver); 147 DISALLOW_COPY_AND_ASSIGN(ExtensionTestNotificationObserver);
139 }; 148 };
140 149
141 } // namespace extensions 150 } // namespace extensions
142 151
143 #endif // EXTENSIONS_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ 152 #endif // EXTENSIONS_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698