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