Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
|
Matt Giuca
2017/01/23 03:00:57
Copyright 2017.
constantina
2017/01/24 02:03:42
OMG. Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
|
Matt Giuca
2017/01/23 03:00:57
You need a .h file for this file.
Also you need t
constantina
2017/01/24 02:03:42
Done.
| |
| 5 #include <sstream> | |
| 6 | |
| 7 #include "base/strings/string16.h" | |
| 8 #include "base/values.h" | |
| 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 { | |
|
Matt Giuca
2017/01/23 03:00:57
This can't be in an anonymous namespace, since it
constantina
2017/01/24 02:03:43
Done. Used 'webshare'.
Matt Giuca
2017/01/24 03:26:09
We haven't used the "webshare" namespace anywhere
constantina
2017/01/24 23:39:04
Done.
| |
| 15 | |
| 16 // Adds the Web Share target |share_target_origin| with template |url_template| | |
| 17 // to |pref_service| under kWebShareVisitedTargets. If |url_template| is null, | |
| 18 // this function does nothing. | |
|
Matt Giuca
2017/01/23 03:00:58
Obsolete comment? It removes the target from the p
constantina
2017/01/24 02:03:42
Yeah, obsolete. Removed.
| |
| 19 void AddShareTargetToPrefs(std::string share_target_origin, | |
|
Matt Giuca
2017/01/23 03:00:57
StringPiece?
constantina
2017/01/24 02:03:42
Done.
| |
| 20 base::NullableString16 share_target_url_template, | |
|
Matt Giuca
2017/01/23 03:00:57
Hmm, I think it would be more natural to accept a
constantina
2017/01/24 02:03:42
I do care about optionality, because we want to al
| |
| 21 PrefService* pref_service) { | |
| 22 DictionaryPrefUpdate update(pref_service, prefs::kWebShareVisitedTargets); | |
| 23 base::DictionaryValue* share_target_dict = update.Get(); | |
| 24 | |
| 25 if (share_target_url_template.is_null()) { | |
|
Matt Giuca
2017/01/23 03:00:57
nit: && rather than two if statements.
constantina
2017/01/24 02:03:42
There are supposed to be two distinct cases here,
Matt Giuca
2017/01/24 03:26:09
I see, I misread it.
No, don't do the same check
constantina
2017/01/24 23:39:04
Done.
| |
| 26 if (share_target_dict->HasKey(share_target_origin)) | |
| 27 share_target_dict->RemoveWithoutPathExpansion(share_target_origin, NULL); | |
| 28 return; | |
| 29 } | |
| 30 | |
| 31 constexpr char kUrlTemplateKey[] = "url_template"; | |
| 32 | |
| 33 std::unique_ptr<base::DictionaryValue> origin_dict(new base::DictionaryValue); | |
| 34 | |
| 35 std::stringstream ss; | |
| 36 ss << share_target_url_template.string(); | |
| 37 std::string url_template; | |
| 38 ss >> url_template; | |
|
Matt Giuca
2017/01/23 03:00:57
What's with the stringstream? Are you just doing t
constantina
2017/01/24 02:03:43
Done.
| |
| 39 origin_dict->SetStringWithoutPathExpansion(kUrlTemplateKey, url_template); | |
| 40 | |
| 41 share_target_dict->SetWithoutPathExpansion(share_target_origin, | |
|
Matt Giuca
2017/01/23 03:58:56
As discussed offline, this should actually be keye
constantina
2017/01/24 02:03:43
Done.
| |
| 42 std::move(origin_dict)); | |
| 43 } | |
| 44 | |
| 45 } // namespace | |
| OLD | NEW |