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