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

Unified Diff: content/renderer/installedapp/related_apps_fetcher.cc

Issue 2488573002: Refactor getInstalledRelatedApps code and add manifest logic and tests. (Closed)
Patch Set: Use SecurityOrigin, not WebSecurityOrigin. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/installedapp/related_apps_fetcher.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2d6db5a5c0f0be3e3dbc7dec2552e33c2fcca057
--- /dev/null
+++ b/content/renderer/installedapp/related_apps_fetcher.cc
@@ -0,0 +1,53 @@
+// 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);
+ webRelatedApplication.id =
+ blink::WebString::fromUTF16(relatedApplication.id);
+ if (!relatedApplication.url.is_empty()) {
+ webRelatedApplication.url =
+ blink::WebString::fromUTF8(relatedApplication.url.spec());
+ }
+ related_apps.push_back(std::move(webRelatedApplication));
+ }
+ callbacks->onSuccess(std::move(related_apps));
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/installedapp/related_apps_fetcher.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698