| Index: content/browser/screen_orientation/screen_orientation_provider.cc
|
| diff --git a/content/public/browser/screen_orientation_provider.cc b/content/browser/screen_orientation/screen_orientation_provider.cc
|
| similarity index 82%
|
| rename from content/public/browser/screen_orientation_provider.cc
|
| rename to content/browser/screen_orientation/screen_orientation_provider.cc
|
| index 7da24eb3d02a3f4605f178b9386710303c172498..1ab00dfa12866d15c41d0cb815ce0091f08d72af 100644
|
| --- a/content/public/browser/screen_orientation_provider.cc
|
| +++ b/content/browser/screen_orientation/screen_orientation_provider.cc
|
| @@ -2,11 +2,12 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/public/browser/screen_orientation_provider.h"
|
| +#include "content/browser/screen_orientation/screen_orientation_provider.h"
|
|
|
| #include "base/callback_helpers.h"
|
| #include "content/browser/renderer_host/render_view_host_impl.h"
|
| #include "content/browser/web_contents/web_contents_impl.h"
|
| +#include "content/public/browser/navigation_handle.h"
|
| #include "content/public/browser/render_widget_host.h"
|
| #include "content/public/browser/screen_orientation_delegate.h"
|
| #include "content/public/browser/web_contents.h"
|
| @@ -19,10 +20,11 @@ using device::mojom::ScreenOrientationLockResult;
|
| ScreenOrientationDelegate* ScreenOrientationProvider::delegate_ = nullptr;
|
|
|
| ScreenOrientationProvider::ScreenOrientationProvider(WebContents* web_contents)
|
| - : WebContentsObserver(web_contents), lock_applied_(false) {}
|
| + : WebContentsObserver(web_contents),
|
| + lock_applied_(false),
|
| + bindings_(web_contents, this) {}
|
|
|
| -ScreenOrientationProvider::~ScreenOrientationProvider() {
|
| -}
|
| +ScreenOrientationProvider::~ScreenOrientationProvider() = default;
|
|
|
| void ScreenOrientationProvider::LockOrientation(
|
| blink::WebScreenOrientationLockType orientation,
|
| @@ -106,9 +108,9 @@ void ScreenOrientationProvider::OnOrientationChange() {
|
|
|
| void ScreenOrientationProvider::NotifyLockResult(
|
| ScreenOrientationLockResult result) {
|
| - if (!pending_callback_.is_null()) {
|
| + if (!pending_callback_.is_null())
|
| base::ResetAndReturn(&pending_callback_).Run(result);
|
| - }
|
| +
|
| pending_lock_orientation_.reset();
|
| }
|
|
|
| @@ -118,7 +120,8 @@ void ScreenOrientationProvider::SetDelegate(
|
| }
|
|
|
| void ScreenOrientationProvider::DidToggleFullscreenModeForTab(
|
| - bool entered_fullscreen, bool will_cause_resize) {
|
| + bool entered_fullscreen,
|
| + bool will_cause_resize) {
|
| if (!lock_applied_ || !delegate_)
|
| return;
|
|
|
| @@ -131,8 +134,17 @@ void ScreenOrientationProvider::DidToggleFullscreenModeForTab(
|
| UnlockOrientation();
|
| }
|
|
|
| +void ScreenOrientationProvider::DidFinishNavigation(
|
| + NavigationHandle* navigation_handle) {
|
| + if (!navigation_handle->IsInMainFrame() ||
|
| + !navigation_handle->HasCommitted() || navigation_handle->IsSamePage()) {
|
| + return;
|
| + }
|
| + UnlockOrientation();
|
| +}
|
| +
|
| blink::WebScreenOrientationLockType
|
| - ScreenOrientationProvider::GetNaturalLockType() const {
|
| +ScreenOrientationProvider::GetNaturalLockType() const {
|
| RenderWidgetHost* rwh = web_contents()->GetRenderViewHost()->GetWidget();
|
| if (!rwh)
|
| return blink::WebScreenOrientationLockDefault;
|
| @@ -175,26 +187,26 @@ bool ScreenOrientationProvider::LockMatchesCurrentOrientation(
|
| switch (lock) {
|
| case blink::WebScreenOrientationLockPortraitPrimary:
|
| return screen_info.orientation_type ==
|
| - SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY;
|
| + SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY;
|
| case blink::WebScreenOrientationLockPortraitSecondary:
|
| return screen_info.orientation_type ==
|
| - SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY;
|
| + SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY;
|
| case blink::WebScreenOrientationLockLandscapePrimary:
|
| return screen_info.orientation_type ==
|
| - SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY;
|
| + SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY;
|
| case blink::WebScreenOrientationLockLandscapeSecondary:
|
| return screen_info.orientation_type ==
|
| - SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY;
|
| + SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY;
|
| case blink::WebScreenOrientationLockLandscape:
|
| return screen_info.orientation_type ==
|
| - SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY ||
|
| - screen_info.orientation_type ==
|
| - SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY;
|
| + SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY ||
|
| + screen_info.orientation_type ==
|
| + SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY;
|
| case blink::WebScreenOrientationLockPortrait:
|
| return screen_info.orientation_type ==
|
| - SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY ||
|
| - screen_info.orientation_type ==
|
| - SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY;
|
| + SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY ||
|
| + screen_info.orientation_type ==
|
| + SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY;
|
| case blink::WebScreenOrientationLockAny:
|
| return true;
|
| case blink::WebScreenOrientationLockNatural:
|
| @@ -207,4 +219,4 @@ bool ScreenOrientationProvider::LockMatchesCurrentOrientation(
|
| return false;
|
| }
|
|
|
| -} // namespace content
|
| +} // namespace content
|
|
|