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

Side by Side Diff: content/public/browser/screen_orientation_provider.cc

Issue 2317563004: Change blink::WebScreenInfo to content::ScreenInfo (Closed)
Patch Set: Fix Windows compile Created 4 years, 3 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/public/browser/screen_orientation_provider.h" 5 #include "content/public/browser/screen_orientation_provider.h"
6 6
7 #include "content/browser/renderer_host/render_view_host_impl.h" 7 #include "content/browser/renderer_host/render_view_host_impl.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 8 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/public/browser/render_widget_host.h" 9 #include "content/public/browser/render_widget_host.h"
10 #include "content/public/browser/screen_orientation_delegate.h" 10 #include "content/public/browser/screen_orientation_delegate.h"
11 #include "content/public/browser/screen_orientation_dispatcher_host.h" 11 #include "content/public/browser/screen_orientation_dispatcher_host.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
14 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebLockO rientationError.h" 13 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebLockO rientationError.h"
15 14
16 namespace content { 15 namespace content {
17 16
18 ScreenOrientationDelegate* ScreenOrientationProvider::delegate_ = nullptr; 17 ScreenOrientationDelegate* ScreenOrientationProvider::delegate_ = nullptr;
19 18
20 ScreenOrientationProvider::LockInformation::LockInformation(int request_id, 19 ScreenOrientationProvider::LockInformation::LockInformation(int request_id,
21 blink::WebScreenOrientationLockType lock) 20 blink::WebScreenOrientationLockType lock)
22 : request_id(request_id), 21 : request_id(request_id),
23 lock(lock) { 22 lock(lock) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 DCHECK(!entered_fullscreen); 124 DCHECK(!entered_fullscreen);
126 UnlockOrientation(); 125 UnlockOrientation();
127 } 126 }
128 127
129 blink::WebScreenOrientationLockType 128 blink::WebScreenOrientationLockType
130 ScreenOrientationProvider::GetNaturalLockType() const { 129 ScreenOrientationProvider::GetNaturalLockType() const {
131 RenderWidgetHost* rwh = web_contents()->GetRenderViewHost()->GetWidget(); 130 RenderWidgetHost* rwh = web_contents()->GetRenderViewHost()->GetWidget();
132 if (!rwh) 131 if (!rwh)
133 return blink::WebScreenOrientationLockDefault; 132 return blink::WebScreenOrientationLockDefault;
134 133
135 blink::WebScreenInfo screen_info; 134 ScreenInfo screen_info;
136 rwh->GetWebScreenInfo(&screen_info); 135 rwh->GetScreenInfo(&screen_info);
137 136
138 switch (screen_info.orientationType) { 137 switch (screen_info.orientation_type) {
139 case blink::WebScreenOrientationPortraitPrimary: 138 case SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY:
140 case blink::WebScreenOrientationPortraitSecondary: 139 case SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY:
141 if (screen_info.orientationAngle == 0 || 140 if (screen_info.orientation_angle == 0 ||
142 screen_info.orientationAngle == 180) { 141 screen_info.orientation_angle == 180) {
143 return blink::WebScreenOrientationLockPortraitPrimary; 142 return blink::WebScreenOrientationLockPortraitPrimary;
144 } 143 }
145 return blink::WebScreenOrientationLockLandscapePrimary; 144 return blink::WebScreenOrientationLockLandscapePrimary;
146 case blink::WebScreenOrientationLandscapePrimary: 145 case SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY:
147 case blink::WebScreenOrientationLandscapeSecondary: 146 case SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY:
148 if (screen_info.orientationAngle == 0 || 147 if (screen_info.orientation_angle == 0 ||
149 screen_info.orientationAngle == 180) { 148 screen_info.orientation_angle == 180) {
150 return blink::WebScreenOrientationLockLandscapePrimary; 149 return blink::WebScreenOrientationLockLandscapePrimary;
151 } 150 }
152 return blink::WebScreenOrientationLockPortraitPrimary; 151 return blink::WebScreenOrientationLockPortraitPrimary;
153 case blink::WebScreenOrientationUndefined: 152 default:
154 NOTREACHED(); 153 break;
155 return blink::WebScreenOrientationLockDefault;
156 } 154 }
157 155
158 NOTREACHED(); 156 NOTREACHED();
159 return blink::WebScreenOrientationLockDefault; 157 return blink::WebScreenOrientationLockDefault;
160 } 158 }
161 159
162 bool ScreenOrientationProvider::LockMatchesCurrentOrientation( 160 bool ScreenOrientationProvider::LockMatchesCurrentOrientation(
163 blink::WebScreenOrientationLockType lock) { 161 blink::WebScreenOrientationLockType lock) {
164 RenderWidgetHost* rwh = web_contents()->GetRenderViewHost()->GetWidget(); 162 RenderWidgetHost* rwh = web_contents()->GetRenderViewHost()->GetWidget();
165 if (!rwh) 163 if (!rwh)
166 return false; 164 return false;
167 165
168 blink::WebScreenInfo screen_info; 166 ScreenInfo screen_info;
169 rwh->GetWebScreenInfo(&screen_info); 167 rwh->GetScreenInfo(&screen_info);
170 168
171 switch (lock) { 169 switch (lock) {
172 case blink::WebScreenOrientationLockPortraitPrimary: 170 case blink::WebScreenOrientationLockPortraitPrimary:
173 return screen_info.orientationType == 171 return screen_info.orientation_type ==
174 blink::WebScreenOrientationPortraitPrimary; 172 SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY;
175 case blink::WebScreenOrientationLockPortraitSecondary: 173 case blink::WebScreenOrientationLockPortraitSecondary:
176 return screen_info.orientationType == 174 return screen_info.orientation_type ==
177 blink::WebScreenOrientationPortraitSecondary; 175 SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY;
178 case blink::WebScreenOrientationLockLandscapePrimary: 176 case blink::WebScreenOrientationLockLandscapePrimary:
179 return screen_info.orientationType == 177 return screen_info.orientation_type ==
180 blink::WebScreenOrientationLandscapePrimary; 178 SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY;
181 case blink::WebScreenOrientationLockLandscapeSecondary: 179 case blink::WebScreenOrientationLockLandscapeSecondary:
182 return screen_info.orientationType == 180 return screen_info.orientation_type ==
183 blink::WebScreenOrientationLandscapeSecondary; 181 SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY;
184 case blink::WebScreenOrientationLockLandscape: 182 case blink::WebScreenOrientationLockLandscape:
185 return screen_info.orientationType == 183 return screen_info.orientation_type ==
186 blink::WebScreenOrientationLandscapePrimary || 184 SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY ||
187 screen_info.orientationType == 185 screen_info.orientation_type ==
188 blink::WebScreenOrientationLandscapeSecondary; 186 SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY;
189 case blink::WebScreenOrientationLockPortrait: 187 case blink::WebScreenOrientationLockPortrait:
190 return screen_info.orientationType == 188 return screen_info.orientation_type ==
191 blink::WebScreenOrientationPortraitPrimary || 189 SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY ||
192 screen_info.orientationType == 190 screen_info.orientation_type ==
193 blink::WebScreenOrientationPortraitSecondary; 191 SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY;
194 case blink::WebScreenOrientationLockAny: 192 case blink::WebScreenOrientationLockAny:
195 return true; 193 return true;
196 case blink::WebScreenOrientationLockNatural: 194 case blink::WebScreenOrientationLockNatural:
197 case blink::WebScreenOrientationLockDefault: 195 case blink::WebScreenOrientationLockDefault:
198 NOTREACHED(); 196 NOTREACHED();
199 return false; 197 return false;
200 } 198 }
201 199
202 NOTREACHED(); 200 NOTREACHED();
203 return false; 201 return false;
204 } 202 }
205 203
206 } // namespace content 204 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698