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/NavigatorInstalledApp.h" | 5 #include "modules/installedapp/NavigatorInstalledApp.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
11 #include "core/dom/DOMException.h" | 11 #include "core/dom/DOMException.h" |
12 #include "core/dom/Document.h" | 12 #include "core/dom/Document.h" |
13 #include "core/dom/ExceptionCode.h" | 13 #include "core/dom/ExceptionCode.h" |
14 #include "core/frame/LocalDOMWindow.h" | 14 #include "core/frame/LocalDOMWindow.h" |
15 #include "core/frame/LocalFrame.h" | 15 #include "core/frame/LocalFrame.h" |
16 #include "core/frame/Navigator.h" | 16 #include "core/frame/Navigator.h" |
17 #include "modules/installedapp/InstalledAppController.h" | 17 #include "modules/installedapp/InstalledAppController.h" |
18 #include "modules/installedapp/RelatedApplication.h" | 18 #include "modules/installedapp/RelatedApplication.h" |
19 #include "public/platform/modules/installedapp/WebInstalledAppClient.h" | |
20 #include "public/platform/modules/installedapp/WebRelatedApplication.h" | 19 #include "public/platform/modules/installedapp/WebRelatedApplication.h" |
21 #include "wtf/PtrUtil.h" | 20 #include "wtf/PtrUtil.h" |
22 | 21 |
23 namespace blink { | 22 namespace blink { |
24 | 23 |
25 NavigatorInstalledApp::NavigatorInstalledApp(Navigator& navigator) | 24 NavigatorInstalledApp::NavigatorInstalledApp(Navigator& navigator) |
26 : Supplement<Navigator>(navigator) {} | 25 : Supplement<Navigator>(navigator) {} |
27 | 26 |
28 NavigatorInstalledApp* NavigatorInstalledApp::from(Document& document) { | 27 NavigatorInstalledApp* NavigatorInstalledApp::from(Document& document) { |
29 if (!document.frame() || !document.frame()->domWindow()) | 28 if (!document.frame() || !document.frame()->domWindow()) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 ScriptPromise promise = resolver->promise(); | 71 ScriptPromise promise = resolver->promise(); |
73 | 72 |
74 InstalledAppController* appController = controller(); | 73 InstalledAppController* appController = controller(); |
75 if (!appController) { // If the associated frame is detached | 74 if (!appController) { // If the associated frame is detached |
76 DOMException* exception = DOMException::create( | 75 DOMException* exception = DOMException::create( |
77 InvalidStateError, "The object is no longer associated to a document."); | 76 InvalidStateError, "The object is no longer associated to a document."); |
78 resolver->reject(exception); | 77 resolver->reject(exception); |
79 return promise; | 78 return promise; |
80 } | 79 } |
81 | 80 |
82 appController->getInstalledApps( | 81 appController->getInstalledRelatedApps( |
83 WebSecurityOrigin( | 82 scriptState->getExecutionContext()->getSecurityOrigin(), |
84 scriptState->getExecutionContext()->getSecurityOrigin()), | |
85 WTF::wrapUnique( | 83 WTF::wrapUnique( |
86 new CallbackPromiseAdapter<RelatedAppArray, void>(resolver))); | 84 new CallbackPromiseAdapter<RelatedAppArray, void>(resolver))); |
87 return promise; | 85 return promise; |
88 } | 86 } |
89 | 87 |
90 InstalledAppController* NavigatorInstalledApp::controller() { | 88 InstalledAppController* NavigatorInstalledApp::controller() { |
91 if (!supplementable()->frame()) | 89 if (!supplementable()->frame()) |
92 return nullptr; | 90 return nullptr; |
93 | 91 |
94 return InstalledAppController::from(*supplementable()->frame()); | 92 return InstalledAppController::from(*supplementable()->frame()); |
95 } | 93 } |
96 | 94 |
97 const char* NavigatorInstalledApp::supplementName() { | 95 const char* NavigatorInstalledApp::supplementName() { |
98 return "NavigatorInstalledApp"; | 96 return "NavigatorInstalledApp"; |
99 } | 97 } |
100 | 98 |
101 DEFINE_TRACE(NavigatorInstalledApp) { | 99 DEFINE_TRACE(NavigatorInstalledApp) { |
102 Supplement<Navigator>::trace(visitor); | 100 Supplement<Navigator>::trace(visitor); |
103 } | 101 } |
104 | 102 |
105 } // namespace blink | 103 } // namespace blink |
OLD | NEW |