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 "content/renderer/installedapp/related_apps_fetcher.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "content/public/common/manifest.h" | |
9 #include "content/renderer/manifest/manifest_debug_info.h" | |
10 #include "content/renderer/manifest/manifest_manager.h" | |
11 #include "third_party/WebKit/public/platform/WebString.h" | |
12 #include "third_party/WebKit/public/platform/modules/installedapp/WebRelatedAppl ication.h" | |
13 | |
14 namespace content { | |
15 | |
16 RelatedAppsFetcher::RelatedAppsFetcher(ManifestManager* manifest_manager) | |
17 : manifest_manager_(manifest_manager) {} | |
18 | |
19 RelatedAppsFetcher::~RelatedAppsFetcher() {} | |
20 | |
21 void RelatedAppsFetcher::getManifestRelatedApplications( | |
22 std::unique_ptr<blink::WebCallbacks< | |
23 const blink::WebVector<blink::WebRelatedApplication>&, | |
24 void>> callbacks) { | |
25 manifest_manager_->GetManifest( | |
26 base::Bind(&RelatedAppsFetcher::OnGetManifestForRelatedApplications, | |
27 base::Unretained(this), base::Passed(&callbacks))); | |
28 } | |
29 | |
30 void RelatedAppsFetcher::OnGetManifestForRelatedApplications( | |
31 std::unique_ptr<blink::WebCallbacks< | |
32 const blink::WebVector<blink::WebRelatedApplication>&, | |
33 void>> callbacks, | |
34 const GURL& /*url*/, | |
35 const Manifest& manifest, | |
36 const ManifestDebugInfo& /*manifest_debug_info*/) { | |
37 std::vector<blink::WebRelatedApplication> related_apps; | |
38 for (const auto& relatedApplication : manifest.related_applications) { | |
39 blink::WebRelatedApplication webRelatedApplication; | |
40 webRelatedApplication.platform = | |
41 blink::WebString::fromUTF16(relatedApplication.platform.string()); | |
esprehn
2017/02/15 01:56:50
This doesn't preserve the nullability, WebString c
Matt Giuca
2017/02/15 07:55:34
Done. (WebString::fromUTF16 has an overload that t
| |
42 webRelatedApplication.id = | |
43 blink::WebString::fromUTF16(relatedApplication.id.string()); | |
esprehn
2017/02/15 01:56:50
ditto
Matt Giuca
2017/02/15 07:55:34
Done.
| |
44 webRelatedApplication.url = | |
45 blink::WebString::fromUTF8(relatedApplication.url.spec()); | |
Matt Giuca
2017/02/15 07:55:34
url doesn't have a concept of null, but I felt it
| |
46 related_apps.push_back(std::move(webRelatedApplication)); | |
47 } | |
48 callbacks->onSuccess(std::move(related_apps)); | |
49 } | |
50 | |
51 } // namespace content | |
OLD | NEW |