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

Side by Side 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 unified diff | Download patch
OLDNEW
(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);
42 webRelatedApplication.id =
43 blink::WebString::fromUTF16(relatedApplication.id);
44 if (!relatedApplication.url.is_empty()) {
45 webRelatedApplication.url =
46 blink::WebString::fromUTF8(relatedApplication.url.spec());
47 }
48 related_apps.push_back(std::move(webRelatedApplication));
49 }
50 callbacks->onSuccess(std::move(related_apps));
51 }
52
53 } // namespace content
OLDNEW
« 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