Chromium Code Reviews| Index: content/renderer/installedapp/related_apps_fetcher.cc |
| diff --git a/content/renderer/installedapp/related_apps_fetcher.cc b/content/renderer/installedapp/related_apps_fetcher.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..67d7c1080952e28bde9bde736dcff8f1360b28ef |
| --- /dev/null |
| +++ b/content/renderer/installedapp/related_apps_fetcher.cc |
| @@ -0,0 +1,51 @@ |
| +// 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 "content/renderer/installedapp/related_apps_fetcher.h" |
| + |
| +#include "base/bind.h" |
| +#include "content/public/common/manifest.h" |
| +#include "content/renderer/manifest/manifest_debug_info.h" |
| +#include "content/renderer/manifest/manifest_manager.h" |
| +#include "third_party/WebKit/public/platform/WebString.h" |
| +#include "third_party/WebKit/public/platform/modules/installedapp/WebRelatedApplication.h" |
| + |
| +namespace content { |
| + |
| +RelatedAppsFetcher::RelatedAppsFetcher(ManifestManager* manifest_manager) |
| + : manifest_manager_(manifest_manager) {} |
| + |
| +RelatedAppsFetcher::~RelatedAppsFetcher() {} |
| + |
| +void RelatedAppsFetcher::getManifestRelatedApplications( |
| + std::unique_ptr<blink::WebCallbacks< |
| + const blink::WebVector<blink::WebRelatedApplication>&, |
| + void>> callbacks) { |
| + manifest_manager_->GetManifest( |
| + base::Bind(&RelatedAppsFetcher::OnGetManifestForRelatedApplications, |
| + base::Unretained(this), base::Passed(&callbacks))); |
| +} |
| + |
| +void RelatedAppsFetcher::OnGetManifestForRelatedApplications( |
| + std::unique_ptr<blink::WebCallbacks< |
| + const blink::WebVector<blink::WebRelatedApplication>&, |
| + void>> callbacks, |
| + const GURL& /*url*/, |
| + const Manifest& manifest, |
| + const ManifestDebugInfo& /*manifest_debug_info*/) { |
| + std::vector<blink::WebRelatedApplication> related_apps; |
| + for (const auto& relatedApplication : manifest.related_applications) { |
| + blink::WebRelatedApplication webRelatedApplication; |
| + webRelatedApplication.platform = |
| + 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
|
| + webRelatedApplication.id = |
| + blink::WebString::fromUTF16(relatedApplication.id.string()); |
|
esprehn
2017/02/15 01:56:50
ditto
Matt Giuca
2017/02/15 07:55:34
Done.
|
| + webRelatedApplication.url = |
| + 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
|
| + related_apps.push_back(std::move(webRelatedApplication)); |
| + } |
| + callbacks->onSuccess(std::move(related_apps)); |
| +} |
| + |
| +} // namespace content |