Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 InstalledAppController* controller = new InstalledAppController(frame, clien t); | |
| 22 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), adoptPt rWillBeNoop(controller)); | |
|
haraken
2016/02/27 15:53:11
OwnPtr<InstalledAppController> controllers = adopt
Daniel Nishi
2016/02/29 18:38:38
.release() for an OwnPtr is an OwnPtr, whereas pro
| |
| 23 } | |
| 24 | |
| 25 InstalledAppController* InstalledAppController::from(LocalFrame& frame) | |
| 26 { | |
| 27 return static_cast<InstalledAppController*>(WillBeHeapSupplement<LocalFrame> ::from(frame, supplementName())); | |
|
haraken
2016/02/27 15:53:11
Can we add an assert to check that the returned In
Daniel Nishi
2016/02/29 18:38:39
Done.
| |
| 28 } | |
| 29 | |
| 30 InstalledAppController::InstalledAppController(LocalFrame& frame, WebInstalledAp p* client) | |
| 31 : LocalFrameLifecycleObserver(&frame) | |
| 32 , m_client(client) | |
| 33 { | |
| 34 } | |
| 35 | |
| 36 const char* InstalledAppController::supplementName() | |
| 37 { | |
| 38 return "InstalledAppController"; | |
| 39 } | |
| 40 | |
| 41 void InstalledAppController::getInstalledApps(const WebSecurityOrigin& url, AppI nstalledCallbacks* callback) | |
| 42 { | |
| 43 // When detached, the client is no longer valid. | |
| 44 if (!m_client) { | |
| 45 callback->onError(); | |
| 46 delete callback; | |
|
haraken
2016/02/27 15:53:11
It's really nasty to call delete manually... Can w
Daniel Nishi
2016/02/29 18:38:38
Done.
| |
| 47 return; | |
| 48 } | |
| 49 | |
| 50 // Client is expected to take ownership of the callback | |
| 51 m_client->getInstalledRelatedApps(url, callback); | |
| 52 } | |
| 53 | |
| 54 void InstalledAppController::willDetachFrameHost() | |
| 55 { | |
| 56 m_client = nullptr; | |
| 57 } | |
| 58 | |
| 59 DEFINE_TRACE(InstalledAppController) | |
| 60 { | |
| 61 WillBeHeapSupplement<LocalFrame>::trace(visitor); | |
| 62 LocalFrameLifecycleObserver::trace(visitor); | |
| 63 } | |
| 64 | |
| 65 } // namespace blink | |
| OLD | NEW |