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.
5 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
7 #include "content/browser/screen_orientation/screen_orientation_provider.h"
8 #include "content/common/screen_orientation_messages.h"
12 ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost()
13 : BrowserMessageFilter(ScreenOrientationMsgStart
) {
15 provider_
.reset(CreateProvider());
18 ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() {
21 bool ScreenOrientationDispatcherHost::OnMessageReceived(
22 const IPC::Message
& message
, bool* message_was_ok
) {
25 IPC_BEGIN_MESSAGE_MAP_EX(ScreenOrientationDispatcherHost
,
28 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Lock
, OnLockRequest
)
29 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Unlock
, OnUnlockRequest
)
30 IPC_MESSAGE_UNHANDLED(handled
= false)
31 IPC_END_MESSAGE_MAP_EX()
36 void ScreenOrientationDispatcherHost::OnOrientationChange(
37 blink::WebScreenOrientationType orientation
) {
38 Send(new ScreenOrientationMsg_OrientationChange(orientation
));
41 void ScreenOrientationDispatcherHost::SetProviderForTests(
42 ScreenOrientationProvider
* provider
) {
43 provider_
.reset(provider
);
46 void ScreenOrientationDispatcherHost::OnLockRequest(
47 blink::WebScreenOrientationLockType orientation
) {
51 provider_
->LockOrientation(orientation
);
54 void ScreenOrientationDispatcherHost::OnUnlockRequest() {
58 provider_
->UnlockOrientation();
61 #if !defined(OS_ANDROID)
63 ScreenOrientationProvider
* ScreenOrientationDispatcherHost::CreateProvider() {
68 } // namespace content