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

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

Issue 2703333002: Web Share: Refactor Mojo interface to now return an enum error. (Closed)
Patch Set: Fix assignment statement. #oops Created 3 years, 10 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
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 382e6b49e5437f0e6933ac0c52742947672b0135..23dd7e15fd6752b7da97c95703d3bcbf6a3a7d96 100644
--- a/third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp
+++ b/third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp
@@ -17,12 +17,32 @@
namespace blink {
+namespace {
+
+// Gets the human-friendly error message for a ShareError. |error| must not be
+// ShareError::OK.
+String errorToString(mojom::blink::ShareError error) {
+ switch (error) {
+ case mojom::blink::ShareError::OK:
+ NOTREACHED();
+ break;
+ case mojom::blink::ShareError::INTERNAL_ERROR:
+ return "Share failed";
+ case mojom::blink::ShareError::CANCELED:
+ return "Share canceled";
+ }
+ NOTREACHED();
+ return String();
+}
+
+} // namespace
+
class NavigatorShare::ShareClientImpl final
: public GarbageCollected<ShareClientImpl> {
public:
ShareClientImpl(NavigatorShare*, ScriptPromiseResolver*);
- void callback(const String& error);
+ void callback(mojom::blink::ShareError);
void onConnectionError();
@@ -41,15 +61,15 @@ NavigatorShare::ShareClientImpl::ShareClientImpl(
ScriptPromiseResolver* resolver)
: m_navigator(navigator_share), m_resolver(resolver) {}
-void NavigatorShare::ShareClientImpl::callback(const String& error) {
+void NavigatorShare::ShareClientImpl::callback(mojom::blink::ShareError error) {
if (m_navigator)
m_navigator->m_clients.erase(this);
- if (error.isNull()) {
+ if (error == mojom::blink::ShareError::OK) {
m_resolver->resolve();
} else {
// TODO(mgiuca): Work out which error type to use.
- m_resolver->reject(DOMException::create(AbortError, error));
+ m_resolver->reject(DOMException::create(AbortError, errorToString(error)));
}
}

Powered by Google App Engine
This is Rietveld 408576698