Rename Animate as Begin(Main)Frame
[chromium-blink-merge.git] / content / browser / screen_orientation / screen_orientation_provider_android.h
blob9b88386afab1e611732ff026c2fd3a44117d9751
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H_
6 #define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H_
8 #include <jni.h>
10 #include "base/compiler_specific.h"
11 #include "content/browser/screen_orientation/screen_orientation_provider.h"
12 #include "content/public/browser/web_contents_observer.h"
14 namespace content {
16 class WebContentsImpl;
18 class ScreenOrientationProviderAndroid : public ScreenOrientationProvider,
19 public WebContentsObserver {
20 public:
21 explicit ScreenOrientationProviderAndroid(
22 ScreenOrientationDispatcherHost* dispatcher,
23 WebContents* web_contents);
25 static bool Register(JNIEnv* env);
27 // ScreenOrientationProvider
28 virtual void LockOrientation(int request_id,
29 blink::WebScreenOrientationLockType) OVERRIDE;
30 virtual void UnlockOrientation() OVERRIDE;
31 virtual void OnOrientationChange() OVERRIDE;
33 // WebContentsObserver
34 virtual void DidToggleFullscreenModeForTab(bool entered_fullscreen) OVERRIDE;
36 // Ask the ScreenOrientationListener (Java) to start accurately listening to
37 // the screen orientation. It keep track of the number of start request if it
38 // is already running an accurate listening.
39 static void StartAccurateListening();
41 // Ask the ScreenOrientationListener (Java) to stop accurately listening to
42 // the screen orientation. It will actually stop only if the number of stop
43 // requests matches the number of start requests.
44 static void StopAccurateListening();
46 private:
47 WebContentsImpl* web_contents_impl();
49 // Whether the passed |lock| matches the current orientation. In other words,
50 // whether the orientation will need to change to match the |lock|.
51 bool LockMatchesCurrentOrientation(blink::WebScreenOrientationLockType lock);
53 // Returns the lock type that should be associated with 'natural' lock.
54 // Returns WebScreenOrientationLockDefault if the natural lock type can't be
55 // found.
56 blink::WebScreenOrientationLockType GetNaturalLockType() const;
58 virtual ~ScreenOrientationProviderAndroid();
60 // ScreenOrientationDispatcherHost owns ScreenOrientationProvider so
61 // dispatcher_ should not point to an invalid memory.
62 ScreenOrientationDispatcherHost* dispatcher_;
64 // Whether the ScreenOrientationProvider currently has a lock applied.
65 bool lock_applied_;
67 struct LockInformation {
68 LockInformation(int request_id, blink::WebScreenOrientationLockType lock);
69 int request_id;
70 blink::WebScreenOrientationLockType lock;
72 LockInformation* pending_lock_;
74 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationProviderAndroid);
77 } // namespace content
79 #endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H_