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

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

Issue 1735033004: Bindings and client interface for the IsAppInstalled API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "modules/installedapp/InstalledAppController.h"
6
7 #include "core/frame/LocalFrame.h"
8 #include "platform/RuntimeEnabledFeatures.h"
9 #include "public/platform/WebSecurityOrigin.h"
10
11 namespace blink {
12
13 InstalledAppController::~InstalledAppController()
14 {
15 }
16
17 void InstalledAppController::provideTo(LocalFrame& frame, WebInstalledApp* clien t)
18 {
19 ASSERT(RuntimeEnabledFeatures::installedAppEnabled());
20
21 OwnPtrWillBeRawPtr<InstalledAppController> controller = adoptPtrWillBeNoop(n ew InstalledAppController(frame, client));
22 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), control ler.release());
23 }
24
25 InstalledAppController* InstalledAppController::from(LocalFrame& frame)
26 {
27 InstalledAppController* controller = static_cast<InstalledAppController*>(Wi llBeHeapSupplement<LocalFrame>::from(frame, supplementName()));
28 ASSERT(controller);
29 return controller;
30 }
31
32 InstalledAppController::InstalledAppController(LocalFrame& frame, WebInstalledAp p* client)
33 : LocalFrameLifecycleObserver(&frame)
34 , m_client(client)
35 {
36 }
37
38 const char* InstalledAppController::supplementName()
39 {
40 return "InstalledAppController";
41 }
42
43 void InstalledAppController::getInstalledApps(const WebSecurityOrigin& url, WebP assOwnPtr<AppInstalledCallbacks> callback)
44 {
45 // When detached, the client is no longer valid.
46 if (!m_client) {
47 callback.release()->onError();
haraken 2016/03/01 02:15:25 callback->onError()
Daniel Nishi 2016/03/01 20:46:20 WebPassOwnPtr doesn't seem to let us use the arrow
48 return;
49 }
50
51 // Client is expected to take ownership of the callback
52 m_client->getInstalledRelatedApps(url, callback);
53 }
54
55 void InstalledAppController::willDetachFrameHost()
56 {
57 m_client = nullptr;
58 }
59
60 DEFINE_TRACE(InstalledAppController)
61 {
62 WillBeHeapSupplement<LocalFrame>::trace(visitor);
63 LocalFrameLifecycleObserver::trace(visitor);
64 }
65
66 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698