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.
5 #ifndef CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_
6 #define CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/public/renderer/render_view_observer.h"
10 #include "third_party/WebKit/public/web/WebGeolocationClient.h"
11 #include "third_party/WebKit/public/web/WebGeolocationController.h"
14 class WebGeolocationController
;
15 class WebGeolocationPermissionRequest
;
16 class WebGeolocationPermissionRequestManager
;
17 class WebGeolocationPosition
;
24 // GeolocationDispatcher is a delegate for Geolocation messages used by
26 // It's the complement of GeolocationDispatcherHost (owned by RenderViewHost).
27 class GeolocationDispatcher
: public RenderViewObserver
,
28 public blink::WebGeolocationClient
{
30 explicit GeolocationDispatcher(RenderViewImpl
* render_view
);
31 virtual ~GeolocationDispatcher();
34 // RenderView::Observer implementation.
35 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
37 // WebGeolocationClient
38 virtual void geolocationDestroyed();
39 virtual void startUpdating();
40 virtual void stopUpdating();
41 virtual void setEnableHighAccuracy(bool enable_high_accuracy
);
42 virtual void setController(blink::WebGeolocationController
* controller
);
43 virtual bool lastPosition(blink::WebGeolocationPosition
& position
);
44 virtual void requestPermission(
45 const blink::WebGeolocationPermissionRequest
& permissionRequest
);
46 virtual void cancelPermissionRequest(
47 const blink::WebGeolocationPermissionRequest
& permissionRequest
);
49 // Permission for using geolocation has been set.
50 void OnPermissionSet(int bridge_id
, bool is_allowed
);
52 // We have an updated geolocation position or error code.
53 void OnPositionUpdated(const content::Geoposition
& geoposition
);
55 // The controller_ is valid for the lifetime of the underlying
56 // WebCore::GeolocationController. geolocationDestroyed() is
57 // invoked when the underlying object is destroyed.
58 scoped_ptr
< blink::WebGeolocationController
> controller_
;
60 scoped_ptr
<blink::WebGeolocationPermissionRequestManager
>
62 bool enable_high_accuracy_
;
66 } // namespace content
68 #endif // CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_