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

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

Issue 2391883006: Mojo-ify implementation of screen orientation locking/unlocking. (Closed)
Patch Set: clup 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
(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_DISPATCHER_HOST_IM PL_H_
6 #define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_IM PL_H_
7
8 #include "base/macros.h"
9 #include "content/public/browser/screen_orientation_dispatcher_host.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebLockO rientationError.h"
12 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h"
13
14 namespace content {
15
16 class RenderFrameHost;
17 class ScreenOrientationProvider;
18 class WebContents;
19
20 // ScreenOrientationDispatcherHost receives lock and unlock requests from the
21 // RenderFrames and dispatch them to the ScreenOrientationProvider. It also
22 // make sure that the right RenderFrame get replied for each lock request.
23 class CONTENT_EXPORT ScreenOrientationDispatcherHostImpl
24 : public ScreenOrientationDispatcherHost,
25 public WebContentsObserver {
26 public:
27 explicit ScreenOrientationDispatcherHostImpl(WebContents* web_contents);
28 ~ScreenOrientationDispatcherHostImpl() override;
29
30 // ScreenOrientationDispatcherHost:
31 void NotifyLockSuccess(int request_id) override;
32 void NotifyLockError(int request_id,
33 blink::WebLockOrientationError error) override;
34 void OnOrientationChange() override;
35
36 // WebContentsObserver:
37 bool OnMessageReceived(const IPC::Message&,
38 RenderFrameHost* render_frame_host) override;
39 void DidNavigateMainFrame(const LoadCommittedDetails& details,
40 const FrameNavigateParams& params) override;
41
42 private:
43 void OnLockRequest(RenderFrameHost* render_frame_host,
44 blink::WebScreenOrientationLockType orientation,
45 int request_id);
46 void OnUnlockRequest(RenderFrameHost* render_frame_host);
47
48 // Returns a RenderFrameHost if the request_id is still valid and the
49 // associated RenderFrameHost still exists. Returns NULL otherwise.
50 RenderFrameHost* GetRenderFrameHostForRequestID(int request_id);
51
52 void ResetCurrentLock();
53 void NotifyLockError(int request_id,
54 RenderFrameHost* render_frame_host,
55 blink::WebLockOrientationError error);
56
57 std::unique_ptr<ScreenOrientationProvider> provider_;
58
59 struct LockInformation {
60 LockInformation(int request_id, int process_id, int routing_id);
61 int request_id;
62 int process_id;
63 int routing_id;
64 };
65 // current_lock_ will be NULL if there are no current lock.
66 LockInformation* current_lock_;
67
68 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationDispatcherHostImpl);
69 };
70
71 } // namespace content
72
73 #endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST _IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698