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

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

Issue 327573002: Properly route screen orientation IPC messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screen_lock_view
Patch Set: nit 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"
9 11
10 namespace content { 12 namespace content {
11 13
12 ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost() 14 ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost(
13 : BrowserMessageFilter(ScreenOrientationMsgStart) { 15 WebContents* web_contents)
16 : WebContentsObserver(web_contents) {
14 if (!provider_.get()) 17 if (!provider_.get())
15 provider_.reset(CreateProvider()); 18 provider_.reset(CreateProvider());
16 } 19 }
17 20
18 ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() { 21 ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() {
19 } 22 }
20 23
21 bool ScreenOrientationDispatcherHost::OnMessageReceived( 24 bool ScreenOrientationDispatcherHost::OnMessageReceived(
22 const IPC::Message& message) { 25 const IPC::Message& message,
26 RenderFrameHost* render_frame_host) {
23 bool handled = true; 27 bool handled = true;
24 28
25 IPC_BEGIN_MESSAGE_MAP(ScreenOrientationDispatcherHost, message) 29 int routing_id = message.routing_id();
30 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(ScreenOrientationDispatcherHost, message,
31 &routing_id)
26 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_LockRequest, OnLockRequest) 32 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_LockRequest, OnLockRequest)
27 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Unlock, OnUnlockRequest) 33 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Unlock, OnUnlockRequest)
28 IPC_MESSAGE_UNHANDLED(handled = false) 34 IPC_MESSAGE_UNHANDLED(handled = false)
29 IPC_END_MESSAGE_MAP() 35 IPC_END_MESSAGE_MAP()
30 36
31 return handled; 37 return handled;
32 } 38 }
33 39
34 void ScreenOrientationDispatcherHost::OnOrientationChange( 40 void ScreenOrientationDispatcherHost::OnOrientationChange(
35 blink::WebScreenOrientationType orientation) { 41 blink::WebScreenOrientationType orientation) {
36 Send(new ScreenOrientationMsg_OrientationChange(orientation)); 42 Send(new ScreenOrientationMsg_OrientationChange(orientation));
37 } 43 }
38 44
39 void ScreenOrientationDispatcherHost::SetProviderForTests( 45 void ScreenOrientationDispatcherHost::SetProviderForTests(
40 ScreenOrientationProvider* provider) { 46 ScreenOrientationProvider* provider) {
41 provider_.reset(provider); 47 provider_.reset(provider);
42 } 48 }
43 49
44 void ScreenOrientationDispatcherHost::OnLockRequest( 50 void ScreenOrientationDispatcherHost::OnLockRequest(
51 int* routing_id,
45 blink::WebScreenOrientationLockType orientation, 52 blink::WebScreenOrientationLockType orientation,
46 int request_id) { 53 int request_id) {
47 if (!provider_) { 54 if (!provider_) {
48 Send(new ScreenOrientationMsg_LockError( 55 Send(new ScreenOrientationMsg_LockError(
jam 2014/06/16 19:20:40 I missed this last time, you'll need the RenderFra
mlamouri (slow - plz ping) 2014/06/17 10:13:57 Done.
49 request_id, 56 *routing_id,
50 blink::WebLockOrientationCallback::ErrorTypeNotAvailable)); 57 request_id,
58 blink::WebLockOrientationCallback::ErrorTypeNotAvailable));
51 return; 59 return;
52 } 60 }
53 61
54 // TODO(mlamouri): pass real values. 62 // TODO(mlamouri): pass real values.
55 Send(new ScreenOrientationMsg_LockSuccess( 63 Send(new ScreenOrientationMsg_LockSuccess(
56 request_id, 64 *routing_id,
57 0, 65 request_id,
58 blink::WebScreenOrientationPortraitPrimary)); 66 0,
67 blink::WebScreenOrientationPortraitPrimary));
59 provider_->LockOrientation(orientation); 68 provider_->LockOrientation(orientation);
60 } 69 }
61 70
62 void ScreenOrientationDispatcherHost::OnUnlockRequest() { 71 void ScreenOrientationDispatcherHost::OnUnlockRequest(
72 int* routing_id) {
63 if (!provider_.get()) 73 if (!provider_.get())
64 return; 74 return;
65 75
66 provider_->UnlockOrientation(); 76 provider_->UnlockOrientation();
67 } 77 }
68 78
69 #if !defined(OS_ANDROID) 79 #if !defined(OS_ANDROID)
70 // static 80 // static
71 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { 81 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() {
72 return NULL; 82 return NULL;
73 } 83 }
74 #endif 84 #endif
75 85
76 } // namespace content 86 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698