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" | |
10 #include "content/public/renderer/render_frame_observer.h" | 9 #include "content/public/renderer/render_frame_observer.h" |
11 #include "third_party/WebKit/public/web/WebGeolocationClient.h" | 10 #include "third_party/WebKit/public/web/WebGeolocationClient.h" |
12 #include "third_party/WebKit/public/web/WebGeolocationController.h" | 11 #include "third_party/WebKit/public/web/WebGeolocationController.h" |
13 | 12 |
14 namespace blink { | 13 namespace blink { |
15 class WebGeolocationController; | 14 class WebGeolocationController; |
16 class WebGeolocationPermissionRequest; | 15 class WebGeolocationPermissionRequest; |
17 class WebGeolocationPermissionRequestManager; | 16 class WebGeolocationPermissionRequestManager; |
18 class WebGeolocationPosition; | 17 class WebGeolocationPosition; |
19 } | 18 } |
20 | 19 |
21 namespace content { | 20 namespace content { |
22 struct Geoposition; | 21 struct Geoposition; |
23 | 22 |
24 // GeolocationDispatcher is a delegate for Geolocation messages used by | 23 // GeolocationDispatcher is a delegate for Geolocation messages used by |
25 // WebKit. | 24 // WebKit. |
26 // It's the complement of GeolocationDispatcherHost. | 25 // It's the complement of GeolocationDispatcherHost. |
27 class GeolocationDispatcher | 26 class GeolocationDispatcher : public RenderFrameObserver, |
28 : public RenderFrameObserver, | 27 public blink::WebGeolocationClient { |
29 public blink::WebGeolocationClient, | |
30 public mojo::InterfaceImpl<GeolocationServiceClient> { | |
31 public: | 28 public: |
32 explicit GeolocationDispatcher(RenderFrame* render_frame); | 29 explicit GeolocationDispatcher(RenderFrame* render_frame); |
33 virtual ~GeolocationDispatcher(); | 30 virtual ~GeolocationDispatcher(); |
34 | 31 |
35 private: | 32 private: |
36 // RenderFrame::Observer implementation. | 33 // RenderFrame::Observer implementation. |
37 bool OnMessageReceived(const IPC::Message& message) override; | 34 bool OnMessageReceived(const IPC::Message& message) override; |
38 | 35 |
39 // WebGeolocationClient | 36 // WebGeolocationClient |
40 virtual void startUpdating(); | 37 virtual void startUpdating(); |
41 virtual void stopUpdating(); | 38 virtual void stopUpdating(); |
42 virtual void setEnableHighAccuracy(bool enable_high_accuracy); | 39 virtual void setEnableHighAccuracy(bool enable_high_accuracy); |
43 virtual void setController(blink::WebGeolocationController* controller); | 40 virtual void setController(blink::WebGeolocationController* controller); |
44 virtual bool lastPosition(blink::WebGeolocationPosition& position); | 41 virtual bool lastPosition(blink::WebGeolocationPosition& position); |
45 virtual void requestPermission( | 42 virtual void requestPermission( |
46 const blink::WebGeolocationPermissionRequest& permissionRequest); | 43 const blink::WebGeolocationPermissionRequest& permissionRequest); |
47 virtual void cancelPermissionRequest( | 44 virtual void cancelPermissionRequest( |
48 const blink::WebGeolocationPermissionRequest& permissionRequest); | 45 const blink::WebGeolocationPermissionRequest& permissionRequest); |
49 | 46 |
50 // GeolocationServiceClient | |
51 void OnLocationUpdate(MojoGeopositionPtr geoposition) override; | |
52 | |
53 // Permission for using geolocation has been set. | 47 // Permission for using geolocation has been set. |
54 void OnPermissionSet(int bridge_id, bool is_allowed); | 48 void OnPermissionSet(int bridge_id, bool is_allowed); |
55 | 49 |
| 50 // We have an updated geolocation position or error code. |
| 51 void OnPositionUpdated(const content::Geoposition& geoposition); |
| 52 |
56 scoped_ptr<blink::WebGeolocationController> controller_; | 53 scoped_ptr<blink::WebGeolocationController> controller_; |
57 | 54 |
58 scoped_ptr<blink::WebGeolocationPermissionRequestManager> | 55 scoped_ptr<blink::WebGeolocationPermissionRequestManager> |
59 pending_permissions_; | 56 pending_permissions_; |
60 GeolocationServicePtr geolocation_service_; | |
61 bool enable_high_accuracy_; | 57 bool enable_high_accuracy_; |
| 58 bool updating_; |
62 }; | 59 }; |
63 | 60 |
64 } // namespace content | 61 } // namespace content |
65 | 62 |
66 #endif // CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_ | 63 #endif // CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_ |
OLD | NEW |