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

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

Issue 723633003: Reland ScreenOrientationDelegate on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ChromeOS build error Created 6 years, 1 month 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
« no previous file with comments | « content/public/browser/screen_orientation_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_delegate.h" 7 #include "content/browser/renderer_host/render_view_host_delegate.h"
8 #include "content/public/browser/render_view_host.h" 8 #include "content/public/browser/render_view_host.h"
9 #include "content/public/browser/screen_orientation_delegate.h" 9 #include "content/public/browser/screen_orientation_delegate.h"
10 #include "content/public/browser/screen_orientation_dispatcher_host.h" 10 #include "content/public/browser/screen_orientation_dispatcher_host.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 lock_orientation = GetNaturalLockType(); 66 lock_orientation = GetNaturalLockType();
67 if (lock_orientation == blink::WebScreenOrientationLockDefault) { 67 if (lock_orientation == blink::WebScreenOrientationLockDefault) {
68 // We are in a broken state, let's pretend we got canceled. 68 // We are in a broken state, let's pretend we got canceled.
69 dispatcher_->NotifyLockError(request_id, 69 dispatcher_->NotifyLockError(request_id,
70 blink::WebLockOrientationErrorCanceled); 70 blink::WebLockOrientationErrorCanceled);
71 return; 71 return;
72 } 72 }
73 } 73 }
74 74
75 lock_applied_ = true; 75 lock_applied_ = true;
76 delegate_->Lock(lock_orientation); 76 delegate_->Lock(web_contents(), lock_orientation);
77 77
78 // If two calls happen close to each other some platforms will ignore the 78 // If two calls happen close to each other some platforms will ignore the
79 // first. A successful lock will be once orientation matches the latest 79 // first. A successful lock will be once orientation matches the latest
80 // request. 80 // request.
81 pending_lock_.reset(); 81 pending_lock_.reset();
82 82
83 // If the orientation we are locking to matches the current orientation, we 83 // If the orientation we are locking to matches the current orientation, we
84 // should succeed immediately. 84 // should succeed immediately.
85 if (LockMatchesCurrentOrientation(lock_orientation)) { 85 if (LockMatchesCurrentOrientation(lock_orientation)) {
86 dispatcher_->NotifyLockSuccess(request_id); 86 dispatcher_->NotifyLockSuccess(request_id);
87 return; 87 return;
88 } 88 }
89 89
90 pending_lock_.reset(new LockInformation(request_id, lock_orientation)); 90 pending_lock_.reset(new LockInformation(request_id, lock_orientation));
91 } 91 }
92 92
93 void ScreenOrientationProvider::UnlockOrientation() { 93 void ScreenOrientationProvider::UnlockOrientation() {
94 if (!lock_applied_ || !delegate_) 94 if (!lock_applied_ || !delegate_)
95 return; 95 return;
96 96
97 delegate_->Unlock(); 97 delegate_->Unlock(web_contents());
98 98
99 lock_applied_ = false; 99 lock_applied_ = false;
100 pending_lock_.reset(); 100 pending_lock_.reset();
101 } 101 }
102 102
103 void ScreenOrientationProvider::OnOrientationChange() { 103 void ScreenOrientationProvider::OnOrientationChange() {
104 if (!pending_lock_.get()) 104 if (!pending_lock_.get())
105 return; 105 return;
106 106
107 if (LockMatchesCurrentOrientation(pending_lock_->lock)) { 107 if (LockMatchesCurrentOrientation(pending_lock_->lock)) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 case blink::WebScreenOrientationLockDefault: 200 case blink::WebScreenOrientationLockDefault:
201 NOTREACHED(); 201 NOTREACHED();
202 return false; 202 return false;
203 } 203 }
204 204
205 NOTREACHED(); 205 NOTREACHED();
206 return false; 206 return false;
207 } 207 }
208 208
209 } // namespace content 209 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/screen_orientation_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698