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

Side by Side 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, 10 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/webshare/share_target_pref_helper.h"
6
7 #include "base/values.h"
8 #include "chrome/common/pref_names.h"
9 #include "components/prefs/pref_service.h"
10 #include "components/prefs/scoped_user_pref_update.h"
11
12 void UpdateShareTargetInPrefs(base::StringPiece manifest_url,
13 base::Optional<std::string> url_template,
14 PrefService* pref_service) {
15 DictionaryPrefUpdate update(pref_service, prefs::kWebShareVisitedTargets);
16 base::DictionaryValue* share_target_dict = update.Get();
17
18 if (!url_template.has_value()) {
19 share_target_dict->RemoveWithoutPathExpansion(manifest_url, NULL);
20 return;
21 }
22
23 constexpr char kUrlTemplateKey[] = "url_template";
24
25 std::unique_ptr<base::DictionaryValue> origin_dict(new base::DictionaryValue);
26
27 origin_dict->SetStringWithoutPathExpansion(kUrlTemplateKey,
28 url_template.value());
29
30 share_target_dict->SetWithoutPathExpansion(manifest_url,
31 std::move(origin_dict));
32 }
OLDNEW
« 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