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

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

Issue 9595001: Apps on NTP should be in order of installation (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: ExtensionInstallUI -> ExtensionInstallPrompt Created 8 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
« no previous file with comments | « chrome/browser/sync/test/integration/sync_app_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" 5 #include "chrome/browser/sync/test/integration/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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 bool SyncExtensionHelper::IsIncognitoEnabled( 125 bool SyncExtensionHelper::IsIncognitoEnabled(
126 Profile* profile, const std::string& name) const { 126 Profile* profile, const std::string& name) const {
127 return profile->GetExtensionService()->IsIncognitoEnabled(NameToId(name)); 127 return profile->GetExtensionService()->IsIncognitoEnabled(NameToId(name));
128 } 128 }
129 129
130 130
131 bool SyncExtensionHelper::IsExtensionPendingInstallForSync( 131 bool SyncExtensionHelper::IsExtensionPendingInstallForSync(
132 Profile* profile, const std::string& id) const { 132 Profile* profile, const std::string& id) const {
133 const PendingExtensionManager* pending_extension_manager = 133 const PendingExtensionManager* pending_extension_manager =
134 profile->GetExtensionService()->pending_extension_manager(); 134 profile->GetExtensionService()->pending_extension_manager();
135 PendingExtensionInfo info; 135 const PendingExtensionInfo* info = pending_extension_manager->GetById(id);
136 if (!pending_extension_manager->GetById(id, &info)) { 136 if (!info)
137 return false; 137 return false;
138 } 138 return info->is_from_sync();
139 return info.is_from_sync();
140 } 139 }
141 140
142 void SyncExtensionHelper::InstallExtensionsPendingForSync( 141 void SyncExtensionHelper::InstallExtensionsPendingForSync(
143 Profile* profile, Extension::Type type) { 142 Profile* profile, Extension::Type type) {
144 // TODO(akalin): Mock out the servers that the extensions auto-update 143 // TODO(akalin): Mock out the servers that the extensions auto-update
145 // mechanism talk to so as to more closely match what actually happens. 144 // mechanism talk to so as to more closely match what actually happens.
146 // Background networking will need to be re-enabled for extensions tests. 145 // Background networking will need to be re-enabled for extensions tests.
147 146
148 // We make a copy here since InstallExtension() removes the 147 // We make a copy here since InstallExtension() removes the
149 // extension from the extensions service's copy. 148 // extension from the extensions service's copy.
150 const PendingExtensionManager* pending_extension_manager = 149 const PendingExtensionManager* pending_extension_manager =
151 profile->GetExtensionService()->pending_extension_manager(); 150 profile->GetExtensionService()->pending_extension_manager();
152 151
153 std::set<std::string> pending_crx_ids; 152 std::list<std::string> pending_crx_ids;
154 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids); 153 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids);
155 154
156 std::set<std::string>::const_iterator id; 155 std::list<std::string>::const_iterator iter;
157 PendingExtensionInfo info; 156 const PendingExtensionInfo* info = NULL;
158 for (id = pending_crx_ids.begin(); id != pending_crx_ids.end(); ++id) { 157 for (iter = pending_crx_ids.begin(); iter != pending_crx_ids.end(); ++iter) {
159 ASSERT_TRUE(pending_extension_manager->GetById(*id, &info)); 158 ASSERT_TRUE((info = pending_extension_manager->GetById(*iter)));
160 if (!info.is_from_sync()) 159 if (!info->is_from_sync())
161 continue; 160 continue;
162 161
163 StringMap::const_iterator it2 = id_to_name_.find(*id); 162 StringMap::const_iterator iter2 = id_to_name_.find(*iter);
164 if (it2 == id_to_name_.end()) { 163 if (iter2 == id_to_name_.end()) {
165 ADD_FAILURE() << "Could not get name for id " << *id 164 ADD_FAILURE() << "Could not get name for id " << *iter
166 << " (profile = " << profile->GetDebugName() << ")"; 165 << " (profile = " << profile->GetDebugName() << ")";
167 continue; 166 continue;
168 } 167 }
169 InstallExtension(profile, it2->second, type); 168 InstallExtension(profile, iter2->second, type);
170 } 169 }
171 } 170 }
172 171
173 SyncExtensionHelper::ExtensionStateMap 172 SyncExtensionHelper::ExtensionStateMap
174 SyncExtensionHelper::GetExtensionStates(Profile* profile) { 173 SyncExtensionHelper::GetExtensionStates(Profile* profile) {
175 const std::string& profile_debug_name = profile->GetDebugName(); 174 const std::string& profile_debug_name = profile->GetDebugName();
176 175
177 ExtensionStateMap extension_state_map; 176 ExtensionStateMap extension_state_map;
178 177
179 ExtensionService* extension_service = profile->GetExtensionService(); 178 ExtensionService* extension_service = profile->GetExtensionService();
(...skipping 12 matching lines...) Expand all
192 191
193 DVLOG(2) << "Extension " << (*it)->id() << " in profile " 192 DVLOG(2) << "Extension " << (*it)->id() << " in profile "
194 << profile_debug_name << " is " 193 << profile_debug_name << " is "
195 << (extension_service->IsExtensionEnabled(id) ? 194 << (extension_service->IsExtensionEnabled(id) ?
196 "enabled" : "disabled"); 195 "enabled" : "disabled");
197 } 196 }
198 197
199 const PendingExtensionManager* pending_extension_manager = 198 const PendingExtensionManager* pending_extension_manager =
200 extension_service->pending_extension_manager(); 199 extension_service->pending_extension_manager();
201 200
202 std::set<std::string> pending_crx_ids; 201 std::list<std::string> pending_crx_ids;
203 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids); 202 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids);
204 203
205 std::set<std::string>::const_iterator id; 204 std::list<std::string>::const_iterator id;
206 for (id = pending_crx_ids.begin(); id != pending_crx_ids.end(); ++id) { 205 for (id = pending_crx_ids.begin(); id != pending_crx_ids.end(); ++id) {
207 extension_state_map[*id].enabled_state = ExtensionState::PENDING; 206 extension_state_map[*id].enabled_state = ExtensionState::PENDING;
208 extension_state_map[*id].incognito_enabled = 207 extension_state_map[*id].incognito_enabled =
209 extension_service->IsIncognitoEnabled(*id); 208 extension_service->IsIncognitoEnabled(*id);
210 DVLOG(2) << "Extension " << *id << " in profile " 209 DVLOG(2) << "Extension " << *id << " in profile "
211 << profile_debug_name << " is pending"; 210 << profile_debug_name << " is pending";
212 } 211 }
213 212
214 return extension_state_map; 213 return extension_state_map;
215 } 214 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 if (extension->id() != expected_id) { 346 if (extension->id() != expected_id) {
348 EXPECT_EQ(expected_id, extension->id()); 347 EXPECT_EQ(expected_id, extension->id());
349 return NULL; 348 return NULL;
350 } 349 }
351 DVLOG(2) << "created extension with name = " 350 DVLOG(2) << "created extension with name = "
352 << name << ", id = " << expected_id; 351 << name << ", id = " << expected_id;
353 (it->second)[name] = extension; 352 (it->second)[name] = extension;
354 id_to_name_[expected_id] = name; 353 id_to_name_[expected_id] = name;
355 return extension; 354 return extension;
356 } 355 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_app_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698