| 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" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 return applications; | 64 return applications; |
| 65 } | 65 } |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 ScriptPromise NavigatorInstalledApp::getInstalledRelatedApps(ScriptState* script
State) | 68 ScriptPromise NavigatorInstalledApp::getInstalledRelatedApps(ScriptState* script
State) |
| 69 { | 69 { |
| 70 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 70 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 71 ScriptPromise promise = resolver->promise(); | 71 ScriptPromise promise = resolver->promise(); |
| 72 | 72 |
| 73 // Don't crash when called and unattached to document. | 73 // Don't crash when called and unattached to document. |
| 74 Document* document = m_frame ? m_frame->document() : 0; | 74 Document* document = frame() ? frame()->document() : 0; |
| 75 | 75 |
| 76 if (!document || !controller()) { | 76 if (!document || !controller()) { |
| 77 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."); |
| 78 resolver->reject(exception); | 78 resolver->reject(exception); |
| 79 return promise; | 79 return promise; |
| 80 } | 80 } |
| 81 | 81 |
| 82 controller()->getInstalledApps( | 82 controller()->getInstalledApps( |
| 83 WebSecurityOrigin(scriptState->getExecutionContext()->getSecurityOrigin(
)), | 83 WebSecurityOrigin(scriptState->getExecutionContext()->getSecurityOrigin(
)), |
| 84 wrapUnique(new CallbackPromiseAdapter<RelatedAppArray, void>(resolver)))
; | 84 wrapUnique(new CallbackPromiseAdapter<RelatedAppArray, void>(resolver)))
; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 98 return "NavigatorInstalledApp"; | 98 return "NavigatorInstalledApp"; |
| 99 } | 99 } |
| 100 | 100 |
| 101 DEFINE_TRACE(NavigatorInstalledApp) | 101 DEFINE_TRACE(NavigatorInstalledApp) |
| 102 { | 102 { |
| 103 Supplement<Navigator>::trace(visitor); | 103 Supplement<Navigator>::trace(visitor); |
| 104 DOMWindowProperty::trace(visitor); | 104 DOMWindowProperty::trace(visitor); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |