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 { |
| 24 | 24 enum EnabledState { DISABLED, PENDING, ENABLED }; |
| 25 bool operator==(const ExtensionState &other) const; | |
|
akalin
2011/06/09 20:35:37
Do you need this? If so, operator overloading is
braffert
2011/06/09 23:09:35
Done. This required some additional changes, beca
| |
| 26 EnabledState enabled_state; | |
|
akalin
2011/06/09 20:35:37
please define a default constructor to set these v
braffert
2011/06/09 23:09:35
Done.
| |
| 27 bool incognito_enabled; | |
| 28 }; | |
| 25 typedef std::map<std::string, ExtensionState> ExtensionStateMap; | 29 typedef std::map<std::string, ExtensionState> ExtensionStateMap; |
| 26 | 30 |
| 27 LiveSyncExtensionHelper(); | 31 LiveSyncExtensionHelper(); |
| 28 ~LiveSyncExtensionHelper(); | 32 ~LiveSyncExtensionHelper(); |
| 29 | 33 |
| 30 // Returns a generated extension ID for the given name. | 34 // Returns a generated extension ID for the given name. |
| 31 static std::string NameToId(const std::string& name); | 35 static std::string NameToId(const std::string& name); |
| 32 | 36 |
| 33 // Initializes the profiles in |test| and registers them with | 37 // Initializes the profiles in |test| and registers them with |
| 34 // internal data structures. | 38 // internal data structures. |
| 35 void Setup(LiveSyncTest* test); | 39 void Setup(LiveSyncTest* test); |
| 36 | 40 |
| 37 // Installs the extension with the given name to |profile|. | 41 // Installs the extension with the given name to |profile|. |
| 38 void InstallExtension( | 42 void InstallExtension( |
| 39 Profile* profile, const std::string& name, Extension::Type type); | 43 Profile* profile, const std::string& name, Extension::Type type); |
| 40 | 44 |
| 41 // Uninstalls the extension with the given name from |profile|. | 45 // Uninstalls the extension with the given name from |profile|. |
| 42 void UninstallExtension(Profile* profile, const std::string& name); | 46 void UninstallExtension(Profile* profile, const std::string& name); |
| 43 | 47 |
| 48 // Enables the extension with the given name on |profile|. | |
| 49 void EnableExtension(Profile* profile, const std::string& name); | |
| 50 | |
| 51 // Disables the extension with the given name on |profile|. | |
| 52 void DisableExtension(Profile* profile, const std::string& name); | |
| 53 | |
| 54 // Enables the extension with the given name to run in incognito mode | |
| 55 void IncognitoEnableExtension(Profile* profile, const std::string& name); | |
| 56 | |
| 57 // Disables the extension with the given name from running in incognito mode | |
| 58 void IncognitoDisableExtension(Profile* profile, const std::string& name); | |
| 59 | |
| 44 // Returns true iff the extension with the given id is pending | 60 // Returns true iff the extension with the given id is pending |
| 45 // install in |profile|. | 61 // install in |profile|. |
| 46 bool IsExtensionPendingInstallForSync( | 62 bool IsExtensionPendingInstallForSync( |
| 47 Profile* profile, const std::string& id) const; | 63 Profile* profile, const std::string& id) const; |
| 48 | 64 |
| 49 // Installs all extensions pending sync in |profile| of the given | 65 // Installs all extensions pending sync in |profile| of the given |
| 50 // type. | 66 // type. |
| 51 void InstallExtensionsPendingForSync(Profile* profile, Extension::Type type); | 67 void InstallExtensionsPendingForSync(Profile* profile, Extension::Type type); |
| 52 | 68 |
| 53 // Returns a map from |profile|'s installed extensions to their | 69 // Returns a map from |profile|'s installed extensions to their |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 70 Profile* profile, const std::string& name, | 86 Profile* profile, const std::string& name, |
| 71 Extension::Type type) WARN_UNUSED_RESULT; | 87 Extension::Type type) WARN_UNUSED_RESULT; |
| 72 | 88 |
| 73 ProfileExtensionNameMap profile_extensions_; | 89 ProfileExtensionNameMap profile_extensions_; |
| 74 StringMap id_to_name_; | 90 StringMap id_to_name_; |
| 75 | 91 |
| 76 DISALLOW_COPY_AND_ASSIGN(LiveSyncExtensionHelper); | 92 DISALLOW_COPY_AND_ASSIGN(LiveSyncExtensionHelper); |
| 77 }; | 93 }; |
| 78 | 94 |
| 79 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ | 95 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ |
| OLD | NEW |