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

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

Issue 2753513006: Remove ...LOADED_DEPRECATED and its friends (Closed)
Patch Set: include .h 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 has finished 49 // Wait for the crx installer to be done. Returns true if it has finished
50 // successfully. 50 // successfully.
51 bool WaitForCrxInstallerDone(); 51 bool WaitForCrxInstallerDone();
52 52
53 // Watch for the given event type from the given source. 53 // Watch for the given event type from the given source.
54 // After calling this method, call Wait() to ensure that RunMessageLoop() is 54 // After calling this method, call Wait() to ensure that RunMessageLoop() is
55 // called appropriately and cleanup is performed. 55 // called appropriately and cleanup is performed.
56 void Watch(int type, const content::NotificationSource& source); 56 void Watch(int type, const content::NotificationSource& source);
57 57
58 // After registering one or more event types with Watch(), call 58 // After registering one or more event types with Watch(), call
59 // this method to run the message loop and perform cleanup. 59 // this method to run the message loop and perform cleanup.
60 void Wait(); 60 void Wait();
61 61
62 const std::string& last_loaded_extension_id() { 62 const std::string& last_loaded_extension_id() {
63 return last_loaded_extension_id_; 63 return last_loaded_extension_id_;
64 } 64 }
65 void set_last_loaded_extension_id( 65 void set_last_loaded_extension_id(
66 const std::string& last_loaded_extension_id) { 66 const std::string& last_loaded_extension_id) {
67 last_loaded_extension_id_ = last_loaded_extension_id; 67 last_loaded_extension_id_ = last_loaded_extension_id;
68 } 68 }
69 69
70 // content::NotificationObserver 70 // content::NotificationObserver:
71 void Observe(int type, 71 void Observe(int type,
72 const content::NotificationSource& source, 72 const content::NotificationSource& source,
73 const content::NotificationDetails& details) override; 73 const content::NotificationDetails& details) override;
74 74
75 // ExtensionRegistryObserver:
76 void OnExtensionLoaded(content::BrowserContext* browser_context,
77 const Extension* extension) override;
78 void OnShutdown(ExtensionRegistry* registry) override;
79
75 protected: 80 protected:
76 class NotificationSet : public content::NotificationObserver, 81 class NotificationSet : public content::NotificationObserver,
77 public extensions::ProcessManagerObserver { 82 public extensions::ProcessManagerObserver {
78 public: 83 public:
79 NotificationSet(); 84 NotificationSet();
80 ~NotificationSet() override; 85 ~NotificationSet() override;
81 86
82 void Add(int type, const content::NotificationSource& source); 87 void Add(int type, const content::NotificationSource& source);
83 void Add(int type); 88 void Add(int type);
84 void AddExtensionFrameUnregistration(extensions::ProcessManager* manager); 89 void AddExtensionFrameUnregistration(extensions::ProcessManager* manager);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 int extension_load_errors_observed_; 134 int extension_load_errors_observed_;
130 int crx_installers_done_observed_; 135 int crx_installers_done_observed_;
131 136
132 // The condition for which we are waiting. This should be checked in any 137 // The condition for which we are waiting. This should be checked in any
133 // observing methods that could trigger it. 138 // observing methods that could trigger it.
134 base::Callback<bool(void)> condition_; 139 base::Callback<bool(void)> condition_;
135 140
136 // The closure to quit the currently-running message loop. 141 // The closure to quit the currently-running message loop.
137 base::Closure quit_closure_; 142 base::Closure quit_closure_;
138 143
144 // Listens to extension loaded notifications.
145 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
146 registry_observer_;
147
139 DISALLOW_COPY_AND_ASSIGN(ExtensionTestNotificationObserver); 148 DISALLOW_COPY_AND_ASSIGN(ExtensionTestNotificationObserver);
140 }; 149 };
141 150
142 } // namespace extensions 151 } // namespace extensions
143 152
144 #endif // EXTENSIONS_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ 153 #endif // EXTENSIONS_TEST_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698