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

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

Issue 7104072: Adding new extension sync integration tests. Also modified the way that profile (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: More review changes Created 9 years, 6 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_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 };
24
25 typedef std::map<std::string, ExtensionState> ExtensionStateMap;
26
27 LiveSyncExtensionHelper(); 23 LiveSyncExtensionHelper();
28 ~LiveSyncExtensionHelper(); 24 ~LiveSyncExtensionHelper();
29 25
30 // Returns a generated extension ID for the given name. 26 // Returns a generated extension ID for the given name.
31 static std::string NameToId(const std::string& name); 27 static std::string NameToId(const std::string& name);
32 28
33 // Initializes the profiles in |test| and registers them with 29 // Initializes the profiles in |test| and registers them with
34 // internal data structures. 30 // internal data structures.
35 void Setup(LiveSyncTest* test); 31 void Setup(LiveSyncTest* test);
36 32
37 // Installs the extension with the given name to |profile|. 33 // Installs the extension with the given name to |profile|.
38 void InstallExtension( 34 void InstallExtension(
39 Profile* profile, const std::string& name, Extension::Type type); 35 Profile* profile, const std::string& name, Extension::Type type);
40 36
41 // Uninstalls the extension with the given name from |profile|. 37 // Uninstalls the extension with the given name from |profile|.
42 void UninstallExtension(Profile* profile, const std::string& name); 38 void UninstallExtension(Profile* profile, const std::string& name);
43 39
40 // Enables the extension with the given name on |profile|.
41 void EnableExtension(Profile* profile, const std::string& name);
42
43 // Disables the extension with the given name on |profile|.
44 void DisableExtension(Profile* profile, const std::string& name);
45
46 // Enables the extension with the given name to run in incognito mode
47 void IncognitoEnableExtension(Profile* profile, const std::string& name);
48
49 // Disables the extension with the given name from running in incognito mode
50 void IncognitoDisableExtension(Profile* profile, const std::string& name);
51
44 // Returns true iff the extension with the given id is pending 52 // Returns true iff the extension with the given id is pending
45 // install in |profile|. 53 // install in |profile|.
46 bool IsExtensionPendingInstallForSync( 54 bool IsExtensionPendingInstallForSync(
47 Profile* profile, const std::string& id) const; 55 Profile* profile, const std::string& id) const;
48 56
49 // Installs all extensions pending sync in |profile| of the given 57 // Installs all extensions pending sync in |profile| of the given
50 // type. 58 // type.
51 void InstallExtensionsPendingForSync(Profile* profile, Extension::Type type); 59 void InstallExtensionsPendingForSync(Profile* profile, Extension::Type type);
52 60
53 // Returns a map from |profile|'s installed extensions to their 61 // Returns true iff |profile1| and |profile2| have the same extensions and
54 // state. 62 // they are all in the same state.
55 ExtensionStateMap GetExtensionStates(Profile* profile) const; 63 static bool ExtensionStatesMatch(Profile* profile1, Profile* profile2);
56 64
57 private: 65 private:
66 struct ExtensionState {
67 enum EnabledState { DISABLED, PENDING, ENABLED };
68
69 ExtensionState();
70 ~ExtensionState();
71 bool Equals(const ExtensionState &other) const;
72
73 EnabledState enabled_state;
74 bool incognito_enabled;
75 };
76
77 typedef std::map<std::string, ExtensionState> ExtensionStateMap;
58 typedef std::map<std::string, scoped_refptr<Extension> > ExtensionNameMap; 78 typedef std::map<std::string, scoped_refptr<Extension> > ExtensionNameMap;
59 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap; 79 typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap;
60 typedef std::map<std::string, std::string> StringMap; 80 typedef std::map<std::string, std::string> StringMap;
61 81
82 // Returns a map from |profile|'s installed extensions to their state.
83 static ExtensionStateMap GetExtensionStates(Profile* profile);
84
62 // Initializes extensions for |profile| and creates an entry in 85 // Initializes extensions for |profile| and creates an entry in
63 // |profile_extensions_| for it. 86 // |profile_extensions_| for it.
64 void SetupProfile(Profile* profile); 87 void SetupProfile(Profile* profile);
65 88
66 // Returns an extension for the given name in |profile|. type and 89 // Returns an extension for the given name in |profile|. type and
67 // index. Two extensions with the name but different profiles will 90 // index. Two extensions with the name but different profiles will
68 // have the same id. 91 // have the same id.
69 scoped_refptr<Extension> GetExtension( 92 scoped_refptr<Extension> GetExtension(
70 Profile* profile, const std::string& name, 93 Profile* profile, const std::string& name,
71 Extension::Type type) WARN_UNUSED_RESULT; 94 Extension::Type type) WARN_UNUSED_RESULT;
72 95
73 ProfileExtensionNameMap profile_extensions_; 96 ProfileExtensionNameMap profile_extensions_;
74 StringMap id_to_name_; 97 StringMap id_to_name_;
75 98
76 DISALLOW_COPY_AND_ASSIGN(LiveSyncExtensionHelper); 99 DISALLOW_COPY_AND_ASSIGN(LiveSyncExtensionHelper);
77 }; 100 };
78 101
79 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_EXTENSION_HELPER_H_ 102 #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