Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / screen_orientation / screen_orientation_dispatcher_host_impl.h
blob29bc534ea7d62bb3b021e2cdde07340331ef4c07
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.
5 #ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_IMPL_H_
6 #define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_IMPL_H_
8 #include "content/public/browser/screen_orientation_dispatcher_host.h"
9 #include "content/public/browser/web_contents_observer.h"
10 #include "third_party/WebKit/public/platform/WebLockOrientationError.h"
11 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
13 namespace content {
15 class RenderFrameHost;
16 class ScreenOrientationProvider;
17 class WebContents;
19 // ScreenOrientationDispatcherHost receives lock and unlock requests from the
20 // RenderFrames and dispatch them to the ScreenOrientationProvider. It also
21 // make sure that the right RenderFrame get replied for each lock request.
22 class CONTENT_EXPORT ScreenOrientationDispatcherHostImpl
23 : public ScreenOrientationDispatcherHost,
24 public WebContentsObserver {
25 public:
26 explicit ScreenOrientationDispatcherHostImpl(WebContents* web_contents);
27 ~ScreenOrientationDispatcherHostImpl() override;
29 // ScreenOrientationDispatcherHost:
30 void NotifyLockSuccess(int request_id) override;
31 void NotifyLockError(int request_id,
32 blink::WebLockOrientationError error) override;
33 void OnOrientationChange() override;
35 // WebContentsObserver:
36 bool OnMessageReceived(const IPC::Message&,
37 RenderFrameHost* render_frame_host) override;
38 void DidNavigateMainFrame(const LoadCommittedDetails& details,
39 const FrameNavigateParams& params) override;
41 private:
42 void OnLockRequest(RenderFrameHost* render_frame_host,
43 blink::WebScreenOrientationLockType orientation,
44 int request_id);
45 void OnUnlockRequest(RenderFrameHost* render_frame_host);
47 // Returns a RenderFrameHost if the request_id is still valid and the
48 // associated RenderFrameHost still exists. Returns NULL otherwise.
49 RenderFrameHost* GetRenderFrameHostForRequestID(int request_id);
51 void ResetCurrentLock();
52 void NotifyLockError(int request_id,
53 RenderFrameHost* render_frame_host,
54 blink::WebLockOrientationError error);
56 scoped_ptr<ScreenOrientationProvider> provider_;
58 struct LockInformation {
59 LockInformation(int request_id, int process_id, int routing_id);
60 int request_id;
61 int process_id;
62 int routing_id;
64 // current_lock_ will be NULL if there are no current lock.
65 LockInformation* current_lock_;
67 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationDispatcherHostImpl);
70 } // namespace content
72 #endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_IMPL_H_