Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(928)

Unified Diff: third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp

Issue 2314573002: Don't expose webshare from the browser when the origin trial disables it. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webshare/NavigatorShare.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp
diff --git a/third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp b/third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp
index 74124c9ee9db4cc7a3e5883071a52667af8c6874..fdc669c2ab98df6b9e01cab11e6f541d129d302b 100644
--- a/third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp
+++ b/third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp
@@ -24,6 +24,8 @@ class NavigatorShare::ShareClientImpl final
void callback(const String& error);
+ void onConnectionError();
+
DEFINE_INLINE_TRACE() {
visitor->trace(m_navigator);
visitor->trace(m_resolver);
@@ -51,6 +53,11 @@ void NavigatorShare::ShareClientImpl::callback(const String& error) {
}
}
+void NavigatorShare::ShareClientImpl::onConnectionError() {
+ m_resolver->reject(
+ DOMException::create(SecurityError, "WebShare is disabled."));
+}
+
NavigatorShare::~NavigatorShare() = default;
NavigatorShare& NavigatorShare::from(Navigator& navigator) {
@@ -94,6 +101,8 @@ ScriptPromise NavigatorShare::share(ScriptState* scriptState,
LocalFrame* frame = doc->frame();
DCHECK(frame);
frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_service));
+ m_service.set_connection_error_handler(convertToBaseCallback(WTF::bind(
+ &NavigatorShare::onConnectionError, wrapWeakPersistent(this))));
DCHECK(m_service);
}
@@ -117,4 +126,12 @@ ScriptPromise NavigatorShare::share(ScriptState* scriptState,
return from(navigator).share(scriptState, shareData);
}
+void NavigatorShare::onConnectionError() {
+ for (auto& client : m_clients) {
+ client->onConnectionError();
+ }
+ m_clients.clear();
+ m_service.reset();
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/webshare/NavigatorShare.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698