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

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

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: Fixed lint error - misplaced comma 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 #include "chrome/test/live_sync/live_sync_extension_helper.h" 5 #include "chrome/test/live_sync/live_sync_extension_helper.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 30 matching lines...) Expand all
41 << " (profile = " << profile << ")"; 41 << " (profile = " << profile << ")";
42 profile->GetExtensionService()->OnExtensionInstalled(extension); 42 profile->GetExtensionService()->OnExtensionInstalled(extension);
43 } 43 }
44 44
45 void LiveSyncExtensionHelper::UninstallExtension( 45 void LiveSyncExtensionHelper::UninstallExtension(
46 Profile* profile, const std::string& name) { 46 Profile* profile, const std::string& name) {
47 ExtensionService::UninstallExtensionHelper(profile->GetExtensionService(), 47 ExtensionService::UninstallExtensionHelper(profile->GetExtensionService(),
48 NameToId(name)); 48 NameToId(name));
49 } 49 }
50 50
51 void LiveSyncExtensionHelper::EnableExtension(Profile* profile,
52 const std::string& name) {
53 profile->GetExtensionService()->EnableExtension(NameToId(name));
54 }
55
56 void LiveSyncExtensionHelper::DisableExtension(Profile* profile,
57 const std::string& name) {
58 profile->GetExtensionService()->DisableExtension(NameToId(name));
59 }
60
61 void LiveSyncExtensionHelper::IncognitoEnableExtension(
62 Profile* profile, const std::string& name) {
63 profile->GetExtensionService()->SetIsIncognitoEnabled(NameToId(name), true);
64 }
65
66 void LiveSyncExtensionHelper::IncognitoDisableExtension(
67 Profile* profile, const std::string& name) {
68 profile->GetExtensionService()->SetIsIncognitoEnabled(NameToId(name), false);
69 }
70
51 bool LiveSyncExtensionHelper::IsExtensionPendingInstallForSync( 71 bool LiveSyncExtensionHelper::IsExtensionPendingInstallForSync(
52 Profile* profile, const std::string& id) const { 72 Profile* profile, const std::string& id) const {
53 const PendingExtensionManager* pending_extension_manager = 73 const PendingExtensionManager* pending_extension_manager =
54 profile->GetExtensionService()->pending_extension_manager(); 74 profile->GetExtensionService()->pending_extension_manager();
55 PendingExtensionInfo info; 75 PendingExtensionInfo info;
56 if (!pending_extension_manager->GetById(id, &info)) { 76 if (!pending_extension_manager->GetById(id, &info)) {
57 return false; 77 return false;
58 } 78 }
59 return info.is_from_sync(); 79 return info.is_from_sync();
60 } 80 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Profile* profile) const { 113 Profile* profile) const {
94 const std::string& profile_debug_name = profile->GetDebugName(); 114 const std::string& profile_debug_name = profile->GetDebugName();
95 115
96 ExtensionStateMap extension_state_map; 116 ExtensionStateMap extension_state_map;
97 117
98 ExtensionService* extension_service = profile->GetExtensionService(); 118 ExtensionService* extension_service = profile->GetExtensionService();
99 119
100 const ExtensionList* extensions = extension_service->extensions(); 120 const ExtensionList* extensions = extension_service->extensions();
101 for (ExtensionList::const_iterator it = extensions->begin(); 121 for (ExtensionList::const_iterator it = extensions->begin();
102 it != extensions->end(); ++it) { 122 it != extensions->end(); ++it) {
103 extension_state_map[(*it)->id()] = ENABLED; 123 extension_state_map[(*it)->id()].first = ENABLED;
124 if (extension_service->IsIncognitoEnabled((*it)->id())) {
125 extension_state_map[(*it)->id()].second = INCOGNITO_ENABLED;
126 } else {
127 extension_state_map[(*it)->id()].second = INCOGNITO_DISABLED;
128 }
104 VLOG(2) << "Extension " << (*it)->id() << " in profile " 129 VLOG(2) << "Extension " << (*it)->id() << " in profile "
105 << profile_debug_name << " is enabled"; 130 << profile_debug_name << " is enabled";
106 } 131 }
107 132
108 const ExtensionList* disabled_extensions = 133 const ExtensionList* disabled_extensions =
109 extension_service->disabled_extensions(); 134 extension_service->disabled_extensions();
110 for (ExtensionList::const_iterator it = disabled_extensions->begin(); 135 for (ExtensionList::const_iterator it = disabled_extensions->begin();
111 it != disabled_extensions->end(); ++it) { 136 it != disabled_extensions->end(); ++it) {
112 extension_state_map[(*it)->id()] = DISABLED; 137 extension_state_map[(*it)->id()].first = DISABLED;
138 if (extension_service->IsIncognitoEnabled((*it)->id())) {
139 extension_state_map[(*it)->id()].second = INCOGNITO_ENABLED;
140 } else {
141 extension_state_map[(*it)->id()].second = INCOGNITO_DISABLED;
142 }
113 VLOG(2) << "Extension " << (*it)->id() << " in profile " 143 VLOG(2) << "Extension " << (*it)->id() << " in profile "
114 << profile_debug_name << " is disabled"; 144 << profile_debug_name << " is disabled";
115 } 145 }
116 146
117 const PendingExtensionManager* pending_extension_manager = 147 const PendingExtensionManager* pending_extension_manager =
118 extension_service->pending_extension_manager(); 148 extension_service->pending_extension_manager();
119 PendingExtensionManager::const_iterator it; 149 PendingExtensionManager::const_iterator it;
120 for (it = pending_extension_manager->begin(); 150 for (it = pending_extension_manager->begin();
121 it != pending_extension_manager->end(); ++it) { 151 it != pending_extension_manager->end(); ++it) {
122 extension_state_map[it->first] = PENDING; 152 extension_state_map[it->first].first = PENDING;
153 if (extension_service->IsIncognitoEnabled(it->first)) {
154 extension_state_map[it->first].second = INCOGNITO_ENABLED;
155 } else {
156 extension_state_map[it->first].second = INCOGNITO_DISABLED;
157 }
123 VLOG(2) << "Extension " << it->first << " in profile " 158 VLOG(2) << "Extension " << it->first << " in profile "
124 << profile_debug_name << " is pending"; 159 << profile_debug_name << " is pending";
125 } 160 }
126 161
127 return extension_state_map; 162 return extension_state_map;
128 } 163 }
129 164
130 void LiveSyncExtensionHelper::SetupProfile(Profile* profile) { 165 void LiveSyncExtensionHelper::SetupProfile(Profile* profile) {
131 profile->InitExtensions(true); 166 profile->InitExtensions(true);
132 profile_extensions_.insert(make_pair(profile, ExtensionNameMap())); 167 profile_extensions_.insert(make_pair(profile, ExtensionNameMap()));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 if (extension->id() != expected_id) { 267 if (extension->id() != expected_id) {
233 EXPECT_EQ(expected_id, extension->id()); 268 EXPECT_EQ(expected_id, extension->id());
234 return NULL; 269 return NULL;
235 } 270 }
236 VLOG(2) << "created extension with name = " 271 VLOG(2) << "created extension with name = "
237 << name << ", id = " << expected_id; 272 << name << ", id = " << expected_id;
238 (it->second)[name] = extension; 273 (it->second)[name] = extension;
239 id_to_name_[expected_id] = name; 274 id_to_name_[expected_id] = name;
240 return extension; 275 return extension;
241 } 276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698