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

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

Issue 2868843002: Use OnceCallback on Mojo interfaces in //device/screen_orientation (Closed)
Patch Set: rebase Created 3 years, 7 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_provider.h" 5 #include "content/browser/screen_orientation/screen_orientation_provider.h"
6 6
7 #include <utility>
8
7 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h" 10 #include "content/browser/renderer_host/render_view_host_impl.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 11 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/public/browser/navigation_handle.h" 12 #include "content/public/browser/navigation_handle.h"
11 #include "content/public/browser/render_widget_host.h" 13 #include "content/public/browser/render_widget_host.h"
12 #include "content/public/browser/screen_orientation_delegate.h" 14 #include "content/public/browser/screen_orientation_delegate.h"
13 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
14 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebLockO rientationError.h" 16 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebLockO rientationError.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 using device::mojom::ScreenOrientationLockResult; 20 using device::mojom::ScreenOrientationLockResult;
19 21
20 ScreenOrientationDelegate* ScreenOrientationProvider::delegate_ = nullptr; 22 ScreenOrientationDelegate* ScreenOrientationProvider::delegate_ = nullptr;
21 23
22 ScreenOrientationProvider::ScreenOrientationProvider(WebContents* web_contents) 24 ScreenOrientationProvider::ScreenOrientationProvider(WebContents* web_contents)
23 : WebContentsObserver(web_contents), 25 : WebContentsObserver(web_contents),
24 lock_applied_(false), 26 lock_applied_(false),
25 bindings_(web_contents, this) {} 27 bindings_(web_contents, this) {}
26 28
27 ScreenOrientationProvider::~ScreenOrientationProvider() = default; 29 ScreenOrientationProvider::~ScreenOrientationProvider() = default;
28 30
29 void ScreenOrientationProvider::LockOrientation( 31 void ScreenOrientationProvider::LockOrientation(
30 blink::WebScreenOrientationLockType orientation, 32 blink::WebScreenOrientationLockType orientation,
31 const LockOrientationCallback& callback) { 33 LockOrientationCallback callback) {
32 // Cancel any pending lock request. 34 // Cancel any pending lock request.
33 NotifyLockResult(ScreenOrientationLockResult:: 35 NotifyLockResult(ScreenOrientationLockResult::
34 SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED); 36 SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED);
35 // Record new pending lock request. 37 // Record new pending lock request.
36 pending_callback_ = callback; 38 pending_callback_ = std::move(callback);
37 39
38 if (!delegate_ || !delegate_->ScreenOrientationProviderSupported()) { 40 if (!delegate_ || !delegate_->ScreenOrientationProviderSupported()) {
39 NotifyLockResult(ScreenOrientationLockResult:: 41 NotifyLockResult(ScreenOrientationLockResult::
40 SCREEN_ORIENTATION_LOCK_RESULT_ERROR_NOT_AVAILABLE); 42 SCREEN_ORIENTATION_LOCK_RESULT_ERROR_NOT_AVAILABLE);
41 return; 43 return;
42 } 44 }
43 45
44 if (delegate_->FullScreenRequired(web_contents())) { 46 if (delegate_->FullScreenRequired(web_contents())) {
45 RenderViewHostImpl* rvhi = 47 RenderViewHostImpl* rvhi =
46 static_cast<RenderViewHostImpl*>(web_contents()->GetRenderViewHost()); 48 static_cast<RenderViewHostImpl*>(web_contents()->GetRenderViewHost());
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 case blink::kWebScreenOrientationLockDefault: 216 case blink::kWebScreenOrientationLockDefault:
215 NOTREACHED(); 217 NOTREACHED();
216 return false; 218 return false;
217 } 219 }
218 220
219 NOTREACHED(); 221 NOTREACHED();
220 return false; 222 return false;
221 } 223 }
222 224
223 } // namespace content 225 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/screen_orientation/screen_orientation_provider.h ('k') | device/screen_orientation/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698