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/public/browser/screen_orientation_provider.h

Issue 2682643002: [ScreenOrientation] Hide ScreenOrientationProvider inside WebContentsImpl. (Closed)
Patch Set: Rebase only Created 3 years, 10 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
« no previous file with comments | « content/public/browser/BUILD.gn ('k') | content/public/browser/screen_orientation_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_
6 #define CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_
7
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "base/macros.h"
11 #include "base/optional.h"
12 #include "content/common/content_export.h"
13 #include "content/public/browser/web_contents_binding_set.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "device/screen_orientation/public/interfaces/screen_orientation.mojom.h "
16 #include "device/screen_orientation/public/interfaces/screen_orientation_lock_ty pes.mojom.h"
17 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h"
18
19 namespace content {
20
21 class ScreenOrientationDelegate;
22 class WebContents;
23
24 // Handles screen orientation lock/unlock. Platforms which wish to provide
25 // custom implementations can provide a factory for ScreenOrientationDelegate.
26 class CONTENT_EXPORT ScreenOrientationProvider
27 : NON_EXPORTED_BASE(public device::mojom::ScreenOrientation),
28 public WebContentsObserver {
29 public:
30 ScreenOrientationProvider(WebContents* web_contents);
31
32 ~ScreenOrientationProvider() override;
33
34 // device::mojom::ScreenOrientation:
35 void LockOrientation(blink::WebScreenOrientationLockType orientation,
36 const LockOrientationCallback& callback) override;
37 void UnlockOrientation() override;
38
39 // Inform about a screen orientation update. It is called to let the provider
40 // know if a lock has been resolved.
41 void OnOrientationChange();
42
43 // Provide a delegate which creates delegates for platform implementations.
44 // The delegate is not owned by ScreenOrientationProvider.
45 static void SetDelegate(ScreenOrientationDelegate* delegate_);
46
47 // WebContentsObserver
48 void DidToggleFullscreenModeForTab(bool entered_fullscreen,
49 bool will_cause_resize) override;
50 void DidFinishNavigation(NavigationHandle* navigation_handle) override;
51
52 private:
53 // Calls on |on_result_callback_| with |result|, followed by resetting
54 // |on_result_callback_| and |pending_lock_orientation_|.
55 void NotifyLockResult(device::mojom::ScreenOrientationLockResult result);
56
57 // Returns the lock type that should be associated with 'natural' lock.
58 // Returns WebScreenOrientationLockDefault if the natural lock type can't be
59 // found.
60 blink::WebScreenOrientationLockType GetNaturalLockType() const;
61
62 // Whether the passed |lock| matches the current orientation. In other words,
63 // whether the orientation will need to change to match the |lock|.
64 bool LockMatchesCurrentOrientation(blink::WebScreenOrientationLockType lock);
65
66 // Not owned, responsible for platform implementations.
67 static ScreenOrientationDelegate* delegate_;
68
69 // Whether the ScreenOrientationProvider currently has a lock applied.
70 bool lock_applied_;
71
72 // Lock that require orientation changes are not completed until
73 // OnOrientationChange.
74 base::Optional<blink::WebScreenOrientationLockType> pending_lock_orientation_;
75
76 LockOrientationCallback pending_callback_;
77
78 WebContentsFrameBindingSet<device::mojom::ScreenOrientation> bindings_;
79
80 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationProvider);
81 };
82
83 } // namespace content
84
85 #endif // CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/public/browser/BUILD.gn ('k') | content/public/browser/screen_orientation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698