Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: content/browser/screen_orientation/screen_orientation_provider_android.h

Issue 546453004: Centralize ScreenOrientationProvider logic, add platform delegates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screen_orientation_public_impl_split
Patch Set: Remove Factory Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H _
6 #define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H _
7
8 #include <jni.h>
9
10 #include "base/compiler_specific.h"
11 #include "content/public/browser/screen_orientation_provider.h"
12 #include "content/public/browser/web_contents_observer.h"
13
14 namespace content {
15
16 class ScreenOrientationDispatcherHost;
17 class WebContentsImpl;
18
19 class ScreenOrientationProviderAndroid : public ScreenOrientationProvider,
20 public WebContentsObserver {
21 public:
22 explicit ScreenOrientationProviderAndroid(
23 ScreenOrientationDispatcherHost* dispatcher,
24 WebContents* web_contents);
25
26 static bool Register(JNIEnv* env);
27
28 // ScreenOrientationProvider
29 virtual void LockOrientation(int request_id,
30 blink::WebScreenOrientationLockType) OVERRIDE;
31 virtual void UnlockOrientation() OVERRIDE;
32 virtual void OnOrientationChange() OVERRIDE;
33
34 // WebContentsObserver
35 virtual void DidToggleFullscreenModeForTab(bool entered_fullscreen) OVERRIDE;
36
37 // Ask the ScreenOrientationListener (Java) to start accurately listening to
38 // the screen orientation. It keep track of the number of start request if it
39 // is already running an accurate listening.
40 static void StartAccurateListening();
41
42 // Ask the ScreenOrientationListener (Java) to stop accurately listening to
43 // the screen orientation. It will actually stop only if the number of stop
44 // requests matches the number of start requests.
45 static void StopAccurateListening();
46
47 private:
48 WebContentsImpl* web_contents_impl();
49
50 // Whether the passed |lock| matches the current orientation. In other words,
51 // whether the orientation will need to change to match the |lock|.
52 bool LockMatchesCurrentOrientation(blink::WebScreenOrientationLockType lock);
53
54 // Returns the lock type that should be associated with 'natural' lock.
55 // Returns WebScreenOrientationLockDefault if the natural lock type can't be
56 // found.
57 blink::WebScreenOrientationLockType GetNaturalLockType() const;
58
59 virtual ~ScreenOrientationProviderAndroid();
60
61 // ScreenOrientationDispatcherHost owns ScreenOrientationProvider so
62 // dispatcher_ should not point to an invalid memory.
63 ScreenOrientationDispatcherHost* dispatcher_;
64
65 // Whether the ScreenOrientationProvider currently has a lock applied.
66 bool lock_applied_;
67
68 struct LockInformation {
69 LockInformation(int request_id, blink::WebScreenOrientationLockType lock);
70 int request_id;
71 blink::WebScreenOrientationLockType lock;
72 };
73 LockInformation* pending_lock_;
74
75 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationProviderAndroid);
76 };
77
78 } // namespace content
79
80 #endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698