Chromium Code Reviews| 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..974fac8ac465213cc71ae46f6cde87c9117b4b65 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,8 @@ blink::WebScreenOrientationType ScreenOrientationController::orientation() const |
| return m_overrideOrientation; |
| } |
| - LocalFrame* mainFrame = m_document.frame(); |
| + ASSERT(page()); |
|
Inactive
2014/06/03 18:04:53
Why is this safe? This assertion above seems to hi
mlamouri (slow - plz ping)
2014/06/03 19:49:30
Done.
|
| + LocalFrame* mainFrame = page()->mainFrame(); |
| if (!mainFrame) |
| return blink::WebScreenOrientationPortraitPrimary; |
| blink::WebScreenOrientationType orientationType = screenOrientationType(mainFrame->view()); |
| @@ -105,4 +109,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 |