OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/ntp_snippets/ntp_snippets_service.h" | 5 #include "components/ntp_snippets/ntp_snippets_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 } | 496 } |
497 | 497 |
498 void NTPSnippetsService::StoreDiscardedSnippetsToPrefs() { | 498 void NTPSnippetsService::StoreDiscardedSnippetsToPrefs() { |
499 pref_service_->Set(prefs::kDiscardedSnippets, | 499 pref_service_->Set(prefs::kDiscardedSnippets, |
500 *SnippetsToListValue(discarded_snippets_)); | 500 *SnippetsToListValue(discarded_snippets_)); |
501 } | 501 } |
502 | 502 |
503 std::set<std::string> NTPSnippetsService::GetSnippetHostsFromPrefs() const { | 503 std::set<std::string> NTPSnippetsService::GetSnippetHostsFromPrefs() const { |
504 std::set<std::string> hosts; | 504 std::set<std::string> hosts; |
505 const base::ListValue* list = pref_service_->GetList(prefs::kSnippetHosts); | 505 const base::ListValue* list = pref_service_->GetList(prefs::kSnippetHosts); |
506 for (const base::Value* value : *list) { | 506 for (const auto& value : *list) { |
507 std::string str; | 507 std::string str; |
508 bool success = value->GetAsString(&str); | 508 bool success = value->GetAsString(&str); |
509 DCHECK(success) << "Failed to parse snippet host from prefs"; | 509 DCHECK(success) << "Failed to parse snippet host from prefs"; |
510 hosts.insert(std::move(str)); | 510 hosts.insert(std::move(str)); |
511 } | 511 } |
512 return hosts; | 512 return hosts; |
513 } | 513 } |
514 | 514 |
515 void NTPSnippetsService::StoreSnippetHostsToPrefs( | 515 void NTPSnippetsService::StoreSnippetHostsToPrefs( |
516 const std::set<std::string>& hosts) { | 516 const std::set<std::string>& hosts) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 bool NTPSnippetsService::IsSyncStateIncompatible() { | 578 bool NTPSnippetsService::IsSyncStateIncompatible() { |
579 if (!sync_service_ || !sync_service_->CanSyncStart()) | 579 if (!sync_service_ || !sync_service_->CanSyncStart()) |
580 return true; | 580 return true; |
581 if (!sync_service_->IsSyncActive() || !sync_service_->ConfigurationDone()) | 581 if (!sync_service_->IsSyncActive() || !sync_service_->ConfigurationDone()) |
582 return false; // Sync service is not initialized, yet not disabled. | 582 return false; // Sync service is not initialized, yet not disabled. |
583 return !sync_service_->GetActiveDataTypes().Has( | 583 return !sync_service_->GetActiveDataTypes().Has( |
584 syncer::HISTORY_DELETE_DIRECTIVES); | 584 syncer::HISTORY_DELETE_DIRECTIVES); |
585 } | 585 } |
586 | 586 |
587 } // namespace ntp_snippets | 587 } // namespace ntp_snippets |
OLD | NEW |