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

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

Issue 444033002: Fix screen.orientation.lock() rejection and an integration test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 6 years, 4 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" 9 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ResetCurrentLock(); 76 ResetCurrentLock();
77 } 77 }
78 78
79 void ScreenOrientationDispatcherHost::NotifyLockError( 79 void ScreenOrientationDispatcherHost::NotifyLockError(
80 int request_id, blink::WebLockOrientationError error) { 80 int request_id, blink::WebLockOrientationError error) {
81 RenderFrameHost* render_frame_host = 81 RenderFrameHost* render_frame_host =
82 GetRenderFrameHostForRequestID(request_id); 82 GetRenderFrameHostForRequestID(request_id);
83 if (!render_frame_host) 83 if (!render_frame_host)
84 return; 84 return;
85 85
86 NotifyLockError(request_id, render_frame_host, error);
87 }
88
89 void ScreenOrientationDispatcherHost::NotifyLockError(
90 int request_id,
91 RenderFrameHost* render_frame_host,
92 blink::WebLockOrientationError error) {
86 render_frame_host->Send(new ScreenOrientationMsg_LockError( 93 render_frame_host->Send(new ScreenOrientationMsg_LockError(
87 render_frame_host->GetRoutingID(), request_id, error)); 94 render_frame_host->GetRoutingID(), request_id, error));
88 ResetCurrentLock(); 95 ResetCurrentLock();
89 } 96 }
90 97
91 void ScreenOrientationDispatcherHost::OnOrientationChange() { 98 void ScreenOrientationDispatcherHost::OnOrientationChange() {
92 if (provider_) 99 if (provider_)
93 provider_->OnOrientationChange(); 100 provider_->OnOrientationChange();
94 } 101 }
95 102
96 void ScreenOrientationDispatcherHost::OnLockRequest( 103 void ScreenOrientationDispatcherHost::OnLockRequest(
97 RenderFrameHost* render_frame_host, 104 RenderFrameHost* render_frame_host,
98 blink::WebScreenOrientationLockType orientation, 105 blink::WebScreenOrientationLockType orientation,
99 int request_id) { 106 int request_id) {
100 if (current_lock_) { 107 if (current_lock_) {
101 NotifyLockError(current_lock_->request_id, 108 NotifyLockError(current_lock_->request_id, render_frame_host,
102 blink::WebLockOrientationErrorCanceled); 109 blink::WebLockOrientationErrorCanceled);
103 } 110 }
104 111
105 if (!provider_) { 112 if (!provider_) {
106 NotifyLockError(request_id, 113 NotifyLockError(request_id, render_frame_host,
107 blink::WebLockOrientationErrorNotAvailable); 114 blink::WebLockOrientationErrorNotAvailable);
108 return; 115 return;
109 } 116 }
110 117
111 current_lock_ = new LockInformation(request_id, 118 current_lock_ = new LockInformation(request_id,
112 render_frame_host->GetProcess()->GetID(), 119 render_frame_host->GetProcess()->GetID(),
113 render_frame_host->GetRoutingID()); 120 render_frame_host->GetRoutingID());
114 121
115 provider_->LockOrientation(request_id, orientation); 122 provider_->LockOrientation(request_id, orientation);
116 } 123 }
117 124
118 void ScreenOrientationDispatcherHost::OnUnlockRequest( 125 void ScreenOrientationDispatcherHost::OnUnlockRequest(
119 RenderFrameHost* render_frame_host) { 126 RenderFrameHost* render_frame_host) {
120 if (current_lock_) { 127 if (current_lock_) {
121 NotifyLockError(current_lock_->request_id, 128 NotifyLockError(current_lock_->request_id, render_frame_host,
122 blink::WebLockOrientationErrorCanceled); 129 blink::WebLockOrientationErrorCanceled);
123 } 130 }
124 131
125 if (!provider_) 132 if (!provider_)
126 return; 133 return;
127 134
128 provider_->UnlockOrientation(); 135 provider_->UnlockOrientation();
129 } 136 }
130 137
131 } // namespace content 138 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698