| 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" | 19 #include "public/platform/modules/installedapp/WebInstalledAppClient.h" |
| 20 #include "public/platform/modules/installedapp/WebRelatedApplication.h" | 20 #include "public/platform/modules/installedapp/WebRelatedApplication.h" |
| 21 #include "wtf/PtrUtil.h" |
| 21 | 22 |
| 22 namespace blink { | 23 namespace blink { |
| 23 | 24 |
| 24 NavigatorInstalledApp::NavigatorInstalledApp(LocalFrame* frame) | 25 NavigatorInstalledApp::NavigatorInstalledApp(LocalFrame* frame) |
| 25 : DOMWindowProperty(frame) | 26 : DOMWindowProperty(frame) |
| 26 { | 27 { |
| 27 } | 28 } |
| 28 | 29 |
| 29 NavigatorInstalledApp* NavigatorInstalledApp::from(Document& document) | 30 NavigatorInstalledApp* NavigatorInstalledApp::from(Document& document) |
| 30 { | 31 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 Document* document = m_frame ? m_frame->document() : 0; | 74 Document* document = m_frame ? m_frame->document() : 0; |
| 74 | 75 |
| 75 if (!document || !controller()) { | 76 if (!document || !controller()) { |
| 76 DOMException* exception = DOMException::create(InvalidStateError, "The o
bject is no longer associated to a document."); | 77 DOMException* exception = DOMException::create(InvalidStateError, "The o
bject is no longer associated to a document."); |
| 77 resolver->reject(exception); | 78 resolver->reject(exception); |
| 78 return promise; | 79 return promise; |
| 79 } | 80 } |
| 80 | 81 |
| 81 controller()->getInstalledApps( | 82 controller()->getInstalledApps( |
| 82 WebSecurityOrigin(scriptState->getExecutionContext()->getSecurityOrigin(
)), | 83 WebSecurityOrigin(scriptState->getExecutionContext()->getSecurityOrigin(
)), |
| 83 adoptWebPtr(new CallbackPromiseAdapter<RelatedAppArray, void>(resolver))
); | 84 wrapUnique(new CallbackPromiseAdapter<RelatedAppArray, void>(resolver)))
; |
| 84 return promise; | 85 return promise; |
| 85 } | 86 } |
| 86 | 87 |
| 87 InstalledAppController* NavigatorInstalledApp::controller() | 88 InstalledAppController* NavigatorInstalledApp::controller() |
| 88 { | 89 { |
| 89 if (!frame()) | 90 if (!frame()) |
| 90 return nullptr; | 91 return nullptr; |
| 91 | 92 |
| 92 return InstalledAppController::from(*frame()); | 93 return InstalledAppController::from(*frame()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 const char* NavigatorInstalledApp::supplementName() | 96 const char* NavigatorInstalledApp::supplementName() |
| 96 { | 97 { |
| 97 return "NavigatorInstalledApp"; | 98 return "NavigatorInstalledApp"; |
| 98 } | 99 } |
| 99 | 100 |
| 100 DEFINE_TRACE(NavigatorInstalledApp) | 101 DEFINE_TRACE(NavigatorInstalledApp) |
| 101 { | 102 { |
| 102 Supplement<Navigator>::trace(visitor); | 103 Supplement<Navigator>::trace(visitor); |
| 103 DOMWindowProperty::trace(visitor); | 104 DOMWindowProperty::trace(visitor); |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |