| Index: content/renderer/screen_orientation_dispatcher.cc
|
| diff --git a/content/renderer/screen_orientation_dispatcher.cc b/content/renderer/screen_orientation_dispatcher.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5b7cd4c52d4c5bf4e24512416df1a85530bb15d5
|
| --- /dev/null
|
| +++ b/content/renderer/screen_orientation_dispatcher.cc
|
| @@ -0,0 +1,67 @@
|
| +// 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.
|
| +
|
| +#include "content/renderer/screen_orientation_dispatcher.h"
|
| +
|
| +#include "content/common/view_messages.h"
|
| +#include "content/renderer/render_thread_impl.h"
|
| +#include "content/renderer/render_view_impl.h"
|
| +#include "ipc/ipc_channel.h"
|
| +#include "ipc/ipc_message_utils.h"
|
| +#include "third_party/WebKit/public/web/WebScreenOrientationController.h"
|
| +
|
| +namespace content {
|
| +
|
| +ScreenOrientationDispatcher::ScreenOrientationDispatcher(
|
| + RenderViewImpl* render_view)
|
| + : RenderViewObserver(render_view),
|
| + controller_(NULL) {
|
| +}
|
| +
|
| +void ScreenOrientationDispatcher::OrientationChangeEvent(int orientation) {
|
| + if (!controller_)
|
| + return;
|
| +
|
| + blink::WebScreenOrientation web_orientation;
|
| + switch(orientation) {
|
| + case 90:
|
| + web_orientation = blink::WebScreenOrientationLandscapePrimary;
|
| + break;
|
| + case 180:
|
| + web_orientation = blink::WebScreenOrientationPortraitSecondary;
|
| + break;
|
| + case 270:
|
| + case -90:
|
| + web_orientation = blink::WebScreenOrientationLandscapeSecondary;
|
| + break;
|
| + case 0:
|
| + default:
|
| + web_orientation = blink::WebScreenOrientationPortraitPrimary;
|
| + }
|
| +
|
| + controller_->orientationChanged(web_orientation);
|
| +}
|
| +
|
| +bool ScreenOrientationDispatcher::lockOrientation(
|
| + blink::WebScreenOrientations lock) {
|
| + bool result = false;
|
| +
|
| + IPC::Message* msg = new ViewHostMsg_LockScreenOrientation(lock, &result);
|
| + if (!RenderThread::Get()->Send(msg))
|
| + return false;
|
| +
|
| + return result;
|
| +}
|
| +
|
| +void ScreenOrientationDispatcher::unlockOrientation() {
|
| + IPC::Message* msg = new ViewHostMsg_UnlockScreenOrientation();
|
| + RenderThread::Get()->Send(msg);
|
| +}
|
| +
|
| +void ScreenOrientationDispatcher::setController(
|
| + blink::WebScreenOrientationController* controller) {
|
| + controller_ = controller;
|
| +}
|
| +
|
| +} // namespace content
|
|
|