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 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_APPS_HELPER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_APPS_HELPER_H_ |
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_APPS_HELPER_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_APPS_HELPER_H_ |
7 | 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
8 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "chrome/browser/sync/test/integration/status_change_checker.h" |
9 #include "chrome/browser/sync/test/integration/sync_test.h" | 13 #include "chrome/browser/sync/test/integration/sync_test.h" |
10 #include "components/sync/api/string_ordinal.h" | 14 #include "components/sync/api/string_ordinal.h" |
| 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "extensions/browser/extension_prefs_observer.h" |
| 18 #include "extensions/browser/extension_registry_observer.h" |
11 | 19 |
12 class Profile; | 20 class Profile; |
| 21 class SyncedExtensionInstaller; |
13 | 22 |
14 namespace apps_helper { | 23 namespace apps_helper { |
15 | 24 |
16 // Returns true iff |profile1| has same apps (hosted, legacy packaged and | 25 // Returns true iff |profile1| has same apps (hosted, legacy packaged and |
17 // platform) as |profile2|. | 26 // platform) as |profile2|. |
18 bool HasSameApps(Profile* profile1, Profile* profile2); | 27 bool HasSameApps(Profile* profile1, Profile* profile2); |
19 | 28 |
20 // Returns true iff all existing profiles have the same apps (hosted, | 29 // Returns true iff all existing profiles have the same apps (hosted, |
21 // legacy packaged and platform). | 30 // legacy packaged and platform). |
22 bool AllProfilesHaveSameApps() WARN_UNUSED_RESULT; | 31 bool AllProfilesHaveSameApps() WARN_UNUSED_RESULT; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 92 |
84 // Copy the page and app launch ordinal value for the application at the given | 93 // Copy the page and app launch ordinal value for the application at the given |
85 // index on |profile_source| to |profile_destination|. | 94 // index on |profile_source| to |profile_destination|. |
86 // The main intention of this is to properly setup the values on the verifier | 95 // The main intention of this is to properly setup the values on the verifier |
87 // profile in situations where the other profiles have conflicting values. | 96 // profile in situations where the other profiles have conflicting values. |
88 void CopyNTPOrdinals(Profile* source, Profile* destination, int index); | 97 void CopyNTPOrdinals(Profile* source, Profile* destination, int index); |
89 | 98 |
90 // Fix any NTP icon collisions that are currently in |profile|. | 99 // Fix any NTP icon collisions that are currently in |profile|. |
91 void FixNTPOrdinalCollisions(Profile* profile); | 100 void FixNTPOrdinalCollisions(Profile* profile); |
92 | 101 |
93 // Waits until all profiles have the same set of apps. In case verifier profile | |
94 // is enabled, it waits until all profiles match the verifier. | |
95 // | |
96 // Returns false on time out. | |
97 bool AwaitAllProfilesHaveSameApps(); | |
98 | |
99 } // namespace apps_helper | 102 } // namespace apps_helper |
100 | 103 |
| 104 // Checker to block for a set of profiles to have matching extensions lists. If |
| 105 // the verifier profile is enabled, it will be included in the set of profiles |
| 106 // to check against. |
| 107 class AppsMatchChecker : public StatusChangeChecker, |
| 108 public extensions::ExtensionRegistryObserver, |
| 109 public extensions::ExtensionPrefsObserver, |
| 110 public content::NotificationObserver { |
| 111 public: |
| 112 AppsMatchChecker(); |
| 113 ~AppsMatchChecker() override; |
| 114 |
| 115 // StatusChangeChecker implementation. |
| 116 std::string GetDebugMessage() const override; |
| 117 bool IsExitConditionSatisfied() override; |
| 118 |
| 119 // extensions::ExtensionRegistryObserver implementation. |
| 120 void OnExtensionLoaded(content::BrowserContext* context, |
| 121 const extensions::Extension* extension) override; |
| 122 void OnExtensionUnloaded( |
| 123 content::BrowserContext* context, |
| 124 const extensions::Extension* extenion, |
| 125 extensions::UnloadedExtensionInfo::Reason reason) override; |
| 126 void OnExtensionInstalled(content::BrowserContext* browser_context, |
| 127 const extensions::Extension* extension, |
| 128 bool is_update) override; |
| 129 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 130 const extensions::Extension* extension, |
| 131 extensions::UninstallReason reason) override; |
| 132 |
| 133 // extensions::ExtensionPrefsObserver implementation. |
| 134 void OnExtensionDisableReasonsChanged(const std::string& extension_id, |
| 135 int disabled_reasons) override; |
| 136 void OnExtensionRegistered(const std::string& extension_id, |
| 137 const base::Time& install_time, |
| 138 bool is_enabled) override; |
| 139 void OnExtensionPrefsLoaded(const std::string& extension_id, |
| 140 const extensions::ExtensionPrefs* prefs) override; |
| 141 void OnExtensionPrefsDeleted(const std::string& extension_id) override; |
| 142 void OnExtensionStateChanged(const std::string& extension_id, |
| 143 bool state) override; |
| 144 |
| 145 // Implementation of content::NotificationObserver. |
| 146 void Observe(int type, |
| 147 const content::NotificationSource& source, |
| 148 const content::NotificationDetails& details) override; |
| 149 |
| 150 private: |
| 151 std::vector<Profile*> profiles_; |
| 152 |
| 153 content::NotificationRegistrar registrar_; |
| 154 |
| 155 // This installs apps, too. |
| 156 ScopedVector<SyncedExtensionInstaller> synced_extension_installers_; |
| 157 |
| 158 DISALLOW_COPY_AND_ASSIGN(AppsMatchChecker); |
| 159 }; |
| 160 |
101 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_APPS_HELPER_H_ | 161 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_APPS_HELPER_H_ |
OLD | NEW |