| Index: content/renderer/screen_orientation/mock_screen_orientation_controller.cc
|
| diff --git a/content/renderer/screen_orientation/mock_screen_orientation_controller.cc b/content/renderer/screen_orientation/mock_screen_orientation_controller.cc
|
| index bbff907dda565e8793d8b3539f8bbe4f78feb353..f0b1a6df4e5e3aead135ead6b4870b10cf85a06e 100644
|
| --- a/content/renderer/screen_orientation/mock_screen_orientation_controller.cc
|
| +++ b/content/renderer/screen_orientation/mock_screen_orientation_controller.cc
|
| @@ -7,12 +7,14 @@
|
| #include "base/bind.h"
|
| #include "base/logging.h"
|
| #include "base/message_loop/message_loop.h"
|
| +#include "content/renderer/render_view_impl.h"
|
| #include "third_party/WebKit/public/platform/WebScreenOrientationListener.h"
|
|
|
| namespace content {
|
|
|
| MockScreenOrientationController::MockScreenOrientationController()
|
| - : current_lock_(blink::WebScreenOrientationLockDefault),
|
| + : RenderViewObserver(NULL),
|
| + current_lock_(blink::WebScreenOrientationLockDefault),
|
| device_orientation_(blink::WebScreenOrientationPortraitPrimary),
|
| current_orientation_(blink::WebScreenOrientationPortraitPrimary),
|
| listener_(NULL) {
|
| @@ -30,6 +32,9 @@ void MockScreenOrientationController::SetListener(
|
| }
|
|
|
| void MockScreenOrientationController::ResetData() {
|
| + if (render_view_impl())
|
| + render_view_impl()->RemoveObserver(this);
|
| +
|
| current_lock_ = blink::WebScreenOrientationLockDefault;
|
| device_orientation_ = blink::WebScreenOrientationPortraitPrimary;
|
| current_orientation_ = blink::WebScreenOrientationPortraitPrimary;
|
| @@ -64,7 +69,15 @@ void MockScreenOrientationController::ResetLockSync() {
|
| }
|
|
|
| void MockScreenOrientationController::UpdateDeviceOrientation(
|
| + RenderView* render_view,
|
| blink::WebScreenOrientationType orientation) {
|
| + if (this->render_view()) {
|
| + // Make sure that render_view_ did not change during test.
|
| + DCHECK_EQ(this->render_view(), render_view);
|
| + } else {
|
| + Observe(render_view);
|
| + }
|
| +
|
| if (device_orientation_ == orientation)
|
| return;
|
| device_orientation_ = orientation;
|
| @@ -73,11 +86,18 @@ void MockScreenOrientationController::UpdateDeviceOrientation(
|
| UpdateScreenOrientation(orientation);
|
| }
|
|
|
| +RenderViewImpl* MockScreenOrientationController::render_view_impl() const {
|
| + return static_cast<RenderViewImpl*>(render_view());
|
| +}
|
| +
|
| void MockScreenOrientationController::UpdateScreenOrientation(
|
| blink::WebScreenOrientationType orientation) {
|
| if (current_orientation_ == orientation)
|
| return;
|
| current_orientation_ = orientation;
|
| + if (render_view_impl())
|
| + render_view_impl()->SetScreenOrientationForTesting(orientation);
|
| +
|
| if (listener_)
|
| listener_->didChangeScreenOrientation(current_orientation_);
|
| }
|
| @@ -124,4 +144,7 @@ MockScreenOrientationController::SuitableOrientationForCurrentLock() {
|
| }
|
| }
|
|
|
| +void MockScreenOrientationController::OnDestruct() {
|
| +}
|
| +
|
| } // namespace content
|
|
|