| 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/webshare/NavigatorShare.h" | 5 #include "modules/webshare/NavigatorShare.h" |
| 6 | 6 |
| 7 #include "core/dom/DOMException.h" | 7 #include "core/dom/DOMException.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 m_service.set_connection_error_handler(convertToBaseCallback(WTF::bind( | 104 m_service.set_connection_error_handler(convertToBaseCallback(WTF::bind( |
| 105 &NavigatorShare::onConnectionError, wrapWeakPersistent(this)))); | 105 &NavigatorShare::onConnectionError, wrapWeakPersistent(this)))); |
| 106 DCHECK(m_service); | 106 DCHECK(m_service); |
| 107 } | 107 } |
| 108 | 108 |
| 109 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 109 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 110 ShareClientImpl* client = new ShareClientImpl(this, resolver); | 110 ShareClientImpl* client = new ShareClientImpl(this, resolver); |
| 111 m_clients.insert(client); | 111 m_clients.insert(client); |
| 112 ScriptPromise promise = resolver->promise(); | 112 ScriptPromise promise = resolver->promise(); |
| 113 | 113 |
| 114 m_service->Share(shareData.hasTitle() ? shareData.title() : emptyString(), | 114 m_service->Share(shareData.hasTitle() ? shareData.title() : emptyString, |
| 115 shareData.hasText() ? shareData.text() : emptyString(), | 115 shareData.hasText() ? shareData.text() : emptyString, |
| 116 doc->completeURL(shareData.url()), | 116 doc->completeURL(shareData.url()), |
| 117 convertToBaseCallback(WTF::bind(&ShareClientImpl::callback, | 117 convertToBaseCallback(WTF::bind(&ShareClientImpl::callback, |
| 118 wrapPersistent(client)))); | 118 wrapPersistent(client)))); |
| 119 | 119 |
| 120 return promise; | 120 return promise; |
| 121 } | 121 } |
| 122 | 122 |
| 123 ScriptPromise NavigatorShare::share(ScriptState* scriptState, | 123 ScriptPromise NavigatorShare::share(ScriptState* scriptState, |
| 124 Navigator& navigator, | 124 Navigator& navigator, |
| 125 const ShareData& shareData) { | 125 const ShareData& shareData) { |
| 126 return from(navigator).share(scriptState, shareData); | 126 return from(navigator).share(scriptState, shareData); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void NavigatorShare::onConnectionError() { | 129 void NavigatorShare::onConnectionError() { |
| 130 for (auto& client : m_clients) { | 130 for (auto& client : m_clients) { |
| 131 client->onConnectionError(); | 131 client->onConnectionError(); |
| 132 } | 132 } |
| 133 m_clients.clear(); | 133 m_clients.clear(); |
| 134 m_service.reset(); | 134 m_service.reset(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace blink | 137 } // namespace blink |
| OLD | NEW |