OLD | NEW |
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 "public/platform/WebSecurityOrigin.h" | 10 #include "public/platform/WebSecurityOrigin.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 InstalledAppController* InstalledAppController::from(LocalFrame& frame) { | 27 InstalledAppController* InstalledAppController::from(LocalFrame& frame) { |
28 InstalledAppController* controller = static_cast<InstalledAppController*>( | 28 InstalledAppController* controller = static_cast<InstalledAppController*>( |
29 Supplement<LocalFrame>::from(frame, supplementName())); | 29 Supplement<LocalFrame>::from(frame, supplementName())); |
30 ASSERT(controller); | 30 ASSERT(controller); |
31 return controller; | 31 return controller; |
32 } | 32 } |
33 | 33 |
34 InstalledAppController::InstalledAppController(LocalFrame& frame, | 34 InstalledAppController::InstalledAppController(LocalFrame& frame, |
35 WebInstalledAppClient* client) | 35 WebInstalledAppClient* client) |
36 : ContextLifecycleObserver(frame.document()), m_client(client) {} | 36 : Supplement<LocalFrame>(frame), |
| 37 ContextLifecycleObserver(frame.document()), |
| 38 m_client(client) {} |
37 | 39 |
38 const char* InstalledAppController::supplementName() { | 40 const char* InstalledAppController::supplementName() { |
39 return "InstalledAppController"; | 41 return "InstalledAppController"; |
40 } | 42 } |
41 | 43 |
42 void InstalledAppController::getInstalledApps( | 44 void InstalledAppController::getInstalledApps( |
43 const WebSecurityOrigin& url, | 45 const WebSecurityOrigin& url, |
44 std::unique_ptr<AppInstalledCallbacks> callback) { | 46 std::unique_ptr<AppInstalledCallbacks> callback) { |
45 // When detached, the client is no longer valid. | 47 // When detached, the client is no longer valid. |
46 if (!m_client) { | 48 if (!m_client) { |
47 callback.release()->onError(); | 49 callback.release()->onError(); |
48 return; | 50 return; |
49 } | 51 } |
50 | 52 |
51 // Client is expected to take ownership of the callback | 53 // Client is expected to take ownership of the callback |
52 m_client->getInstalledRelatedApps(url, std::move(callback)); | 54 m_client->getInstalledRelatedApps(url, std::move(callback)); |
53 } | 55 } |
54 | 56 |
55 void InstalledAppController::contextDestroyed() { | 57 void InstalledAppController::contextDestroyed() { |
56 m_client = nullptr; | 58 m_client = nullptr; |
57 } | 59 } |
58 | 60 |
59 DEFINE_TRACE(InstalledAppController) { | 61 DEFINE_TRACE(InstalledAppController) { |
60 Supplement<LocalFrame>::trace(visitor); | 62 Supplement<LocalFrame>::trace(visitor); |
61 ContextLifecycleObserver::trace(visitor); | 63 ContextLifecycleObserver::trace(visitor); |
62 } | 64 } |
63 | 65 |
64 } // namespace blink | 66 } // namespace blink |
OLD | NEW |