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

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: review comments 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 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(ScreenOrientationDispatcherHost, message,
30 render_frame_host)
26 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_LockRequest, OnLockRequest) 31 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_LockRequest, OnLockRequest)
27 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Unlock, OnUnlockRequest) 32 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Unlock, OnUnlockRequest)
28 IPC_MESSAGE_UNHANDLED(handled = false) 33 IPC_MESSAGE_UNHANDLED(handled = false)
29 IPC_END_MESSAGE_MAP() 34 IPC_END_MESSAGE_MAP()
30 35
31 return handled; 36 return handled;
32 } 37 }
33 38
34 void ScreenOrientationDispatcherHost::OnOrientationChange( 39 void ScreenOrientationDispatcherHost::OnOrientationChange(
35 blink::WebScreenOrientationType orientation) { 40 blink::WebScreenOrientationType orientation) {
36 Send(new ScreenOrientationMsg_OrientationChange(orientation)); 41 Send(new ScreenOrientationMsg_OrientationChange(orientation));
37 } 42 }
38 43
39 void ScreenOrientationDispatcherHost::SetProviderForTests( 44 void ScreenOrientationDispatcherHost::SetProviderForTests(
40 ScreenOrientationProvider* provider) { 45 ScreenOrientationProvider* provider) {
41 provider_.reset(provider); 46 provider_.reset(provider);
42 } 47 }
43 48
44 void ScreenOrientationDispatcherHost::OnLockRequest( 49 void ScreenOrientationDispatcherHost::OnLockRequest(
50 RenderFrameHost* render_frame_host,
45 blink::WebScreenOrientationLockType orientation, 51 blink::WebScreenOrientationLockType orientation,
46 int request_id) { 52 int request_id) {
47 if (!provider_) { 53 if (!provider_) {
48 Send(new ScreenOrientationMsg_LockError( 54 render_frame_host->Send(new ScreenOrientationMsg_LockError(
49 request_id, 55 render_frame_host->GetRoutingID(),
50 blink::WebLockOrientationCallback::ErrorTypeNotAvailable)); 56 request_id,
57 blink::WebLockOrientationCallback::ErrorTypeNotAvailable));
51 return; 58 return;
52 } 59 }
53 60
54 // TODO(mlamouri): pass real values. 61 // TODO(mlamouri): pass real values.
55 Send(new ScreenOrientationMsg_LockSuccess( 62 render_frame_host->Send(new ScreenOrientationMsg_LockSuccess(
56 request_id, 63 render_frame_host->GetRoutingID(),
57 0, 64 request_id,
58 blink::WebScreenOrientationPortraitPrimary)); 65 0,
66 blink::WebScreenOrientationPortraitPrimary));
59 provider_->LockOrientation(orientation); 67 provider_->LockOrientation(orientation);
60 } 68 }
61 69
62 void ScreenOrientationDispatcherHost::OnUnlockRequest() { 70 void ScreenOrientationDispatcherHost::OnUnlockRequest(
71 RenderFrameHost* render_frame_host) {
63 if (!provider_.get()) 72 if (!provider_.get())
64 return; 73 return;
65 74
66 provider_->UnlockOrientation(); 75 provider_->UnlockOrientation();
67 } 76 }
68 77
69 #if !defined(OS_ANDROID) 78 #if !defined(OS_ANDROID)
70 // static 79 // static
71 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { 80 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() {
72 return NULL; 81 return NULL;
73 } 82 }
74 #endif 83 #endif
75 84
76 } // namespace content 85 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698