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

Side by Side Diff: chrome/test/live_sync/sync_extension_helper.h

Issue 7599019: Allow sync integration tests to operate on multiple datatypes: Apps, Extensions, Themes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix indents Created 9 years, 4 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) 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_SYNC_EXTENSION_HELPER_H_
6 #define CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ 6 #define CHROME_TEST_LIVE_SYNC_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 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/singleton.h"
16 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
17 18
18 class Extension; 19 class Extension;
19 class LiveSyncTest; 20 class LiveSyncTest;
20 class Profile; 21 class Profile;
21 22
22 class LiveSyncExtensionHelper { 23 class SyncExtensionHelper {
23 public: 24 public:
24 LiveSyncExtensionHelper(); 25 // Singleton implementation.
25 ~LiveSyncExtensionHelper(); 26 static SyncExtensionHelper* GetInstance();
26 27
27 // Returns a generated extension ID for the given name. 28 // Returns a generated extension ID for the given name.
28 static std::string NameToId(const std::string& name); 29 static std::string NameToId(const std::string& name);
29 30
30 // Initializes the profiles in |test| and registers them with 31 // Initializes the profiles in |test| and registers them with
31 // internal data structures. 32 // internal data structures.
32 void Setup(LiveSyncTest* test); 33 void SetupIfNecessary(LiveSyncTest* test);
33 34
34 // Installs the extension with the given name to |profile|. 35 // Installs the extension with the given name to |profile|.
35 void InstallExtension( 36 void InstallExtension(
36 Profile* profile, const std::string& name, Extension::Type type); 37 Profile* profile, const std::string& name, Extension::Type type);
37 38
38 // Uninstalls the extension with the given name from |profile|. 39 // Uninstalls the extension with the given name from |profile|.
39 void UninstallExtension(Profile* profile, const std::string& name); 40 void UninstallExtension(Profile* profile, const std::string& name);
40 41
41 // Returns a vector containing the names of all currently installed extensions 42 // Returns a vector containing the names of all currently installed extensions
42 // on |profile|. 43 // on |profile|.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 84
84 EnabledState enabled_state; 85 EnabledState enabled_state;
85 bool incognito_enabled; 86 bool incognito_enabled;
86 }; 87 };
87 88
88 typedef std::map<std::string, ExtensionState> ExtensionStateMap; 89 typedef std::map<std::string, ExtensionState> ExtensionStateMap;
89 typedef std::map<std::string, scoped_refptr<Extension> > ExtensionNameMap; 90 typedef std::map<std::string, scoped_refptr<Extension> > ExtensionNameMap;
90 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap; 91 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap;
91 typedef std::map<std::string, std::string> StringMap; 92 typedef std::map<std::string, std::string> StringMap;
92 93
94 friend struct DefaultSingletonTraits<SyncExtensionHelper>;
95
96 SyncExtensionHelper();
97 ~SyncExtensionHelper();
98
93 // Returns a map from |profile|'s installed extensions to their state. 99 // Returns a map from |profile|'s installed extensions to their state.
94 static ExtensionStateMap GetExtensionStates(Profile* profile); 100 static ExtensionStateMap GetExtensionStates(Profile* profile);
95 101
96 // Initializes extensions for |profile| and creates an entry in 102 // Initializes extensions for |profile| and creates an entry in
97 // |profile_extensions_| for it. 103 // |profile_extensions_| for it.
98 void SetupProfile(Profile* profile); 104 void SetupProfile(Profile* profile);
99 105
100 // Returns an extension for the given name in |profile|. type and 106 // Returns an extension for the given name in |profile|. type and
101 // index. Two extensions with the name but different profiles will 107 // index. Two extensions with the name but different profiles will
102 // have the same id. 108 // have the same id.
103 scoped_refptr<Extension> GetExtension( 109 scoped_refptr<Extension> GetExtension(
104 Profile* profile, const std::string& name, 110 Profile* profile, const std::string& name,
105 Extension::Type type) WARN_UNUSED_RESULT; 111 Extension::Type type) WARN_UNUSED_RESULT;
106 112
107 ProfileExtensionNameMap profile_extensions_; 113 ProfileExtensionNameMap profile_extensions_;
108 StringMap id_to_name_; 114 StringMap id_to_name_;
115 bool setup_completed_;
109 116
110 DISALLOW_COPY_AND_ASSIGN(LiveSyncExtensionHelper); 117 DISALLOW_COPY_AND_ASSIGN(SyncExtensionHelper);
111 }; 118 };
112 119
113 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ 120 #endif // CHROME_TEST_LIVE_SYNC_SYNC_EXTENSION_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/test/live_sync/single_client_themes_sync_test.cc ('k') | chrome/test/live_sync/sync_extension_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698