Commit 89fa7447 authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Add a WebLockOrientationError independant from WebLockOrientationCallback.

So we don't need to include WebLockOrientationCallback in places where
we should only include enums.

BUG=162827
NOTRY=true

Review URL: https://codereview.chromium.org/332493003

git-svn-id: svn://svn.chromium.org/blink/trunk@176510 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 618913ec
...@@ -52,4 +52,27 @@ void LockOrientationCallback::onError(ErrorType error) ...@@ -52,4 +52,27 @@ void LockOrientationCallback::onError(ErrorType error)
m_resolver->reject(DOMException::create(code, msg)); m_resolver->reject(DOMException::create(code, msg));
} }
void LockOrientationCallback::onError(blink::WebLockOrientationError error)
{
ExceptionCode code = 0;
String msg = "";
switch (error) {
case blink::WebLockOrientationErrorNotAvailable:
code = NotSupportedError;
msg = "lockOrientation() is not available on this device.";
break;
case blink::WebLockOrientationErrorFullScreenRequired:
code = SecurityError;
msg = "The page needs to be fullscreen in order to call lockOrientation().";
break;
case blink::WebLockOrientationErrorCanceled:
code = AbortError;
msg = "A call to lockOrientation() or unlockOrientation() canceled this call.";
break;
}
m_resolver->reject(DOMException::create(code, msg));
}
} // namespace WebCore } // namespace WebCore
...@@ -26,6 +26,7 @@ public: ...@@ -26,6 +26,7 @@ public:
virtual void onSuccess(unsigned angle, blink::WebScreenOrientationType) OVERRIDE; virtual void onSuccess(unsigned angle, blink::WebScreenOrientationType) OVERRIDE;
virtual void onError(ErrorType) OVERRIDE; virtual void onError(ErrorType) OVERRIDE;
virtual void onError(blink::WebLockOrientationError) OVERRIDE;
private: private:
RefPtr<ScriptPromiseResolverWithContext> m_resolver; RefPtr<ScriptPromiseResolverWithContext> m_resolver;
...@@ -34,4 +35,3 @@ private: ...@@ -34,4 +35,3 @@ private:
} // namespace WebCore } // namespace WebCore
#endif // LockOrientationCallback_h #endif // LockOrientationCallback_h
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef WebLockOrientationCallback_h #ifndef WebLockOrientationCallback_h
#define WebLockOrientationCallback_h #define WebLockOrientationCallback_h
#include "public/platform/WebLockOrientationError.h"
#include "public/platform/WebScreenOrientationType.h" #include "public/platform/WebScreenOrientationType.h"
namespace blink { namespace blink {
...@@ -25,7 +26,11 @@ public: ...@@ -25,7 +26,11 @@ public:
virtual ~WebLockOrientationCallback() { } virtual ~WebLockOrientationCallback() { }
virtual void onSuccess(unsigned angle, WebScreenOrientationType) = 0; virtual void onSuccess(unsigned angle, WebScreenOrientationType) = 0;
virtual void onError(ErrorType) = 0;
// FIXME: those methods are defined and not virtual pure to not break the
// embedder during the transition period.
virtual void onError(ErrorType) { }
virtual void onError(WebLockOrientationError) { }
}; };
} // namespace blink } // namespace blink
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WebLockOrientationError_h
#define WebLockOrientationError_h
namespace blink {
enum WebLockOrientationError {
// If locking isn't available on the platform.
WebLockOrientationErrorNotAvailable,
// If fullscreen is required to lock.
WebLockOrientationErrorFullScreenRequired,
// If another lock/unlock got called before that one ended.
WebLockOrientationErrorCanceled,
};
} // namespace blink
#endif // WebLockOrientationError_h
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment