| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 installer->Subscribe(base::Bind(&WhitelistLoadObserver::OnWhitelistReady, | 156 installer->Subscribe(base::Bind(&WhitelistLoadObserver::OnWhitelistReady, |
| 157 weak_ptr_factory_.GetWeakPtr())); | 157 weak_ptr_factory_.GetWeakPtr())); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void Wait() { run_loop_.Run(); } | 160 void Wait() { run_loop_.Run(); } |
| 161 | 161 |
| 162 const base::FilePath& whitelist_path() { return whitelist_path_; } | 162 const base::FilePath& whitelist_path() { return whitelist_path_; } |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 void OnWhitelistReady(const std::string& crx_id, | 165 void OnWhitelistReady(const std::string& crx_id, |
| 166 const base::string16& title, |
| 166 const base::FilePath& whitelist_path) { | 167 const base::FilePath& whitelist_path) { |
| 167 EXPECT_EQ(base::FilePath::StringType(), whitelist_path_.value()); | 168 EXPECT_EQ(base::FilePath::StringType(), whitelist_path_.value()); |
| 168 whitelist_path_ = whitelist_path; | 169 whitelist_path_ = whitelist_path; |
| 169 run_loop_.Quit(); | 170 run_loop_.Quit(); |
| 170 } | 171 } |
| 171 | 172 |
| 172 base::FilePath whitelist_path_; | 173 base::FilePath whitelist_path_; |
| 173 | 174 |
| 174 base::RunLoop run_loop_; | 175 base::RunLoop run_loop_; |
| 175 base::WeakPtrFactory<WhitelistLoadObserver> weak_ptr_factory_; | 176 base::WeakPtrFactory<WhitelistLoadObserver> weak_ptr_factory_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 201 | 202 |
| 202 ASSERT_TRUE( | 203 ASSERT_TRUE( |
| 203 PathService::Get(chrome::DIR_SUPERVISED_USER_INSTALLED_WHITELISTS, | 204 PathService::Get(chrome::DIR_SUPERVISED_USER_INSTALLED_WHITELISTS, |
| 204 &installed_whitelist_directory_)); | 205 &installed_whitelist_directory_)); |
| 205 std::string crx_id(kCrxId); | 206 std::string crx_id(kCrxId); |
| 206 whitelist_path_ = | 207 whitelist_path_ = |
| 207 installed_whitelist_directory_.AppendASCII(crx_id + ".json"); | 208 installed_whitelist_directory_.AppendASCII(crx_id + ".json"); |
| 208 | 209 |
| 209 scoped_ptr<base::DictionaryValue> whitelist_dict( | 210 scoped_ptr<base::DictionaryValue> whitelist_dict( |
| 210 new base::DictionaryValue); | 211 new base::DictionaryValue); |
| 211 whitelist_dict->SetString("file", kWhitelistFile); | 212 whitelist_dict->SetString("sites", kWhitelistFile); |
| 212 manifest_.Set("whitelist", whitelist_dict.release()); | 213 manifest_.Set("whitelisted_content", whitelist_dict.release()); |
| 213 manifest_.SetString("version", kVersion); | 214 manifest_.SetString("version", kVersion); |
| 214 | 215 |
| 215 scoped_ptr<base::DictionaryValue> crx_dict(new base::DictionaryValue); | 216 scoped_ptr<base::DictionaryValue> crx_dict(new base::DictionaryValue); |
| 216 crx_dict->SetString("name", kName); | 217 crx_dict->SetString("name", kName); |
| 217 scoped_ptr<base::ListValue> clients(new base::ListValue); | 218 scoped_ptr<base::ListValue> clients(new base::ListValue); |
| 218 clients->AppendString(kClientId); | 219 clients->AppendString(kClientId); |
| 219 clients->AppendString(kOtherClientId); | 220 clients->AppendString(kOtherClientId); |
| 220 crx_dict->Set("clients", clients.release()); | 221 crx_dict->Set("clients", clients.release()); |
| 221 pref_.Set(kCrxId, crx_dict.release()); | 222 pref_.Set(kCrxId, crx_dict.release()); |
| 222 } | 223 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 base::RunLoop run_loop; | 376 base::RunLoop run_loop; |
| 376 installer_->UnregisterWhitelist(kOtherClientId, kCrxId); | 377 installer_->UnregisterWhitelist(kOtherClientId, kCrxId); |
| 377 run_loop.RunUntilIdle(); | 378 run_loop.RunUntilIdle(); |
| 378 } | 379 } |
| 379 EXPECT_FALSE(component_update_service_.registered_component()); | 380 EXPECT_FALSE(component_update_service_.registered_component()); |
| 380 EXPECT_FALSE(base::DirectoryExists(whitelist_directory_)); | 381 EXPECT_FALSE(base::DirectoryExists(whitelist_directory_)); |
| 381 EXPECT_FALSE(base::PathExists(whitelist_path_)); | 382 EXPECT_FALSE(base::PathExists(whitelist_path_)); |
| 382 } | 383 } |
| 383 | 384 |
| 384 } // namespace component_updater | 385 } // namespace component_updater |
| OLD | NEW |