OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
11 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
12 #include "base/json/json_file_value_serializer.h" | 14 #include "base/json/json_file_value_serializer.h" |
13 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
14 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
15 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
16 #include "base/path_service.h" | 18 #include "base/path_service.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 ASSERT_TRUE( | 231 ASSERT_TRUE( |
230 PathService::Get(chrome::DIR_SUPERVISED_USER_INSTALLED_WHITELISTS, | 232 PathService::Get(chrome::DIR_SUPERVISED_USER_INSTALLED_WHITELISTS, |
231 &installed_whitelist_directory_)); | 233 &installed_whitelist_directory_)); |
232 std::string crx_id(kCrxId); | 234 std::string crx_id(kCrxId); |
233 whitelist_path_ = | 235 whitelist_path_ = |
234 installed_whitelist_directory_.AppendASCII(crx_id + ".json"); | 236 installed_whitelist_directory_.AppendASCII(crx_id + ".json"); |
235 | 237 |
236 std::unique_ptr<base::DictionaryValue> whitelist_dict( | 238 std::unique_ptr<base::DictionaryValue> whitelist_dict( |
237 new base::DictionaryValue); | 239 new base::DictionaryValue); |
238 whitelist_dict->SetString("sites", kWhitelistFile); | 240 whitelist_dict->SetString("sites", kWhitelistFile); |
239 manifest_.Set("whitelisted_content", whitelist_dict.release()); | 241 manifest_.Set("whitelisted_content", std::move(whitelist_dict)); |
240 | 242 |
241 large_icon_path_ = whitelist_version_directory_.AppendASCII(kLargeIconFile); | 243 large_icon_path_ = whitelist_version_directory_.AppendASCII(kLargeIconFile); |
242 std::unique_ptr<base::DictionaryValue> icons_dict( | 244 std::unique_ptr<base::DictionaryValue> icons_dict( |
243 new base::DictionaryValue); | 245 new base::DictionaryValue); |
244 icons_dict->SetString("128", kLargeIconFile); | 246 icons_dict->SetString("128", kLargeIconFile); |
245 manifest_.Set("icons", icons_dict.release()); | 247 manifest_.Set("icons", std::move(icons_dict)); |
246 | 248 |
247 manifest_.SetString("version", kVersion); | 249 manifest_.SetString("version", kVersion); |
248 | 250 |
249 std::unique_ptr<base::DictionaryValue> crx_dict(new base::DictionaryValue); | 251 std::unique_ptr<base::DictionaryValue> crx_dict(new base::DictionaryValue); |
250 crx_dict->SetString("name", kName); | 252 crx_dict->SetString("name", kName); |
251 std::unique_ptr<base::ListValue> clients(new base::ListValue); | 253 std::unique_ptr<base::ListValue> clients(new base::ListValue); |
252 clients->AppendString(kClientId); | 254 clients->AppendString(kClientId); |
253 clients->AppendString(kOtherClientId); | 255 clients->AppendString(kOtherClientId); |
254 crx_dict->Set("clients", clients.release()); | 256 crx_dict->Set("clients", std::move(clients)); |
255 pref_.Set(kCrxId, crx_dict.release()); | 257 pref_.Set(kCrxId, std::move(crx_dict)); |
256 } | 258 } |
257 | 259 |
258 protected: | 260 protected: |
259 ProfileAttributesStorage* profile_attributes_storage() { | 261 ProfileAttributesStorage* profile_attributes_storage() { |
260 return testing_profile_manager_.profile_attributes_storage(); | 262 return testing_profile_manager_.profile_attributes_storage(); |
261 } | 263 } |
262 | 264 |
263 base::FilePath GetProfilePath(const std::string& profile_name) { | 265 base::FilePath GetProfilePath(const std::string& profile_name) { |
264 return testing_profile_manager_.profiles_dir().AppendASCII(profile_name); | 266 return testing_profile_manager_.profiles_dir().AppendASCII(profile_name); |
265 } | 267 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 // but it exercises a different code path. | 427 // but it exercises a different code path. |
426 profile_attributes_storage()->RemoveProfile(GetProfilePath(kOtherClientId)); | 428 profile_attributes_storage()->RemoveProfile(GetProfilePath(kOtherClientId)); |
427 run_loop.RunUntilIdle(); | 429 run_loop.RunUntilIdle(); |
428 } | 430 } |
429 EXPECT_FALSE(component_update_service_.registered_component()); | 431 EXPECT_FALSE(component_update_service_.registered_component()); |
430 EXPECT_FALSE(base::DirectoryExists(whitelist_directory_)); | 432 EXPECT_FALSE(base::DirectoryExists(whitelist_directory_)); |
431 EXPECT_FALSE(base::PathExists(whitelist_path_)); | 433 EXPECT_FALSE(base::PathExists(whitelist_path_)); |
432 } | 434 } |
433 | 435 |
434 } // namespace component_updater | 436 } // namespace component_updater |
OLD | NEW |