| 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_SYNC_EXTENSION_HELPER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_HELPER_H_ |
| 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_HELPER_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_HELPER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Returns true iff the extension is enabled in incognito mode on |profile|. | 65 // Returns true iff the extension is enabled in incognito mode on |profile|. |
| 66 bool IsIncognitoEnabled(Profile* profile, const std::string& name) const; | 66 bool IsIncognitoEnabled(Profile* profile, const std::string& name) const; |
| 67 | 67 |
| 68 // Returns true iff the extension with the given id is pending | 68 // Returns true iff the extension with the given id is pending |
| 69 // install in |profile|. | 69 // install in |profile|. |
| 70 bool IsExtensionPendingInstallForSync( | 70 bool IsExtensionPendingInstallForSync( |
| 71 Profile* profile, const std::string& id) const; | 71 Profile* profile, const std::string& id) const; |
| 72 | 72 |
| 73 // Installs all extensions pending sync in |profile| of the given | 73 // Installs all extensions pending sync in |profile| of the given |
| 74 // type. | 74 // type. |
| 75 void InstallExtensionsPendingForSync(Profile* profile, | 75 void InstallExtensionsPendingForSync(Profile* profile); |
| 76 extensions::Extension::Type type); | |
| 77 | 76 |
| 78 // Returns true iff |profile1| and |profile2| have the same extensions and | 77 // Returns true iff |profile1| and |profile2| have the same extensions and |
| 79 // they are all in the same state. | 78 // they are all in the same state. |
| 80 static bool ExtensionStatesMatch(Profile* profile1, Profile* profile2); | 79 static bool ExtensionStatesMatch(Profile* profile1, Profile* profile2); |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 struct ExtensionState { | 82 struct ExtensionState { |
| 84 enum EnabledState { DISABLED, PENDING, ENABLED }; | 83 enum EnabledState { DISABLED, PENDING, ENABLED }; |
| 85 | 84 |
| 86 ExtensionState(); | 85 ExtensionState(); |
| 87 ~ExtensionState(); | 86 ~ExtensionState(); |
| 88 bool Equals(const ExtensionState &other) const; | 87 bool Equals(const ExtensionState &other) const; |
| 89 | 88 |
| 90 EnabledState enabled_state; | 89 EnabledState enabled_state; |
| 91 bool incognito_enabled; | 90 bool incognito_enabled; |
| 92 }; | 91 }; |
| 93 | 92 |
| 94 typedef std::map<std::string, ExtensionState> ExtensionStateMap; | 93 typedef std::map<std::string, ExtensionState> ExtensionStateMap; |
| 95 typedef std::map<std::string, scoped_refptr<extensions::Extension> > | 94 typedef std::map<std::string, scoped_refptr<extensions::Extension> > |
| 96 ExtensionNameMap; | 95 ExtensionNameMap; |
| 97 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap; | 96 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap; |
| 98 typedef std::map<std::string, std::string> StringMap; | 97 typedef std::map<std::string, std::string> StringMap; |
| 98 typedef std::map<std::string, extensions::Extension::Type> TypeMap; |
| 99 | 99 |
| 100 friend struct DefaultSingletonTraits<SyncExtensionHelper>; | 100 friend struct DefaultSingletonTraits<SyncExtensionHelper>; |
| 101 | 101 |
| 102 SyncExtensionHelper(); | 102 SyncExtensionHelper(); |
| 103 ~SyncExtensionHelper(); | 103 ~SyncExtensionHelper(); |
| 104 | 104 |
| 105 // Returns a map from |profile|'s installed extensions to their state. | 105 // Returns a map from |profile|'s installed extensions to their state. |
| 106 static ExtensionStateMap GetExtensionStates(Profile* profile); | 106 static ExtensionStateMap GetExtensionStates(Profile* profile); |
| 107 | 107 |
| 108 // Initializes extensions for |profile| and creates an entry in | 108 // Initializes extensions for |profile| and creates an entry in |
| 109 // |profile_extensions_| for it. | 109 // |profile_extensions_| for it. |
| 110 void SetupProfile(Profile* profile); | 110 void SetupProfile(Profile* profile); |
| 111 | 111 |
| 112 // Returns an extension for the given name in |profile|. type and | 112 // Returns an extension for the given name in |profile|. type and |
| 113 // index. Two extensions with the name but different profiles will | 113 // index. Two extensions with the name but different profiles will |
| 114 // have the same id. | 114 // have the same id. |
| 115 scoped_refptr<extensions::Extension> GetExtension( | 115 scoped_refptr<extensions::Extension> GetExtension( |
| 116 Profile* profile, const std::string& name, | 116 Profile* profile, const std::string& name, |
| 117 extensions::Extension::Type type) WARN_UNUSED_RESULT; | 117 extensions::Extension::Type type) WARN_UNUSED_RESULT; |
| 118 | 118 |
| 119 ProfileExtensionNameMap profile_extensions_; | 119 ProfileExtensionNameMap profile_extensions_; |
| 120 StringMap id_to_name_; | 120 StringMap id_to_name_; |
| 121 TypeMap id_to_type_; |
| 121 bool setup_completed_; | 122 bool setup_completed_; |
| 122 | 123 |
| 123 DISALLOW_COPY_AND_ASSIGN(SyncExtensionHelper); | 124 DISALLOW_COPY_AND_ASSIGN(SyncExtensionHelper); |
| 124 }; | 125 }; |
| 125 | 126 |
| 126 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_HELPER_H_ | 127 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_HELPER_H_ |
| OLD | NEW |