OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return last_loaded_extension_id_; | 73 return last_loaded_extension_id_; |
74 } | 74 } |
75 void set_last_loaded_extension_id( | 75 void set_last_loaded_extension_id( |
76 const std::string& last_loaded_extension_id) { | 76 const std::string& last_loaded_extension_id) { |
77 last_loaded_extension_id_ = last_loaded_extension_id; | 77 last_loaded_extension_id_ = last_loaded_extension_id; |
78 } | 78 } |
79 | 79 |
80 // content::NotificationObserver | 80 // content::NotificationObserver |
81 virtual void Observe(int type, | 81 virtual void Observe(int type, |
82 const content::NotificationSource& source, | 82 const content::NotificationSource& source, |
83 const content::NotificationDetails& details) OVERRIDE; | 83 const content::NotificationDetails& details) override; |
84 | 84 |
85 private: | 85 private: |
86 class NotificationSet; | 86 class NotificationSet; |
87 | 87 |
88 Profile* GetProfile(); | 88 Profile* GetProfile(); |
89 | 89 |
90 void WaitForNotification(int notification_type); | 90 void WaitForNotification(int notification_type); |
91 | 91 |
92 // Wait for |condition_| to be met. |notification_set| is the set of | 92 // Wait for |condition_| to be met. |notification_set| is the set of |
93 // notifications to wait for and to check |condition| when observing. This | 93 // notifications to wait for and to check |condition| when observing. This |
94 // can be NULL if we are instead waiting for a different observer method, like | 94 // can be NULL if we are instead waiting for a different observer method, like |
95 // OnPageActionsUpdated(). | 95 // OnPageActionsUpdated(). |
96 void WaitForCondition(const base::Callback<bool(void)>& condition, | 96 void WaitForCondition(const base::Callback<bool(void)>& condition, |
97 NotificationSet* notification_set); | 97 NotificationSet* notification_set); |
98 | 98 |
99 // Quits the message loop if |condition_| is met. | 99 // Quits the message loop if |condition_| is met. |
100 void MaybeQuit(); | 100 void MaybeQuit(); |
101 | 101 |
102 // extensions::ExtensionActionAPI::Observer: | 102 // extensions::ExtensionActionAPI::Observer: |
103 virtual void OnPageActionsUpdated(content::WebContents* contents) OVERRIDE; | 103 virtual void OnPageActionsUpdated(content::WebContents* contents) override; |
104 | 104 |
105 Browser* browser_; | 105 Browser* browser_; |
106 Profile* profile_; | 106 Profile* profile_; |
107 | 107 |
108 content::NotificationRegistrar registrar_; | 108 content::NotificationRegistrar registrar_; |
109 scoped_ptr<content::WindowedNotificationObserver> observer_; | 109 scoped_ptr<content::WindowedNotificationObserver> observer_; |
110 | 110 |
111 std::string last_loaded_extension_id_; | 111 std::string last_loaded_extension_id_; |
112 int extension_installs_observed_; | 112 int extension_installs_observed_; |
113 int extension_load_errors_observed_; | 113 int extension_load_errors_observed_; |
114 int crx_installers_done_observed_; | 114 int crx_installers_done_observed_; |
115 | 115 |
116 // The condition for which we are waiting. This should be checked in any | 116 // The condition for which we are waiting. This should be checked in any |
117 // observing methods that could trigger it. | 117 // observing methods that could trigger it. |
118 base::Callback<bool(void)> condition_; | 118 base::Callback<bool(void)> condition_; |
119 | 119 |
120 // The closure to quit the currently-running message loop. | 120 // The closure to quit the currently-running message loop. |
121 base::Closure quit_closure_; | 121 base::Closure quit_closure_; |
122 }; | 122 }; |
123 | 123 |
124 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ | 124 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ |
OLD | NEW |