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

Side by Side Diff: content/browser/screen_orientation/screen_orientation_dispatcher_host.cc

Issue 336153002: Revert of Properly route screen orientation IPC messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screen_lock_view
Patch Set: Created 6 years, 6 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h" 5 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h"
6 6
7 #include "content/browser/screen_orientation/screen_orientation_provider.h" 7 #include "content/browser/screen_orientation/screen_orientation_provider.h"
8 #include "content/common/screen_orientation_messages.h" 8 #include "content/common/screen_orientation_messages.h"
9 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/web_contents.h"
11 9
12 namespace content { 10 namespace content {
13 11
14 ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost( 12 ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost()
15 WebContents* web_contents) 13 : BrowserMessageFilter(ScreenOrientationMsgStart) {
16 : WebContentsObserver(web_contents) {
17 if (!provider_.get()) 14 if (!provider_.get())
18 provider_.reset(CreateProvider()); 15 provider_.reset(CreateProvider());
19 } 16 }
20 17
21 ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() { 18 ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() {
22 } 19 }
23 20
24 bool ScreenOrientationDispatcherHost::OnMessageReceived( 21 bool ScreenOrientationDispatcherHost::OnMessageReceived(
25 const IPC::Message& message, 22 const IPC::Message& message) {
26 RenderFrameHost* render_frame_host) {
27 bool handled = true; 23 bool handled = true;
28 24
29 int routing_id = message.routing_id(); 25 IPC_BEGIN_MESSAGE_MAP(ScreenOrientationDispatcherHost, message)
30 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(ScreenOrientationDispatcherHost, message,
31 &routing_id)
32 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_LockRequest, OnLockRequest) 26 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_LockRequest, OnLockRequest)
33 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Unlock, OnUnlockRequest) 27 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Unlock, OnUnlockRequest)
34 IPC_MESSAGE_UNHANDLED(handled = false) 28 IPC_MESSAGE_UNHANDLED(handled = false)
35 IPC_END_MESSAGE_MAP() 29 IPC_END_MESSAGE_MAP()
36 30
37 return handled; 31 return handled;
38 } 32 }
39 33
40 void ScreenOrientationDispatcherHost::OnOrientationChange( 34 void ScreenOrientationDispatcherHost::OnOrientationChange(
41 blink::WebScreenOrientationType orientation) { 35 blink::WebScreenOrientationType orientation) {
42 Send(new ScreenOrientationMsg_OrientationChange(orientation)); 36 Send(new ScreenOrientationMsg_OrientationChange(orientation));
43 } 37 }
44 38
45 void ScreenOrientationDispatcherHost::SetProviderForTests( 39 void ScreenOrientationDispatcherHost::SetProviderForTests(
46 ScreenOrientationProvider* provider) { 40 ScreenOrientationProvider* provider) {
47 provider_.reset(provider); 41 provider_.reset(provider);
48 } 42 }
49 43
50 void ScreenOrientationDispatcherHost::OnLockRequest( 44 void ScreenOrientationDispatcherHost::OnLockRequest(
51 int* routing_id,
52 blink::WebScreenOrientationLockType orientation, 45 blink::WebScreenOrientationLockType orientation,
53 int request_id) { 46 int request_id) {
54 if (!provider_) { 47 if (!provider_) {
55 Send(new ScreenOrientationMsg_LockError( 48 Send(new ScreenOrientationMsg_LockError(
56 *routing_id, 49 request_id,
57 request_id, 50 blink::WebLockOrientationCallback::ErrorTypeNotAvailable));
58 blink::WebLockOrientationCallback::ErrorTypeNotAvailable));
59 return; 51 return;
60 } 52 }
61 53
62 // TODO(mlamouri): pass real values. 54 // TODO(mlamouri): pass real values.
63 Send(new ScreenOrientationMsg_LockSuccess( 55 Send(new ScreenOrientationMsg_LockSuccess(
64 *routing_id, 56 request_id,
65 request_id, 57 0,
66 0, 58 blink::WebScreenOrientationPortraitPrimary));
67 blink::WebScreenOrientationPortraitPrimary));
68 provider_->LockOrientation(orientation); 59 provider_->LockOrientation(orientation);
69 } 60 }
70 61
71 void ScreenOrientationDispatcherHost::OnUnlockRequest( 62 void ScreenOrientationDispatcherHost::OnUnlockRequest() {
72 int* routing_id) {
73 if (!provider_.get()) 63 if (!provider_.get())
74 return; 64 return;
75 65
76 provider_->UnlockOrientation(); 66 provider_->UnlockOrientation();
77 } 67 }
78 68
79 #if !defined(OS_ANDROID) 69 #if !defined(OS_ANDROID)
80 // static 70 // static
81 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { 71 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() {
82 return NULL; 72 return NULL;
83 } 73 }
84 #endif 74 #endif
85 75
86 } // namespace content 76 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698