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

Side by Side Diff: content/renderer/screen_orientation_dispatcher.cc

Issue 150153004: [WIP] Add Chromium-side support for the Screen Orientation API (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/screen_orientation_dispatcher.h"
6
7 #include "content/common/view_messages.h"
8 #include "content/renderer/render_thread_impl.h"
9 #include "content/renderer/render_view_impl.h"
10 #include "ipc/ipc_channel.h"
11 #include "ipc/ipc_message_utils.h"
12 #include "third_party/WebKit/public/web/WebScreenOrientationController.h"
13
14 namespace content {
15
16 ScreenOrientationDispatcher::ScreenOrientationDispatcher(
17 RenderViewImpl* render_view)
18 : RenderViewObserver(render_view),
19 controller_(NULL) {
20 }
21
22 void ScreenOrientationDispatcher::OrientationChangeEvent(int orientation) {
23 if (!controller_)
24 return;
25
26 blink::WebScreenOrientation web_orientation;
27 switch(orientation) {
28 case 90:
29 web_orientation = blink::WebScreenOrientationLandscapePrimary;
30 break;
31 case 180:
32 web_orientation = blink::WebScreenOrientationPortraitSecondary;
33 break;
34 case 270:
35 case -90:
36 web_orientation = blink::WebScreenOrientationLandscapeSecondary;
37 break;
38 case 0:
39 default:
40 web_orientation = blink::WebScreenOrientationPortraitPrimary;
41 }
42
43 controller_->orientationChanged(web_orientation);
kenneth.r.christiansen 2014/02/06 15:03:12 are you making sure this is sent as the same time
ostap 2014/02/06 21:23:28 At least it is hooked at the same RenderViewImpl::
44 }
45
46 bool ScreenOrientationDispatcher::lockOrientation(
47 blink::WebScreenOrientations lock) {
48 bool result = false;
49
50 IPC::Message* msg = new ViewHostMsg_LockScreenOrientation(lock, &result);
51 if (!RenderThread::Get()->Send(msg))
52 return false;
53
54 return result;
55 }
56
57 void ScreenOrientationDispatcher::unlockOrientation() {
58 IPC::Message* msg = new ViewHostMsg_UnlockScreenOrientation();
59 RenderThread::Get()->Send(msg);
60 }
61
62 void ScreenOrientationDispatcher::setController(
63 blink::WebScreenOrientationController* controller) {
64 controller_ = controller;
65 }
66
67 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698