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_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_
10 #include "content/browser/geolocation/geolocation_provider_impl.h"
11 #include "content/public/browser/web_contents_observer.h"
17 class GeolocationPermissionContext
;
19 // GeolocationDispatcherHost is an observer for Geolocation messages.
20 // It's the complement of GeolocationDispatcher (owned by RenderView).
21 class GeolocationDispatcherHost
: public WebContentsObserver
{
23 explicit GeolocationDispatcherHost(WebContents
* web_contents
);
24 virtual ~GeolocationDispatcherHost();
26 // Pause or resumes geolocation. Resuming when nothing is paused is a no-op.
27 // If the web contents is paused while not currently using geolocation but
28 // then goes on to do so before being resumed, then it will not get
29 // geolocation updates until it is resumed.
30 void PauseOrResume(bool should_pause
);
33 // WebContentsObserver
34 virtual void RenderFrameDeleted(RenderFrameHost
* render_frame_host
) OVERRIDE
;
35 virtual void RenderViewHostChanged(RenderViewHost
* old_host
,
36 RenderViewHost
* new_host
) OVERRIDE
;
37 virtual bool OnMessageReceived(
38 const IPC::Message
& msg
, RenderFrameHost
* render_frame_host
) OVERRIDE
;
41 void OnRequestPermission(RenderFrameHost
* render_frame_host
,
43 const GURL
& requesting_frame
,
45 void OnCancelPermissionRequest(RenderFrameHost
* render_frame_host
,
47 const GURL
& requesting_frame
);
48 void OnStartUpdating(RenderFrameHost
* render_frame_host
,
49 const GURL
& requesting_frame
,
50 bool enable_high_accuracy
);
51 void OnStopUpdating(RenderFrameHost
* render_frame_host
);
53 // Updates the geolocation provider with the currently required update
55 void RefreshGeolocationOptions();
57 void OnLocationUpdate(const Geoposition
& position
);
59 scoped_refptr
<GeolocationPermissionContext
> geolocation_permission_context_
;
61 // A map from the RenderFrameHosts that have requested geolocation updates to
62 // the type of accuracy they requested (true = high accuracy).
63 std::map
<RenderFrameHost
*, bool> updating_frames_
;
66 scoped_ptr
<GeolocationProvider::Subscription
> geolocation_subscription_
;
68 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost
);
71 } // namespace content
73 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_