Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ | 5 #ifndef CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ |
| 6 #define CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ | 6 #define CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 16 | 16 |
| 17 class Extension; | 17 class Extension; |
| 18 class LiveSyncTest; | 18 class LiveSyncTest; |
| 19 class Profile; | 19 class Profile; |
| 20 | 20 |
| 21 class LiveSyncExtensionHelper { | 21 class LiveSyncExtensionHelper { |
| 22 public: | 22 public: |
| 23 enum ExtensionState { DISABLED, PENDING, ENABLED }; | 23 struct ExtensionState { |
|
akalin
2011/06/09 23:44:39
Move this to private section
braffert
2011/06/10 01:23:58
Done.
| |
| 24 | 24 ExtensionState(); |
| 25 ~ExtensionState(); | |
| 26 enum EnabledState { DISABLED, PENDING, ENABLED }; | |
| 27 bool Equals(const ExtensionState &other) const; | |
| 28 EnabledState enabled_state; | |
| 29 bool incognito_enabled; | |
| 30 }; | |
| 25 typedef std::map<std::string, ExtensionState> ExtensionStateMap; | 31 typedef std::map<std::string, ExtensionState> ExtensionStateMap; |
| 26 | 32 |
| 27 LiveSyncExtensionHelper(); | 33 LiveSyncExtensionHelper(); |
| 28 ~LiveSyncExtensionHelper(); | 34 ~LiveSyncExtensionHelper(); |
| 29 | 35 |
| 30 // Returns a generated extension ID for the given name. | 36 // Returns a generated extension ID for the given name. |
| 31 static std::string NameToId(const std::string& name); | 37 static std::string NameToId(const std::string& name); |
| 32 | 38 |
| 33 // Initializes the profiles in |test| and registers them with | 39 // Initializes the profiles in |test| and registers them with |
| 34 // internal data structures. | 40 // internal data structures. |
| 35 void Setup(LiveSyncTest* test); | 41 void Setup(LiveSyncTest* test); |
| 36 | 42 |
| 37 // Installs the extension with the given name to |profile|. | 43 // Installs the extension with the given name to |profile|. |
| 38 void InstallExtension( | 44 void InstallExtension( |
| 39 Profile* profile, const std::string& name, Extension::Type type); | 45 Profile* profile, const std::string& name, Extension::Type type); |
| 40 | 46 |
| 41 // Uninstalls the extension with the given name from |profile|. | 47 // Uninstalls the extension with the given name from |profile|. |
| 42 void UninstallExtension(Profile* profile, const std::string& name); | 48 void UninstallExtension(Profile* profile, const std::string& name); |
| 43 | 49 |
| 50 // Enables the extension with the given name on |profile|. | |
| 51 void EnableExtension(Profile* profile, const std::string& name); | |
| 52 | |
| 53 // Disables the extension with the given name on |profile|. | |
| 54 void DisableExtension(Profile* profile, const std::string& name); | |
| 55 | |
| 56 // Enables the extension with the given name to run in incognito mode | |
| 57 void IncognitoEnableExtension(Profile* profile, const std::string& name); | |
| 58 | |
| 59 // Disables the extension with the given name from running in incognito mode | |
| 60 void IncognitoDisableExtension(Profile* profile, const std::string& name); | |
| 61 | |
| 44 // Returns true iff the extension with the given id is pending | 62 // Returns true iff the extension with the given id is pending |
| 45 // install in |profile|. | 63 // install in |profile|. |
| 46 bool IsExtensionPendingInstallForSync( | 64 bool IsExtensionPendingInstallForSync( |
| 47 Profile* profile, const std::string& id) const; | 65 Profile* profile, const std::string& id) const; |
| 48 | 66 |
| 49 // Installs all extensions pending sync in |profile| of the given | 67 // Installs all extensions pending sync in |profile| of the given |
| 50 // type. | 68 // type. |
| 51 void InstallExtensionsPendingForSync(Profile* profile, Extension::Type type); | 69 void InstallExtensionsPendingForSync(Profile* profile, Extension::Type type); |
| 52 | 70 |
| 53 // Returns a map from |profile|'s installed extensions to their | 71 // Returns a map from |profile|'s installed extensions to their |
|
akalin
2011/06/09 23:44:39
Move this to private section
braffert
2011/06/10 01:23:58
Done.
| |
| 54 // state. | 72 // state. |
| 55 ExtensionStateMap GetExtensionStates(Profile* profile) const; | 73 ExtensionStateMap GetExtensionStates(Profile* profile) const; |
| 56 | 74 |
| 75 // Returns true iff |profile1| and |profile2|'s extensions state maps match | |
| 76 bool ExtensionStateMapsMatch(Profile* profile1, Profile* profile2); | |
|
akalin
2011/06/09 23:44:39
Name this something like ExtensionStatesMatch().
braffert
2011/06/10 01:23:58
Done.
| |
| 77 | |
| 57 private: | 78 private: |
| 58 typedef std::map<std::string, scoped_refptr<Extension> > ExtensionNameMap; | 79 typedef std::map<std::string, scoped_refptr<Extension> > ExtensionNameMap; |
| 59 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap; | 80 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap; |
| 60 typedef std::map<std::string, std::string> StringMap; | 81 typedef std::map<std::string, std::string> StringMap; |
| 61 | 82 |
| 62 // Initializes extensions for |profile| and creates an entry in | 83 // Initializes extensions for |profile| and creates an entry in |
| 63 // |profile_extensions_| for it. | 84 // |profile_extensions_| for it. |
| 64 void SetupProfile(Profile* profile); | 85 void SetupProfile(Profile* profile); |
| 65 | 86 |
| 66 // Returns an extension for the given name in |profile|. type and | 87 // Returns an extension for the given name in |profile|. type and |
| 67 // index. Two extensions with the name but different profiles will | 88 // index. Two extensions with the name but different profiles will |
| 68 // have the same id. | 89 // have the same id. |
| 69 scoped_refptr<Extension> GetExtension( | 90 scoped_refptr<Extension> GetExtension( |
| 70 Profile* profile, const std::string& name, | 91 Profile* profile, const std::string& name, |
| 71 Extension::Type type) WARN_UNUSED_RESULT; | 92 Extension::Type type) WARN_UNUSED_RESULT; |
| 72 | 93 |
| 73 ProfileExtensionNameMap profile_extensions_; | 94 ProfileExtensionNameMap profile_extensions_; |
| 74 StringMap id_to_name_; | 95 StringMap id_to_name_; |
| 75 | 96 |
| 76 DISALLOW_COPY_AND_ASSIGN(LiveSyncExtensionHelper); | 97 DISALLOW_COPY_AND_ASSIGN(LiveSyncExtensionHelper); |
| 77 }; | 98 }; |
| 78 | 99 |
| 79 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ | 100 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ |
| OLD | NEW |