Added unit test for DevTools' ephemeral port support.
[chromium-blink-merge.git] / content / browser / geolocation / geolocation_dispatcher_host.h
blob151ed46c74d54296cca1ca16a0f1565dcf353719
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_
8 #include <map>
10 #include "content/browser/geolocation/geolocation_provider_impl.h"
11 #include "content/public/browser/web_contents_observer.h"
13 class GURL;
15 namespace content {
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 {
22 public:
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);
32 private:
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;
40 // Message handlers:
41 void OnRequestPermission(RenderFrameHost* render_frame_host,
42 int bridge_id,
43 const GURL& requesting_frame,
44 bool user_gesture);
45 void OnCancelPermissionRequest(RenderFrameHost* render_frame_host,
46 int bridge_id,
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
54 // options.
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_;
64 bool paused_;
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_