1 // Copyright (c) 2012 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_RENDERER_DEVICE_ORIENTATION_DISPATCHER_H_ 6 #define CONTENT_RENDERER_DEVICE_ORIENTATION_DISPATCHER_H_ 7 8 #include "third_party/WebKit/public/web/WebDeviceOrientationClient.h" 9 #include "third_party/WebKit/public/web/WebDeviceOrientation.h" 10 11 #include "base/memory/scoped_ptr.h" 12 #include "content/public/renderer/render_view_observer.h" 13 14 struct DeviceOrientationMsg_Updated_Params; 15 16 namespace content { 17 class RenderViewImpl; 18 19 class DeviceOrientationDispatcher : public RenderViewObserver, 20 public WebKit::WebDeviceOrientationClient { 21 public: 22 explicit DeviceOrientationDispatcher(RenderViewImpl* render_view); 23 virtual ~DeviceOrientationDispatcher(); 24 25 private: 26 // RenderView::Observer implementation. 27 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 28 29 // From WebKit::WebDeviceOrientationClient. 30 virtual void setController( 31 WebKit::WebDeviceOrientationController* controller); 32 virtual void startUpdating(); 33 virtual void stopUpdating(); 34 virtual WebKit::WebDeviceOrientation lastOrientation() const; 35 36 void OnDeviceOrientationUpdated( 37 const DeviceOrientationMsg_Updated_Params& p); 38 39 scoped_ptr<WebKit::WebDeviceOrientationController> controller_; 40 WebKit::WebDeviceOrientation last_orientation_; 41 bool started_; 42 }; 43 44 } // namespace content 45 46 #endif // CONTENT_RENDERER_DEVICE_ORIENTATION_DISPATCHER_H_ 47