OLD | NEW |
---|---|
(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 <sstream> | |
Matt Giuca
2017/01/24 03:26:09
No more sstream.
constantina
2017/01/24 23:39:04
Done.
| |
8 | |
9 #include "chrome/common/pref_names.h" | |
10 #include "components/prefs/pref_service.h" | |
11 #include "components/prefs/scoped_user_pref_update.h" | |
12 #include "content/public/common/manifest.h" | |
13 | |
14 namespace webshare { | |
15 | |
16 void AddShareTargetToPrefs(base::StringPiece share_target_origin, | |
17 base::Optional<std::string> url_template, | |
18 PrefService* pref_service) { | |
19 DictionaryPrefUpdate update(pref_service, prefs::kWebShareVisitedTargets); | |
20 base::DictionaryValue* share_target_dict = update.Get(); | |
21 | |
22 if (!url_template.has_value()) { | |
23 if (share_target_dict->HasKey(share_target_origin)) | |
24 share_target_dict->RemoveWithoutPathExpansion(share_target_origin, NULL); | |
Matt Giuca
2017/01/24 03:26:09
Does this need a check at all? If the key is missi
constantina
2017/01/24 23:39:04
Yeah, it does nothing. Deleted.
| |
25 return; | |
26 } | |
27 | |
28 constexpr char kUrlTemplateKey[] = "url_template"; | |
29 | |
30 std::unique_ptr<base::DictionaryValue> origin_dict(new base::DictionaryValue); | |
31 | |
32 origin_dict->SetStringWithoutPathExpansion(kUrlTemplateKey, | |
33 url_template.value()); | |
34 | |
35 share_target_dict->SetWithoutPathExpansion(share_target_origin, | |
36 std::move(origin_dict)); | |
37 } | |
38 | |
39 } // namespace webshare | |
OLD | NEW |