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

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

Issue 549603003: Create Mojo service for locking/unlocking screen orientation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to review, port unittest Created 6 years, 3 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H _ 5 #ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H _
6 #define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H _ 6 #define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H _
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "content/public/browser/screen_orientation_provider.h" 11 #include "content/public/browser/screen_orientation_provider.h"
12 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
13 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 class ScreenOrientationDispatcherHost;
17 class WebContentsImpl; 17 class WebContentsImpl;
18 18
19 class ScreenOrientationProviderAndroid : public ScreenOrientationProvider, 19 class ScreenOrientationProviderAndroid : public ScreenOrientationProvider,
20 public WebContentsObserver { 20 public WebContentsObserver {
21 public: 21 public:
22 explicit ScreenOrientationProviderAndroid( 22 explicit ScreenOrientationProviderAndroid(
23 ScreenOrientationDispatcherHost* dispatcher, 23 const ScreenOrientationLockCallback& on_result_callback,
24 WebContents* web_contents); 24 WebContents* web_contents);
25 25
26 static bool Register(JNIEnv* env); 26 static bool Register(JNIEnv* env);
27 27
28 // ScreenOrientationProvider 28 // ScreenOrientationProvider
29 virtual void LockOrientation(int request_id, 29 virtual void LockOrientation(ScreenOrientationLockType lock_type) OVERRIDE;
30 blink::WebScreenOrientationLockType) OVERRIDE;
31 virtual void UnlockOrientation() OVERRIDE; 30 virtual void UnlockOrientation() OVERRIDE;
32 virtual void OnOrientationChange() OVERRIDE; 31 virtual void OnOrientationChange() OVERRIDE;
33 32
34 // WebContentsObserver 33 // WebContentsObserver
35 virtual void DidToggleFullscreenModeForTab(bool entered_fullscreen) OVERRIDE; 34 virtual void DidToggleFullscreenModeForTab(bool entered_fullscreen) OVERRIDE;
36 35
37 // Ask the ScreenOrientationListener (Java) to start accurately listening to 36 // Ask the ScreenOrientationListener (Java) to start accurately listening to
38 // the screen orientation. It keep track of the number of start request if it 37 // the screen orientation. It keep track of the number of start request if it
39 // is already running an accurate listening. 38 // is already running an accurate listening.
40 static void StartAccurateListening(); 39 static void StartAccurateListening();
(...skipping 10 matching lines...) Expand all
51 // whether the orientation will need to change to match the |lock|. 50 // whether the orientation will need to change to match the |lock|.
52 bool LockMatchesCurrentOrientation(blink::WebScreenOrientationLockType lock); 51 bool LockMatchesCurrentOrientation(blink::WebScreenOrientationLockType lock);
53 52
54 // Returns the lock type that should be associated with 'natural' lock. 53 // Returns the lock type that should be associated with 'natural' lock.
55 // Returns WebScreenOrientationLockDefault if the natural lock type can't be 54 // Returns WebScreenOrientationLockDefault if the natural lock type can't be
56 // found. 55 // found.
57 blink::WebScreenOrientationLockType GetNaturalLockType() const; 56 blink::WebScreenOrientationLockType GetNaturalLockType() const;
58 57
59 virtual ~ScreenOrientationProviderAndroid(); 58 virtual ~ScreenOrientationProviderAndroid();
60 59
61 // ScreenOrientationDispatcherHost owns ScreenOrientationProvider so 60 // The callback that should be invoked when a lock request receives a
62 // dispatcher_ should not point to an invalid memory. 61 // result.
63 ScreenOrientationDispatcherHost* dispatcher_; 62 ScreenOrientationLockCallback on_result_callback_;
64 63
65 // Whether the ScreenOrientationProvider currently has a lock applied. 64 // Whether the ScreenOrientationProvider currently has a lock applied.
66 bool lock_applied_; 65 bool lock_applied_;
67 66
68 struct LockInformation { 67 // The requested orientation of the pending lock request, or
69 LockInformation(int request_id, blink::WebScreenOrientationLockType lock); 68 // blink::WebScreenOrientationLockDefault if there is no pending lock
70 int request_id; 69 // request.
71 blink::WebScreenOrientationLockType lock; 70 blink::WebScreenOrientationLockType pending_lock_orientation_;
72 };
73 LockInformation* pending_lock_;
74 71
75 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationProviderAndroid); 72 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationProviderAndroid);
76 }; 73 };
77 74
78 } // namespace content 75 } // namespace content
79 76
80 #endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID _H_ 77 #endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698