OLD | NEW |
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_H_ |
6 #define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_H_ |
7 | 7 |
8 #include "content/public/browser/web_contents_observer.h" | 8 #include "content/public/browser/browser_message_filter.h" |
9 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" | 9 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" |
10 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h" | 10 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 class RenderFrameHost; | |
15 class ScreenOrientationProvider; | 14 class ScreenOrientationProvider; |
16 class WebContents; | |
17 | 15 |
18 // ScreenOrientationDispatcherHost is receives lock and unlock requests from the | 16 // ScreenOrientationDispatcherHost is a browser filter for Screen Orientation |
19 // RenderFrames and dispatch them to the ScreenOrientationProvider. It also | 17 // messages and also helps dispatching messages about orientation changes to the |
20 // make sure that the right RenderFrame get replied for each lock request. | 18 // renderers. |
21 class CONTENT_EXPORT ScreenOrientationDispatcherHost | 19 class CONTENT_EXPORT ScreenOrientationDispatcherHost |
22 : public WebContentsObserver { | 20 : public BrowserMessageFilter { |
23 public: | 21 public: |
24 explicit ScreenOrientationDispatcherHost(WebContents* web_contents); | 22 ScreenOrientationDispatcherHost(); |
25 virtual ~ScreenOrientationDispatcherHost(); | |
26 | 23 |
27 // WebContentsObserver | 24 // BrowserMessageFilter |
28 virtual bool OnMessageReceived(const IPC::Message&, | 25 virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE; |
29 RenderFrameHost* render_frame_host) OVERRIDE; | |
30 | 26 |
31 void OnOrientationChange(blink::WebScreenOrientationType orientation); | 27 void OnOrientationChange(blink::WebScreenOrientationType orientation); |
32 | 28 |
33 void SetProviderForTests(ScreenOrientationProvider* provider); | 29 void SetProviderForTests(ScreenOrientationProvider* provider); |
34 | 30 |
| 31 protected: |
| 32 virtual ~ScreenOrientationDispatcherHost(); |
| 33 |
35 private: | 34 private: |
36 void OnLockRequest(int* routing_id, | 35 void OnLockRequest(blink::WebScreenOrientationLockType orientation, |
37 blink::WebScreenOrientationLockType orientation, | |
38 int request_id); | 36 int request_id); |
39 void OnUnlockRequest(int* routing_id); | 37 void OnUnlockRequest(); |
40 | 38 |
41 static ScreenOrientationProvider* CreateProvider(); | 39 static ScreenOrientationProvider* CreateProvider(); |
42 | 40 |
43 scoped_ptr<ScreenOrientationProvider> provider_; | 41 scoped_ptr<ScreenOrientationProvider> provider_; |
44 | 42 |
45 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationDispatcherHost); | 43 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationDispatcherHost); |
46 }; | 44 }; |
47 | 45 |
48 } // namespace content | 46 } // namespace content |
49 | 47 |
50 #endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_
H_ | 48 #endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_
H_ |
OLD | NEW |