Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: chrome/browser/chromeos/policy/cloud_external_data_manager_base.cc

Issue 1825173003: [Policy Experimental] Add "recommended" policies for URL exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/policy/cloud_external_data_manager_base.h" 5 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 OnPolicyStoreLoaded(); 374 OnPolicyStoreLoaded();
375 } 375 }
376 376
377 void CloudExternalDataManagerBase::OnPolicyStoreLoaded() { 377 void CloudExternalDataManagerBase::OnPolicyStoreLoaded() {
378 // Collect all external data references made by policies in |policy_store_| 378 // Collect all external data references made by policies in |policy_store_|
379 // and pass them to the |backend_|. 379 // and pass them to the |backend_|.
380 DCHECK(CalledOnValidThread()); 380 DCHECK(CalledOnValidThread());
381 scoped_ptr<Metadata> metadata(new Metadata); 381 scoped_ptr<Metadata> metadata(new Metadata);
382 const PolicyMap& policy_map = policy_store_->policy_map(); 382 const PolicyMap& policy_map = policy_store_->policy_map();
383 for (PolicyMap::const_iterator it = policy_map.begin(); 383 for (PolicyMap::const_iterator it = policy_map.begin();
384 it != policy_map.end(); ++it) { 384 it != policy_map.end(); policy_map.next_dominant(&it)) {
385 if (!it->second.external_data_fetcher) { 385 if (!it->second.external_data_fetcher) {
386 // Skip policies that do not reference external data. 386 // Skip policies that do not reference external data.
387 continue; 387 continue;
388 } 388 }
389 const base::DictionaryValue* dict = NULL; 389 const base::DictionaryValue* dict = NULL;
390 std::string url; 390 std::string url;
391 std::string hex_hash; 391 std::string hex_hash;
392 std::vector<uint8_t> hash; 392 std::vector<uint8_t> hash;
393 if (it->second.value && it->second.value->GetAsDictionary(&dict) && 393 if (it->second.value && it->second.value->GetAsDictionary(&dict) &&
394 dict->GetStringWithoutPathExpansion("url", &url) && 394 dict->GetStringWithoutPathExpansion("url", &url) &&
395 dict->GetStringWithoutPathExpansion("hash", &hex_hash) && 395 dict->GetStringWithoutPathExpansion("hash", &hex_hash) &&
396 !url.empty() && !hex_hash.empty() && 396 !url.empty() && !hex_hash.empty() &&
397 base::HexStringToBytes(hex_hash, &hash)) { 397 base::HexStringToBytes(hex_hash, &hash)) {
398 // Add the external data reference to |metadata| if it is valid (URL and 398 // Add the external data reference to |metadata| if it is valid (URL and
399 // hash are not empty, hash can be decoded as a hex string). 399 // hash are not empty, hash can be decoded as a hex string).
400 (*metadata)[it->first] = 400 (*metadata)[it->first.name] =
401 MetadataEntry(url, std::string(hash.begin(), hash.end())); 401 MetadataEntry(url, std::string(hash.begin(), hash.end()));
402 } 402 }
403 } 403 }
404 404
405 backend_task_runner_->PostTask(FROM_HERE, base::Bind( 405 backend_task_runner_->PostTask(FROM_HERE, base::Bind(
406 &Backend::OnMetadataUpdated, 406 &Backend::OnMetadataUpdated,
407 base::Unretained(backend_.get()), 407 base::Unretained(backend_.get()),
408 base::Passed(&metadata))); 408 base::Passed(&metadata)));
409 } 409 }
410 410
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 max_external_data_size_for_testing = max_size; 444 max_external_data_size_for_testing = max_size;
445 } 445 }
446 446
447 void CloudExternalDataManagerBase::FetchAll() { 447 void CloudExternalDataManagerBase::FetchAll() {
448 DCHECK(CalledOnValidThread()); 448 DCHECK(CalledOnValidThread());
449 backend_task_runner_->PostTask(FROM_HERE, base::Bind( 449 backend_task_runner_->PostTask(FROM_HERE, base::Bind(
450 &Backend::FetchAll, base::Unretained(backend_.get()))); 450 &Backend::FetchAll, base::Unretained(backend_.get())));
451 } 451 }
452 452
453 } // namespace policy 453 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698