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

Side by Side Diff: third_party/WebKit/Source/modules/installedapp/InstalledAppController.cpp

Issue 2748023002: getInstalledRelatedApps: Change internal url fields to URL type. (Closed)
Patch Set: Created 3 years, 9 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/installedapp/InstalledAppController.h" 5 #include "modules/installedapp/InstalledAppController.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "platform/RuntimeEnabledFeatures.h" 9 #include "platform/RuntimeEnabledFeatures.h"
10 #include "platform/weborigin/KURL.h"
10 #include "public/platform/InterfaceProvider.h" 11 #include "public/platform/InterfaceProvider.h"
11 #include "wtf/Functional.h" 12 #include "wtf/Functional.h"
12 13
13 #include <utility> 14 #include <utility>
14 15
15 namespace blink { 16 namespace blink {
16 17
17 // Callbacks for the result of 18 // Callbacks for the result of
18 // WebRelatedAppsFetcher::getManifestRelatedApplications. Calls 19 // WebRelatedAppsFetcher::getManifestRelatedApplications. Calls
19 // filterByInstalledApps upon receiving the list of related applications. 20 // filterByInstalledApps upon receiving the list of related applications.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 void InstalledAppController::filterByInstalledApps( 97 void InstalledAppController::filterByInstalledApps(
97 const blink::WebVector<blink::WebRelatedApplication>& relatedApps, 98 const blink::WebVector<blink::WebRelatedApplication>& relatedApps,
98 std::unique_ptr<blink::AppInstalledCallbacks> callbacks) { 99 std::unique_ptr<blink::AppInstalledCallbacks> callbacks) {
99 WTF::Vector<mojom::blink::RelatedApplicationPtr> mojoRelatedApps; 100 WTF::Vector<mojom::blink::RelatedApplicationPtr> mojoRelatedApps;
100 for (const auto& relatedApplication : relatedApps) { 101 for (const auto& relatedApplication : relatedApps) {
101 mojom::blink::RelatedApplicationPtr convertedApplication( 102 mojom::blink::RelatedApplicationPtr convertedApplication(
102 mojom::blink::RelatedApplication::New()); 103 mojom::blink::RelatedApplication::New());
103 DCHECK(!relatedApplication.platform.isEmpty()); 104 DCHECK(!relatedApplication.platform.isEmpty());
104 convertedApplication->platform = relatedApplication.platform; 105 convertedApplication->platform = relatedApplication.platform;
105 convertedApplication->id = relatedApplication.id; 106 convertedApplication->id = relatedApplication.id;
106 convertedApplication->url = relatedApplication.url; 107 if (!relatedApplication.url.isNull())
108 convertedApplication->url = KURL(relatedApplication.url);
107 mojoRelatedApps.push_back(std::move(convertedApplication)); 109 mojoRelatedApps.push_back(std::move(convertedApplication));
108 } 110 }
109 111
110 if (!m_provider) { 112 if (!m_provider) {
111 supplementable()->interfaceProvider()->getInterface( 113 supplementable()->interfaceProvider()->getInterface(
112 mojo::MakeRequest(&m_provider)); 114 mojo::MakeRequest(&m_provider));
113 // TODO(mgiuca): Set a connection error handler. This requires a refactor to 115 // TODO(mgiuca): Set a connection error handler. This requires a refactor to
114 // work like NavigatorShare.cpp (retain a persistent list of clients to 116 // work like NavigatorShare.cpp (retain a persistent list of clients to
115 // reject all of their promises). 117 // reject all of their promises).
116 DCHECK(m_provider); 118 DCHECK(m_provider);
117 } 119 }
118 120
119 m_provider->FilterInstalledApps( 121 m_provider->FilterInstalledApps(
120 std::move(mojoRelatedApps), 122 std::move(mojoRelatedApps),
121 convertToBaseCallback( 123 convertToBaseCallback(
122 WTF::bind(&InstalledAppController::OnFilterInstalledApps, 124 WTF::bind(&InstalledAppController::OnFilterInstalledApps,
123 wrapPersistent(this), WTF::passed(std::move(callbacks))))); 125 wrapPersistent(this), WTF::passed(std::move(callbacks)))));
124 } 126 }
125 127
126 void InstalledAppController::OnFilterInstalledApps( 128 void InstalledAppController::OnFilterInstalledApps(
127 std::unique_ptr<blink::AppInstalledCallbacks> callbacks, 129 std::unique_ptr<blink::AppInstalledCallbacks> callbacks,
128 WTF::Vector<mojom::blink::RelatedApplicationPtr> result) { 130 WTF::Vector<mojom::blink::RelatedApplicationPtr> result) {
129 std::vector<blink::WebRelatedApplication> applications; 131 std::vector<blink::WebRelatedApplication> applications;
130 for (const auto& res : result) { 132 for (const auto& res : result) {
131 blink::WebRelatedApplication app; 133 blink::WebRelatedApplication app;
132 app.platform = res->platform; 134 app.platform = res->platform;
133 app.url = res->url; 135 if (res->url)
136 app.url = *res->url;
134 app.id = res->id; 137 app.id = res->id;
135 applications.push_back(app); 138 applications.push_back(app);
136 } 139 }
137 callbacks->onSuccess( 140 callbacks->onSuccess(
138 blink::WebVector<blink::WebRelatedApplication>(applications)); 141 blink::WebVector<blink::WebRelatedApplication>(applications));
139 } 142 }
140 143
141 DEFINE_TRACE(InstalledAppController) { 144 DEFINE_TRACE(InstalledAppController) {
142 Supplement<LocalFrame>::trace(visitor); 145 Supplement<LocalFrame>::trace(visitor);
143 ContextLifecycleObserver::trace(visitor); 146 ContextLifecycleObserver::trace(visitor);
144 } 147 }
145 148
146 } // namespace blink 149 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698