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 "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" | 5 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 base::DictionaryValue* pref_dict, | 432 base::DictionaryValue* pref_dict, |
433 const std::string& client_id, | 433 const std::string& client_id, |
434 const std::string& crx_id) { | 434 const std::string& crx_id) { |
435 base::DictionaryValue* whitelist_dict = nullptr; | 435 base::DictionaryValue* whitelist_dict = nullptr; |
436 bool success = | 436 bool success = |
437 pref_dict->GetDictionaryWithoutPathExpansion(crx_id, &whitelist_dict); | 437 pref_dict->GetDictionaryWithoutPathExpansion(crx_id, &whitelist_dict); |
438 DCHECK(success); | 438 DCHECK(success); |
439 base::ListValue* clients = nullptr; | 439 base::ListValue* clients = nullptr; |
440 success = whitelist_dict->GetList(kClients, &clients); | 440 success = whitelist_dict->GetList(kClients, &clients); |
441 | 441 |
442 const bool removed = clients->Remove(base::StringValue(client_id), nullptr); | 442 const bool removed = clients->Remove(base::Value(client_id), nullptr); |
443 | 443 |
444 if (!clients->empty()) | 444 if (!clients->empty()) |
445 return removed; | 445 return removed; |
446 | 446 |
447 pref_dict->RemoveWithoutPathExpansion(crx_id, nullptr); | 447 pref_dict->RemoveWithoutPathExpansion(crx_id, nullptr); |
448 bool result = cus_->UnregisterComponent(crx_id); | 448 bool result = cus_->UnregisterComponent(crx_id); |
449 DCHECK(result); | 449 DCHECK(result); |
450 | 450 |
451 cus_->GetSequencedTaskRunner()->PostTask( | 451 cus_->GetSequencedTaskRunner()->PostTask( |
452 FROM_HERE, | 452 FROM_HERE, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 pref_dict->SetWithoutPathExpansion(crx_id, whitelist_dict); | 542 pref_dict->SetWithoutPathExpansion(crx_id, whitelist_dict); |
543 } | 543 } |
544 | 544 |
545 if (!client_id.empty()) { | 545 if (!client_id.empty()) { |
546 base::ListValue* clients = nullptr; | 546 base::ListValue* clients = nullptr; |
547 if (!whitelist_dict->GetList(kClients, &clients)) { | 547 if (!whitelist_dict->GetList(kClients, &clients)) { |
548 DCHECK(newly_added); | 548 DCHECK(newly_added); |
549 clients = new base::ListValue; | 549 clients = new base::ListValue; |
550 whitelist_dict->Set(kClients, clients); | 550 whitelist_dict->Set(kClients, clients); |
551 } | 551 } |
552 bool success = clients->AppendIfNotPresent( | 552 bool success = |
553 base::MakeUnique<base::StringValue>(client_id)); | 553 clients->AppendIfNotPresent(base::MakeUnique<base::Value>(client_id)); |
554 DCHECK(success); | 554 DCHECK(success); |
555 } | 555 } |
556 | 556 |
557 if (!newly_added) { | 557 if (!newly_added) { |
558 // Sanity-check that the stored name is equal to the name passed in. | 558 // Sanity-check that the stored name is equal to the name passed in. |
559 // In release builds this is a no-op. | 559 // In release builds this is a no-op. |
560 std::string stored_name; | 560 std::string stored_name; |
561 DCHECK(whitelist_dict->GetString(kName, &stored_name)); | 561 DCHECK(whitelist_dict->GetString(kName, &stored_name)); |
562 DCHECK_EQ(stored_name, name); | 562 DCHECK_EQ(stored_name, name); |
563 return; | 563 return; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 647 |
648 // static | 648 // static |
649 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate( | 649 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate( |
650 OnDemandUpdater* updater, | 650 OnDemandUpdater* updater, |
651 const std::string& crx_id) { | 651 const std::string& crx_id) { |
652 // TODO(sorin): use a callback to check the result (crbug.com/639189). | 652 // TODO(sorin): use a callback to check the result (crbug.com/639189). |
653 updater->OnDemandUpdate(crx_id, component_updater::Callback()); | 653 updater->OnDemandUpdate(crx_id, component_updater::Callback()); |
654 } | 654 } |
655 | 655 |
656 } // namespace component_updater | 656 } // namespace component_updater |
OLD | NEW |