| 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/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 return "NavigatorShare"; | 102 return "NavigatorShare"; |
| 103 } | 103 } |
| 104 | 104 |
| 105 ScriptPromise NavigatorShare::share(ScriptState* script_state, | 105 ScriptPromise NavigatorShare::share(ScriptState* script_state, |
| 106 const ShareData& share_data) { | 106 const ShareData& share_data) { |
| 107 String error_message; | 107 String error_message; |
| 108 if (!ExecutionContext::From(script_state)->IsSecureContext(error_message)) { | 108 if (!ExecutionContext::From(script_state)->IsSecureContext(error_message)) { |
| 109 DOMException* error = DOMException::Create(kSecurityError, error_message); | 109 DOMException* error = DOMException::Create(kSecurityError, error_message); |
| 110 return ScriptPromise::RejectWithDOMException(script_state, error); | 110 return ScriptPromise::RejectWithDOMException(script_state, error); |
| 111 } | 111 } |
| 112 if (!UserGestureIndicator::UtilizeUserGesture()) { | 112 if (!UserGestureIndicator::ProcessingUserGesture()) { |
| 113 DOMException* error = DOMException::Create( | 113 DOMException* error = DOMException::Create( |
| 114 kSecurityError, | 114 kSecurityError, |
| 115 "Must be handling a user gesture to perform a share request."); | 115 "Must be handling a user gesture to perform a share request."); |
| 116 return ScriptPromise::RejectWithDOMException(script_state, error); | 116 return ScriptPromise::RejectWithDOMException(script_state, error); |
| 117 } | 117 } |
| 118 | 118 |
| 119 Document* doc = ToDocument(ExecutionContext::From(script_state)); | 119 Document* doc = ToDocument(ExecutionContext::From(script_state)); |
| 120 DCHECK(doc); | 120 DCHECK(doc); |
| 121 if (!service_) { | 121 if (!service_) { |
| 122 LocalFrame* frame = doc->GetFrame(); | 122 LocalFrame* frame = doc->GetFrame(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 149 | 149 |
| 150 void NavigatorShare::OnConnectionError() { | 150 void NavigatorShare::OnConnectionError() { |
| 151 for (auto& client : clients_) { | 151 for (auto& client : clients_) { |
| 152 client->OnConnectionError(); | 152 client->OnConnectionError(); |
| 153 } | 153 } |
| 154 clients_.clear(); | 154 clients_.clear(); |
| 155 service_.reset(); | 155 service_.reset(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace blink | 158 } // namespace blink |
| OLD | NEW |