OLD | NEW |
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
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 extensions::PendingExtensionManager* pending_extension_manager = |
134 profile->GetExtensionService()->pending_extension_manager(); | 134 profile->GetExtensionService()->pending_extension_manager(); |
135 const PendingExtensionInfo* info = pending_extension_manager->GetById(id); | 135 const extensions::PendingExtensionInfo* info = |
| 136 pending_extension_manager->GetById(id); |
136 if (!info) | 137 if (!info) |
137 return false; | 138 return false; |
138 return info->is_from_sync(); | 139 return info->is_from_sync(); |
139 } | 140 } |
140 | 141 |
141 void SyncExtensionHelper::InstallExtensionsPendingForSync( | 142 void SyncExtensionHelper::InstallExtensionsPendingForSync( |
142 Profile* profile, Extension::Type type) { | 143 Profile* profile, Extension::Type type) { |
143 // TODO(akalin): Mock out the servers that the extensions auto-update | 144 // TODO(akalin): Mock out the servers that the extensions auto-update |
144 // mechanism talk to so as to more closely match what actually happens. | 145 // mechanism talk to so as to more closely match what actually happens. |
145 // Background networking will need to be re-enabled for extensions tests. | 146 // Background networking will need to be re-enabled for extensions tests. |
146 | 147 |
147 // We make a copy here since InstallExtension() removes the | 148 // We make a copy here since InstallExtension() removes the |
148 // extension from the extensions service's copy. | 149 // extension from the extensions service's copy. |
149 const PendingExtensionManager* pending_extension_manager = | 150 const extensions::PendingExtensionManager* pending_extension_manager = |
150 profile->GetExtensionService()->pending_extension_manager(); | 151 profile->GetExtensionService()->pending_extension_manager(); |
151 | 152 |
152 std::list<std::string> pending_crx_ids; | 153 std::list<std::string> pending_crx_ids; |
153 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids); | 154 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids); |
154 | 155 |
155 std::list<std::string>::const_iterator iter; | 156 std::list<std::string>::const_iterator iter; |
156 const PendingExtensionInfo* info = NULL; | 157 const extensions::PendingExtensionInfo* info = NULL; |
157 for (iter = pending_crx_ids.begin(); iter != pending_crx_ids.end(); ++iter) { | 158 for (iter = pending_crx_ids.begin(); iter != pending_crx_ids.end(); ++iter) { |
158 ASSERT_TRUE((info = pending_extension_manager->GetById(*iter))); | 159 ASSERT_TRUE((info = pending_extension_manager->GetById(*iter))); |
159 if (!info->is_from_sync()) | 160 if (!info->is_from_sync()) |
160 continue; | 161 continue; |
161 | 162 |
162 StringMap::const_iterator iter2 = id_to_name_.find(*iter); | 163 StringMap::const_iterator iter2 = id_to_name_.find(*iter); |
163 if (iter2 == id_to_name_.end()) { | 164 if (iter2 == id_to_name_.end()) { |
164 ADD_FAILURE() << "Could not get name for id " << *iter | 165 ADD_FAILURE() << "Could not get name for id " << *iter |
165 << " (profile = " << profile->GetDebugName() << ")"; | 166 << " (profile = " << profile->GetDebugName() << ")"; |
166 continue; | 167 continue; |
(...skipping 21 matching lines...) Expand all Loading... |
188 ExtensionState::DISABLED; | 189 ExtensionState::DISABLED; |
189 extension_state_map[id].incognito_enabled = | 190 extension_state_map[id].incognito_enabled = |
190 extension_service->IsIncognitoEnabled(id); | 191 extension_service->IsIncognitoEnabled(id); |
191 | 192 |
192 DVLOG(2) << "Extension " << (*it)->id() << " in profile " | 193 DVLOG(2) << "Extension " << (*it)->id() << " in profile " |
193 << profile_debug_name << " is " | 194 << profile_debug_name << " is " |
194 << (extension_service->IsExtensionEnabled(id) ? | 195 << (extension_service->IsExtensionEnabled(id) ? |
195 "enabled" : "disabled"); | 196 "enabled" : "disabled"); |
196 } | 197 } |
197 | 198 |
198 const PendingExtensionManager* pending_extension_manager = | 199 const extensions::PendingExtensionManager* pending_extension_manager = |
199 extension_service->pending_extension_manager(); | 200 extension_service->pending_extension_manager(); |
200 | 201 |
201 std::list<std::string> pending_crx_ids; | 202 std::list<std::string> pending_crx_ids; |
202 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids); | 203 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids); |
203 | 204 |
204 std::list<std::string>::const_iterator id; | 205 std::list<std::string>::const_iterator id; |
205 for (id = pending_crx_ids.begin(); id != pending_crx_ids.end(); ++id) { | 206 for (id = pending_crx_ids.begin(); id != pending_crx_ids.end(); ++id) { |
206 extension_state_map[*id].enabled_state = ExtensionState::PENDING; | 207 extension_state_map[*id].enabled_state = ExtensionState::PENDING; |
207 extension_state_map[*id].incognito_enabled = | 208 extension_state_map[*id].incognito_enabled = |
208 extension_service->IsIncognitoEnabled(*id); | 209 extension_service->IsIncognitoEnabled(*id); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 if (extension->id() != expected_id) { | 347 if (extension->id() != expected_id) { |
347 EXPECT_EQ(expected_id, extension->id()); | 348 EXPECT_EQ(expected_id, extension->id()); |
348 return NULL; | 349 return NULL; |
349 } | 350 } |
350 DVLOG(2) << "created extension with name = " | 351 DVLOG(2) << "created extension with name = " |
351 << name << ", id = " << expected_id; | 352 << name << ", id = " << expected_id; |
352 (it->second)[name] = extension; | 353 (it->second)[name] = extension; |
353 id_to_name_[expected_id] = name; | 354 id_to_name_[expected_id] = name; |
354 return extension; | 355 return extension; |
355 } | 356 } |
OLD | NEW |