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

Unified Diff: Source/modules/screen_orientation/ScreenOrientationController.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/ScreenOrientationController.cpp
diff --git a/Source/modules/screen_orientation/ScreenOrientationController.cpp b/Source/modules/screen_orientation/ScreenOrientationController.cpp
index ce82d2e80e7b59d1cd00c3cabf1a7f5f50dcac35..65adbf279560cb2eac5f8f5658391f351098dcc8 100644
--- a/Source/modules/screen_orientation/ScreenOrientationController.cpp
+++ b/Source/modules/screen_orientation/ScreenOrientationController.cpp
@@ -13,6 +13,8 @@
#include "core/page/Page.h"
#include "platform/LayoutTestSupport.h"
#include "platform/PlatformScreen.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebScreenOrientationClient.h"
namespace WebCore {
@@ -20,20 +22,21 @@ ScreenOrientationController::~ScreenOrientationController()
{
}
-ScreenOrientationController& ScreenOrientationController::from(Document& document)
+void ScreenOrientationController::provideTo(Page& page, blink::WebScreenOrientationClient* client)
{
- ScreenOrientationController* controller = static_cast<ScreenOrientationController*>(DocumentSupplement::from(document, supplementName()));
- if (!controller) {
- controller = new ScreenOrientationController(document);
- DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBeNoop(controller));
- }
- return *controller;
+ ScreenOrientationController* controller = new ScreenOrientationController(page, client);
+ WillBeHeapSupplement<Page>::provideTo(page, supplementName(), adoptPtrWillBeNoop(controller));
+}
+
+ScreenOrientationController& ScreenOrientationController::from(Page& page)
+{
+ return *static_cast<ScreenOrientationController*>(WillBeHeapSupplement<Page>::from(page, supplementName()));
}
-ScreenOrientationController::ScreenOrientationController(Document& document)
- : PageLifecycleObserver(document.page())
- , m_document(document)
+ScreenOrientationController::ScreenOrientationController(Page& page, blink::WebScreenOrientationClient* client)
+ : PageLifecycleObserver(&page)
, m_overrideOrientation(blink::WebScreenOrientationUndefined)
+ , m_client(client)
{
}
@@ -74,7 +77,7 @@ void ScreenOrientationController::pageVisibilityChanged()
if (page() && page()->visibilityState() == PageVisibilityStateVisible) {
blink::WebScreenOrientationType oldOrientation = m_overrideOrientation;
m_overrideOrientation = blink::WebScreenOrientationUndefined;
- LocalFrame* mainFrame = m_document.frame();
+ LocalFrame* mainFrame = page()->mainFrame();
if (mainFrame && oldOrientation != orientation())
mainFrame->sendOrientationChangeEvent();
} else if (m_overrideOrientation == blink::WebScreenOrientationUndefined) {
@@ -93,7 +96,7 @@ blink::WebScreenOrientationType ScreenOrientationController::orientation() const
return m_overrideOrientation;
}
- LocalFrame* mainFrame = m_document.frame();
+ LocalFrame* mainFrame = page() ? page()->mainFrame() : 0;
if (!mainFrame)
return blink::WebScreenOrientationPortraitPrimary;
blink::WebScreenOrientationType orientationType = screenOrientationType(mainFrame->view());
@@ -105,4 +108,26 @@ blink::WebScreenOrientationType ScreenOrientationController::orientation() const
return orientationType;
}
+void ScreenOrientationController::lockOrientation(blink::WebScreenOrientationLockType orientation, blink::WebLockOrientationCallback* callback)
+{
+ if (!m_client) {
+ // FIXME: temporary until the content layer gets updated.
+ blink::Platform::current()->lockOrientation(orientation, callback);
+ return;
+ }
+
+ m_client->lockOrientation(orientation, callback);
+}
+
+void ScreenOrientationController::unlockOrientation()
+{
+ if (!m_client) {
+ // FIXME: temporary until the content layer gets updated.
+ blink::Platform::current()->unlockOrientation();
+ return;
+ }
+
+ m_client->unlockOrientation();
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698