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

Side by Side Diff: chrome/test/live_sync/live_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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_
6 #define CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11 #include <vector>
12
13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
15 #include "base/memory/ref_counted.h"
16 #include "chrome/common/extensions/extension.h"
17
18 class Extension;
19 class LiveSyncTest;
20 class Profile;
21
22 class LiveSyncExtensionHelper {
23 public:
24 LiveSyncExtensionHelper();
25 ~LiveSyncExtensionHelper();
26
27 // Returns a generated extension ID for the given name.
28 static std::string NameToId(const std::string& name);
29
30 // Initializes the profiles in |test| and registers them with
31 // internal data structures.
32 void Setup(LiveSyncTest* test);
33
34 // Installs the extension with the given name to |profile|.
35 void InstallExtension(
36 Profile* profile, const std::string& name, Extension::Type type);
37
38 // Uninstalls the extension with the given name from |profile|.
39 void UninstallExtension(Profile* profile, const std::string& name);
40
41 // Returns a vector containing the names of all currently installed extensions
42 // on |profile|.
43 std::vector<std::string> GetInstalledExtensionNames(Profile* profile) const;
44
45 // Enables the extension with the given name on |profile|.
46 void EnableExtension(Profile* profile, const std::string& name);
47
48 // Disables the extension with the given name on |profile|.
49 void DisableExtension(Profile* profile, const std::string& name);
50
51 // Returns true if the extension with the given name is enabled on |profile|.
52 bool IsExtensionEnabled(Profile* profile, const std::string& name) const;
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
60 // Returns true iff the extension is enabled in incognito mode on |profile|.
61 bool IsIncognitoEnabled(Profile* profile, const std::string& name) const;
62
63 // Returns true iff the extension with the given id is pending
64 // install in |profile|.
65 bool IsExtensionPendingInstallForSync(
66 Profile* profile, const std::string& id) const;
67
68 // Installs all extensions pending sync in |profile| of the given
69 // type.
70 void InstallExtensionsPendingForSync(Profile* profile, Extension::Type type);
71
72 // Returns true iff |profile1| and |profile2| have the same extensions and
73 // they are all in the same state.
74 static bool ExtensionStatesMatch(Profile* profile1, Profile* profile2);
75
76 private:
77 struct ExtensionState {
78 enum EnabledState { DISABLED, PENDING, ENABLED };
79
80 ExtensionState();
81 ~ExtensionState();
82 bool Equals(const ExtensionState &other) const;
83
84 EnabledState enabled_state;
85 bool incognito_enabled;
86 };
87
88 typedef std::map<std::string, ExtensionState> ExtensionStateMap;
89 typedef std::map<std::string, scoped_refptr<Extension> > ExtensionNameMap;
90 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap;
91 typedef std::map<std::string, std::string> StringMap;
92
93 // Returns a map from |profile|'s installed extensions to their state.
94 static ExtensionStateMap GetExtensionStates(Profile* profile);
95
96 // Initializes extensions for |profile| and creates an entry in
97 // |profile_extensions_| for it.
98 void SetupProfile(Profile* profile);
99
100 // Returns an extension for the given name in |profile|. type and
101 // index. Two extensions with the name but different profiles will
102 // have the same id.
103 scoped_refptr<Extension> GetExtension(
104 Profile* profile, const std::string& name,
105 Extension::Type type) WARN_UNUSED_RESULT;
106
107 ProfileExtensionNameMap profile_extensions_;
108 StringMap id_to_name_;
109
110 DISALLOW_COPY_AND_ASSIGN(LiveSyncExtensionHelper);
111 };
112
113 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/test/live_sync/live_extensions_sync_test.cc ('k') | chrome/test/live_sync/live_sync_extension_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698