| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/extensions/external_cache.h" | 5 #include "chrome/browser/chromeos/extensions/external_cache.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 13 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 16 #include "base/test/sequenced_worker_pool_owner.h" | 17 #include "base/test/sequenced_worker_pool_owner.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 19 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 20 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); | 164 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); |
| 164 base::DictionaryValue* dict = CreateEntryWithUpdateUrl(true); | 165 base::DictionaryValue* dict = CreateEntryWithUpdateUrl(true); |
| 165 prefs->Set(kTestExtensionId1, dict); | 166 prefs->Set(kTestExtensionId1, dict); |
| 166 CreateExtensionFile(cache_dir, kTestExtensionId1, "1"); | 167 CreateExtensionFile(cache_dir, kTestExtensionId1, "1"); |
| 167 dict = CreateEntryWithUpdateUrl(true); | 168 dict = CreateEntryWithUpdateUrl(true); |
| 168 prefs->Set(kTestExtensionId2, dict); | 169 prefs->Set(kTestExtensionId2, dict); |
| 169 prefs->Set(kTestExtensionId3, CreateEntryWithUpdateUrl(false)); | 170 prefs->Set(kTestExtensionId3, CreateEntryWithUpdateUrl(false)); |
| 170 CreateExtensionFile(cache_dir, kTestExtensionId3, "3"); | 171 CreateExtensionFile(cache_dir, kTestExtensionId3, "3"); |
| 171 prefs->Set(kTestExtensionId4, CreateEntryWithUpdateUrl(false)); | 172 prefs->Set(kTestExtensionId4, CreateEntryWithUpdateUrl(false)); |
| 172 | 173 |
| 173 external_cache.UpdateExtensionsList(prefs.Pass()); | 174 external_cache.UpdateExtensionsList(std::move(prefs)); |
| 174 WaitForCompletion(); | 175 WaitForCompletion(); |
| 175 | 176 |
| 176 ASSERT_TRUE(provided_prefs()); | 177 ASSERT_TRUE(provided_prefs()); |
| 177 EXPECT_EQ(provided_prefs()->size(), 2ul); | 178 EXPECT_EQ(provided_prefs()->size(), 2ul); |
| 178 | 179 |
| 179 // File in cache from Webstore. | 180 // File in cache from Webstore. |
| 180 const base::DictionaryValue* entry1 = NULL; | 181 const base::DictionaryValue* entry1 = NULL; |
| 181 ASSERT_TRUE(provided_prefs()->GetDictionary(kTestExtensionId1, &entry1)); | 182 ASSERT_TRUE(provided_prefs()->GetDictionary(kTestExtensionId1, &entry1)); |
| 182 EXPECT_FALSE(entry1->HasKey( | 183 EXPECT_FALSE(entry1->HasKey( |
| 183 extensions::ExternalProviderImpl::kExternalUpdateUrl)); | 184 extensions::ExternalProviderImpl::kExternalUpdateUrl)); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 base::FilePath cache_dir(CreateCacheDir(false)); | 283 base::FilePath cache_dir(CreateCacheDir(false)); |
| 283 ExternalCache external_cache(cache_dir, request_context_getter(), | 284 ExternalCache external_cache(cache_dir, request_context_getter(), |
| 284 background_task_runner(), this, true, false); | 285 background_task_runner(), this, true, false); |
| 285 | 286 |
| 286 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); | 287 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); |
| 287 prefs->Set(kTestExtensionId1, CreateEntryWithUpdateUrl(true)); | 288 prefs->Set(kTestExtensionId1, CreateEntryWithUpdateUrl(true)); |
| 288 prefs->Set(kTestExtensionId2, CreateEntryWithUpdateUrl(true)); | 289 prefs->Set(kTestExtensionId2, CreateEntryWithUpdateUrl(true)); |
| 289 | 290 |
| 290 AddInstalledExtension(kTestExtensionId1, "1"); | 291 AddInstalledExtension(kTestExtensionId1, "1"); |
| 291 | 292 |
| 292 external_cache.UpdateExtensionsList(prefs.Pass()); | 293 external_cache.UpdateExtensionsList(std::move(prefs)); |
| 293 WaitForCompletion(); | 294 WaitForCompletion(); |
| 294 | 295 |
| 295 ASSERT_TRUE(provided_prefs()); | 296 ASSERT_TRUE(provided_prefs()); |
| 296 EXPECT_EQ(provided_prefs()->size(), 1ul); | 297 EXPECT_EQ(provided_prefs()->size(), 1ul); |
| 297 | 298 |
| 298 // File not in cache but extension installed. | 299 // File not in cache but extension installed. |
| 299 const base::DictionaryValue* entry1 = NULL; | 300 const base::DictionaryValue* entry1 = NULL; |
| 300 ASSERT_TRUE(provided_prefs()->GetDictionary(kTestExtensionId1, &entry1)); | 301 ASSERT_TRUE(provided_prefs()->GetDictionary(kTestExtensionId1, &entry1)); |
| 301 EXPECT_TRUE(entry1->HasKey( | 302 EXPECT_TRUE(entry1->HasKey( |
| 302 extensions::ExternalProviderImpl::kExternalUpdateUrl)); | 303 extensions::ExternalProviderImpl::kExternalUpdateUrl)); |
| 303 EXPECT_FALSE(entry1->HasKey( | 304 EXPECT_FALSE(entry1->HasKey( |
| 304 extensions::ExternalProviderImpl::kExternalCrx)); | 305 extensions::ExternalProviderImpl::kExternalCrx)); |
| 305 EXPECT_FALSE(entry1->HasKey( | 306 EXPECT_FALSE(entry1->HasKey( |
| 306 extensions::ExternalProviderImpl::kExternalVersion)); | 307 extensions::ExternalProviderImpl::kExternalVersion)); |
| 307 } | 308 } |
| 308 | 309 |
| 309 } // namespace chromeos | 310 } // namespace chromeos |
| OLD | NEW |