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

Unified Diff: chrome/browser/webshare/share_target_pref_helper.cc

Issue 2639463002: Add a pref name for share targets, and store their manifest data. (Closed)
Patch Set: Remove upstream dependency Created 3 years, 11 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/webshare/share_target_pref_helper.cc
diff --git a/chrome/browser/webshare/share_target_pref_helper.cc b/chrome/browser/webshare/share_target_pref_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f09fc14ab79277635acfd30fab4a59316e6fe453
--- /dev/null
+++ b/chrome/browser/webshare/share_target_pref_helper.cc
@@ -0,0 +1,32 @@
+// Copyright 2017 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/webshare/share_target_pref_helper.h"
+
+#include "base/values.h"
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_service.h"
+#include "components/prefs/scoped_user_pref_update.h"
+
+void UpdateShareTargetInPrefs(base::StringPiece manifest_url,
+ base::Optional<std::string> url_template,
+ PrefService* pref_service) {
+ DictionaryPrefUpdate update(pref_service, prefs::kWebShareVisitedTargets);
+ base::DictionaryValue* share_target_dict = update.Get();
+
+ if (!url_template.has_value()) {
+ share_target_dict->RemoveWithoutPathExpansion(manifest_url, NULL);
+ return;
+ }
+
+ constexpr char kUrlTemplateKey[] = "url_template";
+
+ std::unique_ptr<base::DictionaryValue> origin_dict(new base::DictionaryValue);
+
+ origin_dict->SetStringWithoutPathExpansion(kUrlTemplateKey,
+ url_template.value());
+
+ share_target_dict->SetWithoutPathExpansion(manifest_url,
+ std::move(origin_dict));
+}
« no previous file with comments | « chrome/browser/webshare/share_target_pref_helper.h ('k') | chrome/browser/webshare/share_target_pref_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698