Chromium Code Reviews| Index: third_party/WebKit/Source/modules/installedapp/InstalledAppController.cpp |
| diff --git a/third_party/WebKit/Source/modules/installedapp/InstalledAppController.cpp b/third_party/WebKit/Source/modules/installedapp/InstalledAppController.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d59957647fe97c1370143faaa1bff755bfb48555 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/installedapp/InstalledAppController.cpp |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2016 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 "modules/installedapp/InstalledAppController.h" |
| + |
| +#include "core/frame/LocalFrame.h" |
| +#include "platform/RuntimeEnabledFeatures.h" |
| +#include "public/platform/WebSecurityOrigin.h" |
| + |
| +namespace blink { |
| + |
| +InstalledAppController::~InstalledAppController() |
| +{ |
| +} |
| + |
| +void InstalledAppController::provideTo(LocalFrame& frame, WebInstalledApp* client) |
| +{ |
| + ASSERT(RuntimeEnabledFeatures::installedAppEnabled()); |
| + |
| + OwnPtrWillBeRawPtr<InstalledAppController> controller = adoptPtrWillBeNoop(new InstalledAppController(frame, client)); |
| + WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), controller.release()); |
| +} |
| + |
| +InstalledAppController* InstalledAppController::from(LocalFrame& frame) |
| +{ |
| + InstalledAppController* controller = static_cast<InstalledAppController*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName())); |
| + ASSERT(controller); |
| + return controller; |
| +} |
| + |
| +InstalledAppController::InstalledAppController(LocalFrame& frame, WebInstalledApp* client) |
| + : LocalFrameLifecycleObserver(&frame) |
| + , m_client(client) |
| +{ |
| +} |
| + |
| +const char* InstalledAppController::supplementName() |
| +{ |
| + return "InstalledAppController"; |
| +} |
| + |
| +void InstalledAppController::getInstalledApps(const WebSecurityOrigin& url, WebPassOwnPtr<AppInstalledCallbacks> callback) |
| +{ |
| + // When detached, the client is no longer valid. |
| + if (!m_client) { |
| + 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
|
| + return; |
| + } |
| + |
| + // Client is expected to take ownership of the callback |
| + m_client->getInstalledRelatedApps(url, callback); |
| +} |
| + |
| +void InstalledAppController::willDetachFrameHost() |
| +{ |
| + m_client = nullptr; |
| +} |
| + |
| +DEFINE_TRACE(InstalledAppController) |
| +{ |
| + WillBeHeapSupplement<LocalFrame>::trace(visitor); |
| + LocalFrameLifecycleObserver::trace(visitor); |
| +} |
| + |
| +} // namespace blink |