OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.h" | 5 #include "content/browser/screen_orientation/screen_orientation.h" |
6 | 6 |
7 #include "content/public/browser/navigation_details.h" | 7 #include "content/public/browser/navigation_handle.h" |
8 #include "content/public/browser/screen_orientation_provider.h" | 8 #include "content/public/browser/screen_orientation_provider.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 ScreenOrientation::ScreenOrientation(WebContents* web_contents) | 13 ScreenOrientation::ScreenOrientation(WebContents* web_contents) |
14 : WebContentsObserver(web_contents), | 14 : WebContentsObserver(web_contents), |
15 bindings_(web_contents, this), | 15 bindings_(web_contents, this), |
16 weak_factory_(this) { | 16 weak_factory_(this) { |
17 provider_.reset(new ScreenOrientationProvider(web_contents)); | 17 provider_.reset(new ScreenOrientationProvider(web_contents)); |
18 } | 18 } |
19 | 19 |
20 ScreenOrientation::~ScreenOrientation() = default; | 20 ScreenOrientation::~ScreenOrientation() = default; |
21 | 21 |
22 void ScreenOrientation::LockOrientation( | 22 void ScreenOrientation::LockOrientation( |
23 blink::WebScreenOrientationLockType orientation, | 23 blink::WebScreenOrientationLockType orientation, |
24 const LockOrientationCallback& callback) { | 24 const LockOrientationCallback& callback) { |
25 provider_->LockOrientation(orientation, callback); | 25 provider_->LockOrientation(orientation, callback); |
26 } | 26 } |
27 | 27 |
28 void ScreenOrientation::UnlockOrientation() { | 28 void ScreenOrientation::UnlockOrientation() { |
29 provider_->UnlockOrientation(); | 29 provider_->UnlockOrientation(); |
30 } | 30 } |
31 | 31 |
32 void ScreenOrientation::DidNavigateMainFrame( | 32 void ScreenOrientation::DidFinishNavigation( |
33 const LoadCommittedDetails& details, | 33 NavigationHandle* navigation_handle) { |
34 const FrameNavigateParams& params) { | 34 if (!navigation_handle->IsInMainFrame() || |
35 if (details.is_in_page) | 35 !navigation_handle->HasCommitted() || |
| 36 navigation_handle->IsSamePage()) { |
36 return; | 37 return; |
| 38 } |
37 provider_->UnlockOrientation(); | 39 provider_->UnlockOrientation(); |
38 } | 40 } |
39 | 41 |
40 ScreenOrientationProvider* ScreenOrientation::GetScreenOrientationProvider() { | 42 ScreenOrientationProvider* ScreenOrientation::GetScreenOrientationProvider() { |
41 return provider_.get(); | 43 return provider_.get(); |
42 } | 44 } |
43 | 45 |
44 } // namespace content | 46 } // namespace content |
OLD | NEW |