Index: content/browser/screen_orientation/screen_orientation_provider.cc |
diff --git a/content/browser/screen_orientation/screen_orientation_provider.cc b/content/browser/screen_orientation/screen_orientation_provider.cc |
index 1ab00dfa12866d15c41d0cb815ce0091f08d72af..4fa0cfa110a3e8501353867fabfa2e662ba8fdc7 100644 |
--- a/content/browser/screen_orientation/screen_orientation_provider.cc |
+++ b/content/browser/screen_orientation/screen_orientation_provider.cc |
@@ -13,6 +13,10 @@ |
#include "content/public/browser/web_contents.h" |
#include "third_party/WebKit/public/platform/modules/screen_orientation/WebLockOrientationError.h" |
+#if defined(OS_ANDROID) |
+#include "content/browser/screen_orientation/screen_orientation_delegate_android.h" |
+#endif |
+ |
namespace content { |
using device::mojom::ScreenOrientationLockResult; |
@@ -24,7 +28,12 @@ ScreenOrientationProvider::ScreenOrientationProvider(WebContents* web_contents) |
lock_applied_(false), |
bindings_(web_contents, this) {} |
-ScreenOrientationProvider::~ScreenOrientationProvider() = default; |
+ScreenOrientationProvider::~ScreenOrientationProvider() { |
+#if defined(OS_ANDROID) |
+ if (accurate_listener_count_ > 0) |
+ ScreenOrientationDelegateAndroid::StopAccurateListening(); |
+#endif |
+} |
void ScreenOrientationProvider::LockOrientation( |
blink::WebScreenOrientationLockType orientation, |
@@ -95,6 +104,23 @@ void ScreenOrientationProvider::UnlockOrientation() { |
lock_applied_ = false; |
} |
+void ScreenOrientationProvider::StartAccurateListen() { |
+#if defined(OS_ANDROID) |
+ ++accurate_listener_count_; |
+ if (accurate_listener_count_ == 1) |
+ ScreenOrientationDelegateAndroid::StartAccurateListening(); |
+#endif |
+} |
+ |
+void ScreenOrientationProvider::StopAccurateListen() { |
+#if defined(OS_ANDROID) |
+ DCHECK(accurate_listener_count_ > 0); |
+ --accurate_listener_count_; |
+ if (accurate_listener_count_ == 0) |
+ ScreenOrientationDelegateAndroid::StopAccurateListening(); |
+#endif |
+} |
+ |
void ScreenOrientationProvider::OnOrientationChange() { |
if (!pending_lock_orientation_.has_value()) |
return; |