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..36774b79b0f12ff28cb33a32236c2f9ec3e8a742 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,13 @@ ScreenOrientationProvider::ScreenOrientationProvider(WebContents* web_contents) |
lock_applied_(false), |
bindings_(web_contents, this) {} |
-ScreenOrientationProvider::~ScreenOrientationProvider() = default; |
+ScreenOrientationProvider::~ScreenOrientationProvider() { |
+#if defined(OS_ANDROID) |
+ if (accurate_listen_count_ > 0) { |
+ ScreenOrientationDelegateAndroid::StopAccurateListening(); |
+ } |
mlamouri (slow - plz ping)
2017/02/15 10:58:41
style: no { }
leonhsl(Using Gerrit)
2017/02/16 05:00:05
Done.
|
+#endif |
+} |
void ScreenOrientationProvider::LockOrientation( |
blink::WebScreenOrientationLockType orientation, |
@@ -95,6 +105,23 @@ void ScreenOrientationProvider::UnlockOrientation() { |
lock_applied_ = false; |
} |
+void ScreenOrientationProvider::StartAccurateListen() { |
+#if defined(OS_ANDROID) |
+ ++accurate_listen_count_; |
+ if (accurate_listen_count_ == 1) |
+ ScreenOrientationDelegateAndroid::StartAccurateListening(); |
+#endif |
+} |
+ |
+void ScreenOrientationProvider::StopAccurateListen() { |
+#if defined(OS_ANDROID) |
+ DCHECK(accurate_listen_count_ > 0); |
+ --accurate_listen_count_; |
+ if (accurate_listen_count_ == 0) |
+ ScreenOrientationDelegateAndroid::StopAccurateListening(); |
+#endif |
+} |
+ |
void ScreenOrientationProvider::OnOrientationChange() { |
if (!pending_lock_orientation_.has_value()) |
return; |