Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: chrome/browser/sync/test/integration/sync_extension_helper.h

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
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 "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/manifest.h"
17 18
18 class Profile; 19 class Profile;
19 class SyncTest; 20 class SyncTest;
20 21
21 namespace extensions {
22 class Extension;
23 }
24
25 class SyncExtensionHelper { 22 class SyncExtensionHelper {
26 public: 23 public:
27 // Singleton implementation. 24 // Singleton implementation.
28 static SyncExtensionHelper* GetInstance(); 25 static SyncExtensionHelper* GetInstance();
29 26
30 // Returns a generated extension ID for the given name. 27 // Returns a generated extension ID for the given name.
31 static std::string NameToId(const std::string& name); 28 static std::string NameToId(const std::string& name);
32 29
33 // Initializes the profiles in |test| and registers them with 30 // Initializes the profiles in |test| and registers them with
34 // internal data structures. 31 // internal data structures.
35 void SetupIfNecessary(SyncTest* test); 32 void SetupIfNecessary(SyncTest* test);
36 33
37 // Installs the extension with the given name to |profile|, and returns the 34 // Installs the extension with the given name to |profile|, and returns the
38 // extension ID of the new extension. 35 // extension ID of the new extension.
39 std::string InstallExtension(Profile* profile, 36 std::string InstallExtension(Profile* profile,
40 const std::string& name, 37 const std::string& name,
41 extensions::Extension::Type type); 38 extensions::Manifest::Type type);
42 39
43 // Uninstalls the extension with the given name from |profile|. 40 // Uninstalls the extension with the given name from |profile|.
44 void UninstallExtension(Profile* profile, const std::string& name); 41 void UninstallExtension(Profile* profile, const std::string& name);
45 42
46 // Returns a vector containing the names of all currently installed extensions 43 // Returns a vector containing the names of all currently installed extensions
47 // on |profile|. 44 // on |profile|.
48 std::vector<std::string> GetInstalledExtensionNames(Profile* profile) const; 45 std::vector<std::string> GetInstalledExtensionNames(Profile* profile) const;
49 46
50 // Enables the extension with the given name on |profile|. 47 // Enables the extension with the given name on |profile|.
51 void EnableExtension(Profile* profile, const std::string& name); 48 void EnableExtension(Profile* profile, const std::string& name);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 85
89 EnabledState enabled_state; 86 EnabledState enabled_state;
90 bool incognito_enabled; 87 bool incognito_enabled;
91 }; 88 };
92 89
93 typedef std::map<std::string, ExtensionState> ExtensionStateMap; 90 typedef std::map<std::string, ExtensionState> ExtensionStateMap;
94 typedef std::map<std::string, scoped_refptr<extensions::Extension> > 91 typedef std::map<std::string, scoped_refptr<extensions::Extension> >
95 ExtensionNameMap; 92 ExtensionNameMap;
96 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap; 93 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap;
97 typedef std::map<std::string, std::string> StringMap; 94 typedef std::map<std::string, std::string> StringMap;
98 typedef std::map<std::string, extensions::Extension::Type> TypeMap; 95 typedef std::map<std::string, extensions::Manifest::Type> TypeMap;
99 96
100 friend struct DefaultSingletonTraits<SyncExtensionHelper>; 97 friend struct DefaultSingletonTraits<SyncExtensionHelper>;
101 98
102 SyncExtensionHelper(); 99 SyncExtensionHelper();
103 ~SyncExtensionHelper(); 100 ~SyncExtensionHelper();
104 101
105 // Returns a map from |profile|'s installed extensions to their state. 102 // Returns a map from |profile|'s installed extensions to their state.
106 static ExtensionStateMap GetExtensionStates(Profile* profile); 103 static ExtensionStateMap GetExtensionStates(Profile* profile);
107 104
108 // Initializes extensions for |profile| and creates an entry in 105 // Initializes extensions for |profile| and creates an entry in
109 // |profile_extensions_| for it. 106 // |profile_extensions_| for it.
110 void SetupProfile(Profile* profile); 107 void SetupProfile(Profile* profile);
111 108
112 // Returns an extension for the given name in |profile|. type and 109 // Returns an extension for the given name in |profile|. type and
113 // index. Two extensions with the name but different profiles will 110 // index. Two extensions with the name but different profiles will
114 // have the same id. 111 // have the same id.
115 scoped_refptr<extensions::Extension> GetExtension( 112 scoped_refptr<extensions::Extension> GetExtension(
116 Profile* profile, const std::string& name, 113 Profile* profile, const std::string& name,
117 extensions::Extension::Type type) WARN_UNUSED_RESULT; 114 extensions::Manifest::Type type) WARN_UNUSED_RESULT;
118 115
119 ProfileExtensionNameMap profile_extensions_; 116 ProfileExtensionNameMap profile_extensions_;
120 StringMap id_to_name_; 117 StringMap id_to_name_;
121 TypeMap id_to_type_; 118 TypeMap id_to_type_;
122 bool setup_completed_; 119 bool setup_completed_;
123 120
124 DISALLOW_COPY_AND_ASSIGN(SyncExtensionHelper); 121 DISALLOW_COPY_AND_ASSIGN(SyncExtensionHelper);
125 }; 122 };
126 123
127 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_HELPER_H_ 124 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698