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

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

Issue 508603003: Export ScreenOrientationProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_IM PL_H_
6 #define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_IM PL_H_
7 7
8 #include "base/id_map.h" 8 #include "content/public/browser/screen_orientation_dispatcher_host.h"
9 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/web_contents_observer.h" 9 #include "content/public/browser/web_contents_observer.h"
11 #include "third_party/WebKit/public/platform/WebLockOrientationError.h" 10 #include "third_party/WebKit/public/platform/WebLockOrientationError.h"
12 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" 11 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
13 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
14 12
15 namespace content { 13 namespace content {
16 14
17 class RenderFrameHost; 15 class RenderFrameHost;
18 class ScreenOrientationProvider; 16 class ScreenOrientationProvider;
19 class WebContents; 17 class WebContents;
20 18
21 // ScreenOrientationDispatcherHost receives lock and unlock requests from the 19 // ScreenOrientationDispatcherHost receives lock and unlock requests from the
22 // RenderFrames and dispatch them to the ScreenOrientationProvider. It also 20 // RenderFrames and dispatch them to the ScreenOrientationProvider. It also
23 // make sure that the right RenderFrame get replied for each lock request. 21 // make sure that the right RenderFrame get replied for each lock request.
24 class CONTENT_EXPORT ScreenOrientationDispatcherHost 22 class CONTENT_EXPORT ScreenOrientationDispatcherHostImpl
25 : public WebContentsObserver { 23 : public ScreenOrientationDispatcherHost,
24 public WebContentsObserver {
26 public: 25 public:
27 explicit ScreenOrientationDispatcherHost(WebContents* web_contents); 26 explicit ScreenOrientationDispatcherHostImpl(WebContents* web_contents);
28 virtual ~ScreenOrientationDispatcherHost(); 27 virtual ~ScreenOrientationDispatcherHostImpl();
29 28
30 // WebContentsObserver 29 // ScreenOrientationDispatcherHost:
30 virtual void NotifyLockSuccess(int request_id) OVERRIDE;
31 virtual void NotifyLockError(int request_id,
32 blink::WebLockOrientationError error) OVERRIDE;
33 virtual void OnOrientationChange() OVERRIDE;
34
35 // WebContentsObserver:
31 virtual bool OnMessageReceived(const IPC::Message&, 36 virtual bool OnMessageReceived(const IPC::Message&,
32 RenderFrameHost* render_frame_host) OVERRIDE; 37 RenderFrameHost* render_frame_host) OVERRIDE;
33 38
34 // Notifies that the lock with the given |request_id| has succeeded.
35 // The renderer process will be notified that the lock succeeded only if
36 // |request_id| matches the |current_lock_|.
37 void NotifyLockSuccess(int request_id);
38
39 // Notifies that the lock with the given |request_id| has failed.
40 // The renderer process will be notified that the lock succeeded only if
41 // |request_id| matches the |current_lock_|.
42 void NotifyLockError(int request_id, blink::WebLockOrientationError error);
43
44 void OnOrientationChange();
45
46 private: 39 private:
47 void OnLockRequest(RenderFrameHost* render_frame_host, 40 void OnLockRequest(RenderFrameHost* render_frame_host,
48 blink::WebScreenOrientationLockType orientation, 41 blink::WebScreenOrientationLockType orientation,
49 int request_id); 42 int request_id);
50 void OnUnlockRequest(RenderFrameHost* render_frame_host); 43 void OnUnlockRequest(RenderFrameHost* render_frame_host);
51 44
52 // Returns a RenderFrameHost if the request_id is still valid and the 45 // Returns a RenderFrameHost if the request_id is still valid and the
53 // associated RenderFrameHost still exists. Returns NULL otherwise. 46 // associated RenderFrameHost still exists. Returns NULL otherwise.
54 RenderFrameHost* GetRenderFrameHostForRequestID(int request_id); 47 RenderFrameHost* GetRenderFrameHostForRequestID(int request_id);
55 48
56 void ResetCurrentLock(); 49 void ResetCurrentLock();
57 void NotifyLockError(int request_id, 50 void NotifyLockError(int request_id,
58 RenderFrameHost* render_frame_host, 51 RenderFrameHost* render_frame_host,
59 blink::WebLockOrientationError error); 52 blink::WebLockOrientationError error);
60 53
61 scoped_ptr<ScreenOrientationProvider> provider_; 54 scoped_ptr<ScreenOrientationProvider> provider_;
62 55
63 struct LockInformation { 56 struct LockInformation {
64 LockInformation(int request_id, int process_id, int routing_id); 57 LockInformation(int request_id, int process_id, int routing_id);
65 int request_id; 58 int request_id;
66 int process_id; 59 int process_id;
67 int routing_id; 60 int routing_id;
68 }; 61 };
69 // current_lock_ will be NULL if there are no current lock. 62 // current_lock_ will be NULL if there are no current lock.
70 LockInformation* current_lock_; 63 LockInformation* current_lock_;
71 64
72 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationDispatcherHost); 65 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationDispatcherHostImpl);
73 }; 66 };
74 67
75 } // namespace content 68 } // namespace content
76 69
77 #endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_ H_ 70 #endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST _IMPL_H_
mlamouri (slow - plz ping) 2014/09/03 11:25:49 nit: you seem to be adding one space for no reason
jonross 2014/09/03 20:33:02 Was identified when I ran cpplint. I've removed th
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698