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

Unified Diff: Source/modules/screen_orientation/ScreenOrientation.cpp

Issue 315693002: Use WebViewClient instead of BlinkPlatform for screen lock. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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: Source/modules/screen_orientation/ScreenOrientation.cpp
diff --git a/Source/modules/screen_orientation/ScreenOrientation.cpp b/Source/modules/screen_orientation/ScreenOrientation.cpp
index 504fda15eaa2df75458e48db0fe92d019ee14df8..211395523adad830d18c349b1b49c5fa393864fe 100644
--- a/Source/modules/screen_orientation/ScreenOrientation.cpp
+++ b/Source/modules/screen_orientation/ScreenOrientation.cpp
@@ -13,9 +13,9 @@
#include "core/frame/DOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Screen.h"
+#include "core/page/Page.h"
#include "modules/screen_orientation/LockOrientationCallback.h"
#include "modules/screen_orientation/ScreenOrientationController.h"
-#include "public/platform/Platform.h"
#include "public/platform/WebScreenOrientationType.h"
// This code assumes that WebScreenOrientationType values are included in WebScreenOrientationLockType.
@@ -101,6 +101,13 @@ Document* ScreenOrientation::document() const
return m_associatedDOMWindow->document();
}
+Page* ScreenOrientation::page() const
+{
+ if (!frame())
+ return 0;
+ return frame()->page();
+}
+
ScreenOrientation& ScreenOrientation::from(Screen& screen)
{
ScreenOrientation* supplement = static_cast<ScreenOrientation*>(WillBeHeapSupplement<Screen>::from(screen, supplementName()));
@@ -118,11 +125,11 @@ ScreenOrientation::~ScreenOrientation()
const AtomicString& ScreenOrientation::orientation(Screen& screen)
{
ScreenOrientation& screenOrientation = ScreenOrientation::from(screen);
- if (!screenOrientation.document()) {
+ if (!screenOrientation.page()) {
// FIXME: we should try to return a better guess, like the latest known value.
return orientationTypeToString(blink::WebScreenOrientationPortraitPrimary);
}
- ScreenOrientationController& controller = ScreenOrientationController::from(*screenOrientation.document());
+ ScreenOrientationController& controller = ScreenOrientationController::from(*screenOrientation.page());
eseidel 2014/06/03 20:57:49 I would just have an accessor for the controller i
dcheng 2014/06/03 21:02:04 I don't think it's clear what the plan is yet so j
return orientationTypeToString(controller.orientation());
}
@@ -134,7 +141,7 @@ ScriptPromise ScreenOrientation::lockOrientation(ScriptState* state, Screen& scr
ScreenOrientation& screenOrientation = ScreenOrientation::from(screen);
Document* document = screenOrientation.document();
- if (!document) {
+ if (!document || !screenOrientation.page()) {
RefPtrWillBeRawPtr<DOMException> exception = DOMException::create(InvalidStateError, "The object is no longer associated to a document.");
resolver->reject(exception);
return promise;
@@ -146,13 +153,17 @@ ScriptPromise ScreenOrientation::lockOrientation(ScriptState* state, Screen& scr
return promise;
}
- blink::Platform::current()->lockOrientation(stringToOrientationLock(lockString), new LockOrientationCallback(resolver));
+ ScreenOrientationController::from(*screenOrientation.page()).lockOrientation(stringToOrientationLock(lockString), new LockOrientationCallback(resolver));
return promise;
}
void ScreenOrientation::unlockOrientation(Screen& screen)
{
- blink::Platform::current()->unlockOrientation();
+ ScreenOrientation& screenOrientation = ScreenOrientation::from(screen);
+ if (!screenOrientation.page())
+ return;
+
+ ScreenOrientationController::from(*screenOrientation.page()).unlockOrientation();
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698