OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/sync/test/integration/apps_helper.h" | 5 #include "chrome/browser/sync/test/integration/apps_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 namespace { | 139 namespace { |
140 | 140 |
141 // A helper class to implement waiting for a set of profiles to have matching | 141 // A helper class to implement waiting for a set of profiles to have matching |
142 // extensions lists. | 142 // extensions lists. |
143 class AppsMatchChecker : public StatusChangeChecker, | 143 class AppsMatchChecker : public StatusChangeChecker, |
144 public extensions::ExtensionRegistryObserver, | 144 public extensions::ExtensionRegistryObserver, |
145 public extensions::ExtensionPrefsObserver, | 145 public extensions::ExtensionPrefsObserver, |
146 public content::NotificationObserver { | 146 public content::NotificationObserver { |
147 public: | 147 public: |
148 explicit AppsMatchChecker(const std::vector<Profile*>& profiles); | 148 explicit AppsMatchChecker(const std::vector<Profile*>& profiles); |
149 virtual ~AppsMatchChecker(); | 149 ~AppsMatchChecker() override; |
150 | 150 |
151 // StatusChangeChecker implementation. | 151 // StatusChangeChecker implementation. |
152 virtual std::string GetDebugMessage() const override; | 152 std::string GetDebugMessage() const override; |
153 virtual bool IsExitConditionSatisfied() override; | 153 bool IsExitConditionSatisfied() override; |
154 | 154 |
155 // extensions::ExtensionRegistryObserver implementation. | 155 // extensions::ExtensionRegistryObserver implementation. |
156 virtual void OnExtensionLoaded( | 156 void OnExtensionLoaded(content::BrowserContext* context, |
157 content::BrowserContext* context, | 157 const extensions::Extension* extension) override; |
158 const extensions::Extension* extension) override; | 158 void OnExtensionUnloaded( |
159 virtual void OnExtensionUnloaded( | |
160 content::BrowserContext* context, | 159 content::BrowserContext* context, |
161 const extensions::Extension* extenion, | 160 const extensions::Extension* extenion, |
162 extensions::UnloadedExtensionInfo::Reason reason) override; | 161 extensions::UnloadedExtensionInfo::Reason reason) override; |
163 virtual void OnExtensionInstalled(content::BrowserContext* browser_context, | 162 void OnExtensionInstalled(content::BrowserContext* browser_context, |
164 const extensions::Extension* extension, | 163 const extensions::Extension* extension, |
165 bool is_update) override; | 164 bool is_update) override; |
166 virtual void OnExtensionUninstalled( | 165 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
167 content::BrowserContext* browser_context, | 166 const extensions::Extension* extension, |
168 const extensions::Extension* extension, | 167 extensions::UninstallReason reason) override; |
169 extensions::UninstallReason reason) override; | |
170 | 168 |
171 // extensions::ExtensionPrefsObserver implementation. | 169 // extensions::ExtensionPrefsObserver implementation. |
172 virtual void OnExtensionDisableReasonsChanged(const std::string& extension_id, | 170 void OnExtensionDisableReasonsChanged(const std::string& extension_id, |
173 int disabled_reasons) override; | 171 int disabled_reasons) override; |
174 virtual void OnExtensionRegistered(const std::string& extension_id, | 172 void OnExtensionRegistered(const std::string& extension_id, |
175 const base::Time& install_time, | 173 const base::Time& install_time, |
176 bool is_enabled) override; | 174 bool is_enabled) override; |
177 virtual void OnExtensionPrefsLoaded( | 175 void OnExtensionPrefsLoaded(const std::string& extension_id, |
178 const std::string& extension_id, | 176 const extensions::ExtensionPrefs* prefs) override; |
179 const extensions::ExtensionPrefs* prefs) override; | 177 void OnExtensionPrefsDeleted(const std::string& extension_id) override; |
180 virtual void OnExtensionPrefsDeleted( | 178 void OnExtensionStateChanged(const std::string& extension_id, |
181 const std::string& extension_id) override; | 179 bool state) override; |
182 virtual void OnExtensionStateChanged(const std::string& extension_id, | |
183 bool state) override; | |
184 | 180 |
185 // Implementation of content::NotificationObserver. | 181 // Implementation of content::NotificationObserver. |
186 virtual void Observe(int type, | 182 void Observe(int type, |
187 const content::NotificationSource& source, | 183 const content::NotificationSource& source, |
188 const content::NotificationDetails& details) override; | 184 const content::NotificationDetails& details) override; |
189 | 185 |
190 void Wait(); | 186 void Wait(); |
191 | 187 |
192 private: | 188 private: |
193 std::vector<Profile*> profiles_; | 189 std::vector<Profile*> profiles_; |
194 bool observing_; | 190 bool observing_; |
195 | 191 |
196 content::NotificationRegistrar registrar_; | 192 content::NotificationRegistrar registrar_; |
197 | 193 |
198 // This installs apps, too. | 194 // This installs apps, too. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 for (int i = 0; i < test()->num_clients(); ++i) { | 337 for (int i = 0; i < test()->num_clients(); ++i) { |
342 profiles.push_back(test()->GetProfile(i)); | 338 profiles.push_back(test()->GetProfile(i)); |
343 } | 339 } |
344 | 340 |
345 AppsMatchChecker checker(profiles); | 341 AppsMatchChecker checker(profiles); |
346 checker.Wait(); | 342 checker.Wait(); |
347 return !checker.TimedOut(); | 343 return !checker.TimedOut(); |
348 } | 344 } |
349 | 345 |
350 } // namespace apps_helper | 346 } // namespace apps_helper |
OLD | NEW |