| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 m_resolver->reject( | 57 m_resolver->reject( |
| 58 DOMException::create(SecurityError, "WebShare is disabled.")); | 58 DOMException::create(SecurityError, "WebShare is disabled.")); |
| 59 } | 59 } |
| 60 | 60 |
| 61 NavigatorShare::~NavigatorShare() = default; | 61 NavigatorShare::~NavigatorShare() = default; |
| 62 | 62 |
| 63 NavigatorShare& NavigatorShare::from(Navigator& navigator) { | 63 NavigatorShare& NavigatorShare::from(Navigator& navigator) { |
| 64 NavigatorShare* supplement = static_cast<NavigatorShare*>( | 64 NavigatorShare* supplement = static_cast<NavigatorShare*>( |
| 65 Supplement<Navigator>::from(navigator, supplementName())); | 65 Supplement<Navigator>::from(navigator, supplementName())); |
| 66 if (!supplement) { | 66 if (!supplement) { |
| 67 supplement = new NavigatorShare(); | 67 supplement = new NavigatorShare(navigator); |
| 68 provideTo(navigator, supplementName(), supplement); | 68 provideTo(navigator, supplementName(), supplement); |
| 69 } | 69 } |
| 70 return *supplement; | 70 return *supplement; |
| 71 } | 71 } |
| 72 | 72 |
| 73 DEFINE_TRACE(NavigatorShare) { | 73 DEFINE_TRACE(NavigatorShare) { |
| 74 visitor->trace(m_clients); | 74 visitor->trace(m_clients); |
| 75 Supplement<Navigator>::trace(visitor); | 75 Supplement<Navigator>::trace(visitor); |
| 76 } | 76 } |
| 77 | 77 |
| 78 NavigatorShare::NavigatorShare() {} | 78 NavigatorShare::NavigatorShare(Navigator& navigator) |
| 79 : Supplement<Navigator>(navigator) {} |
| 79 | 80 |
| 80 const char* NavigatorShare::supplementName() { | 81 const char* NavigatorShare::supplementName() { |
| 81 return "NavigatorShare"; | 82 return "NavigatorShare"; |
| 82 } | 83 } |
| 83 | 84 |
| 84 ScriptPromise NavigatorShare::share(ScriptState* scriptState, | 85 ScriptPromise NavigatorShare::share(ScriptState* scriptState, |
| 85 const ShareData& shareData) { | 86 const ShareData& shareData) { |
| 86 String errorMessage; | 87 String errorMessage; |
| 87 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) { | 88 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) { |
| 88 DOMException* error = DOMException::create(SecurityError, errorMessage); | 89 DOMException* error = DOMException::create(SecurityError, errorMessage); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 134 } |
| 134 | 135 |
| 135 for (auto& client : m_clients) { | 136 for (auto& client : m_clients) { |
| 136 client->onConnectionError(); | 137 client->onConnectionError(); |
| 137 } | 138 } |
| 138 m_clients.clear(); | 139 m_clients.clear(); |
| 139 m_service.reset(); | 140 m_service.reset(); |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |