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

Side by Side Diff: content/public/browser/screen_orientation_provider.h

Issue 2564653003: [DeviceService] Move screen_orientation.mojom from //content to //device. (Closed)
Patch Set: Move screen_orientation_lock_types.mojom from blink into //device Created 4 years 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_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_
6 #define CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_ 6 #define CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/public/browser/web_contents_observer.h" 13 #include "content/public/browser/web_contents_observer.h"
14 #include "device/screen_orientation/public/interfaces/screen_orientation_lock_ty pes.mojom.h"
14 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h" 15 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h"
15 #include "third_party/WebKit/public/platform/modules/screen_orientation/screen_o rientation_lock_types.mojom.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 class ScreenOrientationDelegate; 19 class ScreenOrientationDelegate;
20 class WebContents; 20 class WebContents;
21 21
22 using LockOrientationCallback = 22 using LockOrientationCallback =
23 base::Callback<void(::blink::mojom::ScreenOrientationLockResult)>; 23 base::Callback<void(::device::mojom::ScreenOrientationLockResult)>;
24 24
25 // Handles screen orientation lock/unlock. Platforms which wish to provide 25 // Handles screen orientation lock/unlock. Platforms which wish to provide
26 // custom implementations can provide a factory for ScreenOrientationDelegate. 26 // custom implementations can provide a factory for ScreenOrientationDelegate.
27 class CONTENT_EXPORT ScreenOrientationProvider : public WebContentsObserver { 27 class CONTENT_EXPORT ScreenOrientationProvider : public WebContentsObserver {
28 public: 28 public:
29 ScreenOrientationProvider(WebContents* web_contents); 29 ScreenOrientationProvider(WebContents* web_contents);
30 30
31 ~ScreenOrientationProvider() override; 31 ~ScreenOrientationProvider() override;
32 32
33 // Lock the screen orientation to |orientation|, |callback| is the callback 33 // Lock the screen orientation to |orientation|, |callback| is the callback
(...skipping 12 matching lines...) Expand all
46 // The delegate is not owned by ScreenOrientationProvider. 46 // The delegate is not owned by ScreenOrientationProvider.
47 static void SetDelegate(ScreenOrientationDelegate* delegate_); 47 static void SetDelegate(ScreenOrientationDelegate* delegate_);
48 48
49 // WebContentsObserver 49 // WebContentsObserver
50 void DidToggleFullscreenModeForTab(bool entered_fullscreen, 50 void DidToggleFullscreenModeForTab(bool entered_fullscreen,
51 bool will_cause_resize) override; 51 bool will_cause_resize) override;
52 52
53 private: 53 private:
54 // Calls on |on_result_callback_| with |result|, followed by resetting 54 // Calls on |on_result_callback_| with |result|, followed by resetting
55 // |on_result_callback_| and |pending_lock_orientation_|. 55 // |on_result_callback_| and |pending_lock_orientation_|.
56 void NotifyLockResult(::blink::mojom::ScreenOrientationLockResult result); 56 void NotifyLockResult(::device::mojom::ScreenOrientationLockResult result);
blundell 2016/12/12 12:30:46 tiny nit: the leading :: shouldn't be necessary he
leonhsl(Using Gerrit) 2016/12/13 03:39:58 Done.
57 57
58 // Returns the lock type that should be associated with 'natural' lock. 58 // Returns the lock type that should be associated with 'natural' lock.
59 // Returns WebScreenOrientationLockDefault if the natural lock type can't be 59 // Returns WebScreenOrientationLockDefault if the natural lock type can't be
60 // found. 60 // found.
61 blink::WebScreenOrientationLockType GetNaturalLockType() const; 61 blink::WebScreenOrientationLockType GetNaturalLockType() const;
62 62
63 // Whether the passed |lock| matches the current orientation. In other words, 63 // Whether the passed |lock| matches the current orientation. In other words,
64 // whether the orientation will need to change to match the |lock|. 64 // whether the orientation will need to change to match the |lock|.
65 bool LockMatchesCurrentOrientation(blink::WebScreenOrientationLockType lock); 65 bool LockMatchesCurrentOrientation(blink::WebScreenOrientationLockType lock);
66 66
67 // Not owned, responsible for platform implementations. 67 // Not owned, responsible for platform implementations.
68 static ScreenOrientationDelegate* delegate_; 68 static ScreenOrientationDelegate* delegate_;
69 69
70 // Whether the ScreenOrientationProvider currently has a lock applied. 70 // Whether the ScreenOrientationProvider currently has a lock applied.
71 bool lock_applied_; 71 bool lock_applied_;
72 72
73 // Locks that require orientation changes are not completed until 73 // Locks that require orientation changes are not completed until
74 // OnOrientationChange. 74 // OnOrientationChange.
75 75
76 base::Optional<blink::WebScreenOrientationLockType> pending_lock_orientation_; 76 base::Optional<blink::WebScreenOrientationLockType> pending_lock_orientation_;
77 77
78 LockOrientationCallback on_result_callback_; 78 LockOrientationCallback on_result_callback_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationProvider); 80 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationProvider);
81 }; 81 };
82 82
83 } // namespace content 83 } // namespace content
84 84
85 #endif // CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_ 85 #endif // CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698