OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_RENDERER_GEOLOCATION_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_ |
6 #define CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "content/common/geolocation_service.mojom.h" | 9 #include "content/common/geolocation_service.mojom.h" |
10 #include "content/common/permission_service.mojom.h" | 10 #include "content/common/permission_service.mojom.h" |
11 #include "content/public/renderer/render_frame_observer.h" | 11 #include "content/public/renderer/render_frame_observer.h" |
12 #include "third_party/WebKit/public/web/WebGeolocationClient.h" | 12 #include "third_party/WebKit/public/web/WebGeolocationClient.h" |
13 #include "third_party/WebKit/public/web/WebGeolocationController.h" | 13 #include "third_party/WebKit/public/web/WebGeolocationController.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 class WebGeolocationController; | 16 class WebGeolocationController; |
17 class WebGeolocationPermissionRequest; | 17 class WebGeolocationPermissionRequest; |
18 class WebGeolocationPermissionRequestManager; | 18 class WebGeolocationPermissionRequestManager; |
19 class WebGeolocationPosition; | 19 class WebGeolocationPosition; |
20 } | 20 } |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 struct Geoposition; | 23 struct Geoposition; |
24 | 24 |
25 // GeolocationDispatcher is a delegate for Geolocation messages used by | 25 // GeolocationDispatcher is a delegate for Geolocation messages used by |
26 // WebKit. | 26 // WebKit. |
27 // It's the complement of GeolocationDispatcherHost. | 27 // It's the complement of GeolocationDispatcherHost. |
28 class GeolocationDispatcher | 28 class GeolocationDispatcher |
29 : public RenderFrameObserver, | 29 : public RenderFrameObserver, |
30 public blink::WebGeolocationClient, | 30 public blink::WebGeolocationClient { |
31 public mojo::InterfaceImpl<GeolocationServiceClient> { | |
32 public: | 31 public: |
33 explicit GeolocationDispatcher(RenderFrame* render_frame); | 32 explicit GeolocationDispatcher(RenderFrame* render_frame); |
34 virtual ~GeolocationDispatcher(); | 33 virtual ~GeolocationDispatcher(); |
35 | 34 |
36 private: | 35 private: |
37 // WebGeolocationClient | 36 // WebGeolocationClient |
38 virtual void startUpdating(); | 37 virtual void startUpdating(); |
39 virtual void stopUpdating(); | 38 virtual void stopUpdating(); |
40 virtual void setEnableHighAccuracy(bool enable_high_accuracy); | 39 virtual void setEnableHighAccuracy(bool enable_high_accuracy); |
41 virtual void setController(blink::WebGeolocationController* controller); | 40 virtual void setController(blink::WebGeolocationController* controller); |
42 virtual bool lastPosition(blink::WebGeolocationPosition& position); | 41 virtual bool lastPosition(blink::WebGeolocationPosition& position); |
43 virtual void requestPermission( | 42 virtual void requestPermission( |
44 const blink::WebGeolocationPermissionRequest& permissionRequest); | 43 const blink::WebGeolocationPermissionRequest& permissionRequest); |
45 virtual void cancelPermissionRequest( | 44 virtual void cancelPermissionRequest( |
46 const blink::WebGeolocationPermissionRequest& permissionRequest); | 45 const blink::WebGeolocationPermissionRequest& permissionRequest); |
47 | 46 |
48 // GeolocationServiceClient | 47 void QueryNextPosition(); |
49 void OnLocationUpdate(MojoGeopositionPtr geoposition) override; | 48 void OnPositionUpdate(MojoGeopositionPtr geoposition); |
50 | 49 |
51 // Permission for using geolocation has been set. | 50 // Permission for using geolocation has been set. |
52 void OnPermissionSet(int permission_request_id, PermissionStatus status); | 51 void OnPermissionSet(int permission_request_id, PermissionStatus status); |
53 | 52 |
54 scoped_ptr<blink::WebGeolocationController> controller_; | 53 scoped_ptr<blink::WebGeolocationController> controller_; |
55 | 54 |
56 scoped_ptr<blink::WebGeolocationPermissionRequestManager> | 55 scoped_ptr<blink::WebGeolocationPermissionRequestManager> |
57 pending_permissions_; | 56 pending_permissions_; |
58 GeolocationServicePtr geolocation_service_; | 57 GeolocationServicePtr geolocation_service_; |
59 bool enable_high_accuracy_; | 58 bool enable_high_accuracy_; |
60 PermissionServicePtr permission_service_; | 59 PermissionServicePtr permission_service_; |
61 }; | 60 }; |
62 | 61 |
63 } // namespace content | 62 } // namespace content |
64 | 63 |
65 #endif // CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_ | 64 #endif // CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_ |
OLD | NEW |