Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / content / browser / screen_orientation / screen_orientation_dispatcher_host.cc
blobfc443ecf5dfe92a2be747f76d51019e0de39b567
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"
10 namespace content {
12 ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost()
13 : BrowserMessageFilter(ScreenOrientationMsgStart) {
14 if (!provider_.get())
15 provider_.reset(CreateProvider());
18 ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() {
21 bool ScreenOrientationDispatcherHost::OnMessageReceived(
22 const IPC::Message& message, bool* message_was_ok) {
23 bool handled = true;
25 IPC_BEGIN_MESSAGE_MAP_EX(ScreenOrientationDispatcherHost,
26 message,
27 *message_was_ok)
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()
33 return handled;
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) {
48 if (!provider_.get())
49 return;
51 provider_->LockOrientation(orientation);
54 void ScreenOrientationDispatcherHost::OnUnlockRequest() {
55 if (!provider_.get())
56 return;
58 provider_->UnlockOrientation();
61 #if !defined(OS_ANDROID)
62 // static
63 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() {
64 return NULL;
66 #endif
68 } // namespace content