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