OLD | NEW |
---|---|
(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/browser/screen_orientation/screen_orientation_dispatcher_host. h" | |
6 | |
7 #include "content/common/view_messages.h" | |
8 #include "content/port/browser/screen_orientation_provider.h" | |
9 #include "content/public/browser/content_browser_client.h" | |
10 #include "content/public/common/content_client.h" | |
11 | |
12 namespace content { | |
13 | |
14 ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost() | |
15 : orientation_lock_(0) { | |
16 provider_.reset( | |
17 GetContentClient()->browser()->OverrideScreenOrientationProvider()); | |
18 if (!provider_.get()) | |
19 provider_.reset(CreateProvider()); | |
20 } | |
21 | |
22 ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() { | |
23 } | |
24 | |
25 bool ScreenOrientationDispatcherHost::OnMessageReceived( | |
26 const IPC::Message& message, | |
27 bool* message_was_ok) { | |
28 bool handled = true; | |
29 IPC_BEGIN_MESSAGE_MAP_EX(ScreenOrientationDispatcherHost, | |
30 message, | |
31 *message_was_ok) | |
32 IPC_MESSAGE_HANDLER(ViewHostMsg_LockScreenOrientation, OnLockOrientation) | |
33 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockScreenOrientation, | |
34 OnUnlockOrientation) | |
35 IPC_MESSAGE_UNHANDLED(handled = false) | |
36 IPC_END_MESSAGE_MAP_EX() | |
37 return handled; | |
38 } | |
39 | |
40 void ScreenOrientationDispatcherHost::OnLockOrientation(unsigned char lock, | |
kenneth.r.christiansen
2014/02/06 15:03:12
why not wrap the argument like in the method above
ostap
2014/02/06 21:23:28
Done.
| |
41 bool* result) { | |
42 if (!provider_.get()) | |
43 return; | |
44 | |
45 orientation_lock_ = | |
46 static_cast<ScreenOrientationProvider::Orientations>(lock); | |
47 | |
48 assert((orientation_lock_ & ScreenOrientationProvider::OrientationAny) == 0); | |
49 | |
50 // Is it legal to provide empty lock? | |
51 assert(orientation_lock_); | |
kenneth.r.christiansen
2014/02/06 15:03:12
I would say no, so the Blink implementation needs
ostap
2014/02/06 21:23:28
Ok. Added to TODO list ;)
| |
52 | |
53 *result = provider_->LockOrientation(orientation_lock_); | |
54 } | |
55 | |
56 void ScreenOrientationDispatcherHost::OnUnlockOrientation() { | |
57 if (!provider_.get()) | |
58 return; | |
59 | |
60 provider_->UnlockOrientation(); | |
61 orientation_lock_ = 0; | |
62 } | |
63 | |
64 #if !defined(OS_ANDROID) | |
65 // static | |
66 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { | |
67 return NULL; | |
68 } | |
69 #endif | |
70 } // namespace content | |
OLD | NEW |