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

Unified Diff: chrome/browser/search/suggestions/suggestions_store.cc

Issue 410673002: [Suggestions] Moving suggestions code to a new component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix deps Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search/suggestions/suggestions_store.cc
diff --git a/chrome/browser/search/suggestions/suggestions_store.cc b/chrome/browser/search/suggestions/suggestions_store.cc
deleted file mode 100644
index e57569d7fafce5b6aaa5699ad8c447371855c6f7..0000000000000000000000000000000000000000
--- a/chrome/browser/search/suggestions/suggestions_store.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/search/suggestions/suggestions_store.h"
-
-#include <string>
-
-#include "base/base64.h"
-#include "base/prefs/pref_service.h"
-#include "chrome/common/pref_names.h"
-#include "components/pref_registry/pref_registry_syncable.h"
-
-namespace suggestions {
-
-SuggestionsStore::SuggestionsStore(PrefService* profile_prefs)
- : pref_service_(profile_prefs) {
- DCHECK(profile_prefs);
-}
-
-SuggestionsStore::~SuggestionsStore() {}
-
-bool SuggestionsStore::LoadSuggestions(SuggestionsProfile* suggestions) {
- DCHECK(suggestions);
-
- const std::string base64_suggestions_data =
- pref_service_->GetString(prefs::kSuggestionsData);
- if (base64_suggestions_data.empty()) {
- suggestions->Clear();
- return false;
- }
-
- // If the decode process fails, assume the pref value is corrupt and clear it.
- std::string suggestions_data;
- if (!base::Base64Decode(base64_suggestions_data, &suggestions_data) ||
- !suggestions->ParseFromString(suggestions_data)) {
- VLOG(1) << "Suggestions data in profile pref is corrupt, clearing it.";
- suggestions->Clear();
- ClearSuggestions();
- return false;
- }
-
- return true;
-}
-
-bool SuggestionsStore::StoreSuggestions(const SuggestionsProfile& suggestions) {
- std::string suggestions_data;
- if (!suggestions.SerializeToString(&suggestions_data)) return false;
-
- std::string base64_suggestions_data;
- base::Base64Encode(suggestions_data, &base64_suggestions_data);
-
- pref_service_->SetString(prefs::kSuggestionsData, base64_suggestions_data);
- return true;
-}
-
-void SuggestionsStore::ClearSuggestions() {
- pref_service_->ClearPref(prefs::kSuggestionsData);
-}
-
-// static
-void SuggestionsStore::RegisterProfilePrefs(
- user_prefs::PrefRegistrySyncable* registry) {
- registry->RegisterStringPref(
- prefs::kSuggestionsData, std::string(),
- user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
-}
-
-} // namespace suggestions
« no previous file with comments | « chrome/browser/search/suggestions/suggestions_store.h ('k') | chrome/browser/search/suggestions/suggestions_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698