| 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(navigator); | 67 supplement = new NavigatorShare(); |
| 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(Navigator& navigator) | 78 NavigatorShare::NavigatorShare() {} |
| 79 : Supplement<Navigator>(navigator) {} | |
| 80 | 79 |
| 81 const char* NavigatorShare::supplementName() { | 80 const char* NavigatorShare::supplementName() { |
| 82 return "NavigatorShare"; | 81 return "NavigatorShare"; |
| 83 } | 82 } |
| 84 | 83 |
| 85 ScriptPromise NavigatorShare::share(ScriptState* scriptState, | 84 ScriptPromise NavigatorShare::share(ScriptState* scriptState, |
| 86 const ShareData& shareData) { | 85 const ShareData& shareData) { |
| 87 String errorMessage; | 86 String errorMessage; |
| 88 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) { | 87 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) { |
| 89 DOMException* error = DOMException::create(SecurityError, errorMessage); | 88 DOMException* error = DOMException::create(SecurityError, errorMessage); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 133 } |
| 135 | 134 |
| 136 for (auto& client : m_clients) { | 135 for (auto& client : m_clients) { |
| 137 client->onConnectionError(); | 136 client->onConnectionError(); |
| 138 } | 137 } |
| 139 m_clients.clear(); | 138 m_clients.clear(); |
| 140 m_service.reset(); | 139 m_service.reset(); |
| 141 } | 140 } |
| 142 | 141 |
| 143 } // namespace blink | 142 } // namespace blink |
| OLD | NEW |