| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_RENDERER_GEOLOCATION_DISPATCHER_H_ | 5 #ifndef CHROME_RENDERER_GEOLOCATION_DISPATCHER_H_ |
| 6 #define CHROME_RENDERER_GEOLOCATION_DISPATCHER_H_ | 6 #define CHROME_RENDERER_GEOLOCATION_DISPATCHER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "chrome/renderer/render_view_observer.h" |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClient.h" | 11 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClient.h" |
| 11 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationController.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationController.h" |
| 12 | 13 |
| 13 class RenderView; | |
| 14 struct Geoposition; | 14 struct Geoposition; |
| 15 | 15 |
| 16 namespace WebKit { | 16 namespace WebKit { |
| 17 class WebGeolocationController; | 17 class WebGeolocationController; |
| 18 class WebGeolocationPermissionRequest; | 18 class WebGeolocationPermissionRequest; |
| 19 class WebGeolocationPermissionRequestManager; | 19 class WebGeolocationPermissionRequestManager; |
| 20 class WebGeolocationPosition; | 20 class WebGeolocationPosition; |
| 21 class WebSecurityOrigin; | 21 class WebSecurityOrigin; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace IPC { | |
| 25 class Message; | |
| 26 } | |
| 27 | |
| 28 // GeolocationDispatcher is a delegate for Geolocation messages used by | 24 // GeolocationDispatcher is a delegate for Geolocation messages used by |
| 29 // WebKit. | 25 // WebKit. |
| 30 // It's the complement of GeolocationDispatcherHost (owned by RenderViewHost). | 26 // It's the complement of GeolocationDispatcherHost (owned by RenderViewHost). |
| 31 class GeolocationDispatcher : public WebKit::WebGeolocationClient { | 27 class GeolocationDispatcher : public RenderViewObserver, |
| 28 public WebKit::WebGeolocationClient { |
| 32 public: | 29 public: |
| 33 explicit GeolocationDispatcher(RenderView* render_view); | 30 explicit GeolocationDispatcher(RenderView* render_view); |
| 34 virtual ~GeolocationDispatcher(); | 31 virtual ~GeolocationDispatcher(); |
| 35 | 32 |
| 36 // IPC | 33 private: |
| 34 // RenderView::Observer implementation. |
| 37 bool OnMessageReceived(const IPC::Message& message); | 35 bool OnMessageReceived(const IPC::Message& message); |
| 38 | 36 |
| 39 // WebGeolocationClient | 37 // WebGeolocationClient |
| 40 virtual void geolocationDestroyed(); | 38 virtual void geolocationDestroyed(); |
| 41 virtual void startUpdating(); | 39 virtual void startUpdating(); |
| 42 virtual void stopUpdating(); | 40 virtual void stopUpdating(); |
| 43 virtual void setEnableHighAccuracy(bool enable_high_accuracy); | 41 virtual void setEnableHighAccuracy(bool enable_high_accuracy); |
| 44 virtual void setController(WebKit::WebGeolocationController* controller); | 42 virtual void setController(WebKit::WebGeolocationController* controller); |
| 45 virtual bool lastPosition(WebKit::WebGeolocationPosition& position); | 43 virtual bool lastPosition(WebKit::WebGeolocationPosition& position); |
| 46 virtual void requestPermission( | 44 virtual void requestPermission( |
| 47 const WebKit::WebGeolocationPermissionRequest& permissionRequest); | 45 const WebKit::WebGeolocationPermissionRequest& permissionRequest); |
| 48 virtual void cancelPermissionRequest( | 46 virtual void cancelPermissionRequest( |
| 49 const WebKit::WebGeolocationPermissionRequest& permissionRequest); | 47 const WebKit::WebGeolocationPermissionRequest& permissionRequest); |
| 50 | 48 |
| 51 private: | |
| 52 // Permission for using geolocation has been set. | 49 // Permission for using geolocation has been set. |
| 53 void OnGeolocationPermissionSet(int bridge_id, bool is_allowed); | 50 void OnGeolocationPermissionSet(int bridge_id, bool is_allowed); |
| 54 | 51 |
| 55 // We have an updated geolocation position or error code. | 52 // We have an updated geolocation position or error code. |
| 56 void OnGeolocationPositionUpdated(const Geoposition& geoposition); | 53 void OnGeolocationPositionUpdated(const Geoposition& geoposition); |
| 57 | 54 |
| 58 // GeolocationDispatcher is owned by RenderView. Back pointer for IPC. | 55 // GeolocationDispatcher is owned by RenderView. Back pointer for IPC. |
| 59 RenderView* render_view_; | 56 RenderView* render_view_; |
| 60 | 57 |
| 61 // The controller_ is valid for the lifetime of the underlying | 58 // The controller_ is valid for the lifetime of the underlying |
| 62 // WebCore::GeolocationController. geolocationDestroyed() is | 59 // WebCore::GeolocationController. geolocationDestroyed() is |
| 63 // invoked when the underlying object is destroyed. | 60 // invoked when the underlying object is destroyed. |
| 64 scoped_ptr< WebKit::WebGeolocationController> controller_; | 61 scoped_ptr< WebKit::WebGeolocationController> controller_; |
| 65 | 62 |
| 66 scoped_ptr<WebKit::WebGeolocationPermissionRequestManager> | 63 scoped_ptr<WebKit::WebGeolocationPermissionRequestManager> |
| 67 pending_permissions_; | 64 pending_permissions_; |
| 68 bool enable_high_accuracy_; | 65 bool enable_high_accuracy_; |
| 69 bool updating_; | 66 bool updating_; |
| 70 }; | 67 }; |
| 71 | 68 |
| 72 #endif // CHROME_RENDERER_GEOLOCATION_DISPATCHER_H_ | 69 #endif // CHROME_RENDERER_GEOLOCATION_DISPATCHER_H_ |
| OLD | NEW |