1 // Copyright (c) 2011 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_
9 #include "base/memory/scoped_ptr.h"
10 #include "content/public/renderer/render_view_observer.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationClient.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationController.h"
18 class WebGeolocationController
;
19 class WebGeolocationPermissionRequest
;
20 class WebGeolocationPermissionRequestManager
;
21 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 content::RenderViewObserver
,
28 public WebKit::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(WebKit::WebGeolocationController
* controller
);
43 virtual bool lastPosition(WebKit::WebGeolocationPosition
& position
);
44 virtual void requestPermission(
45 const WebKit::WebGeolocationPermissionRequest
& permissionRequest
);
46 virtual void cancelPermissionRequest(
47 const WebKit::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 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
< WebKit::WebGeolocationController
> controller_
;
60 scoped_ptr
<WebKit::WebGeolocationPermissionRequestManager
>
62 bool enable_high_accuracy_
;
66 #endif // CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_