| 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_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ |
| 6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include <map> |
| 9 |
| 8 #include "content/browser/geolocation/geolocation_provider_impl.h" | 10 #include "content/browser/geolocation/geolocation_provider_impl.h" |
| 9 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 10 | 12 |
| 11 class GURL; | 13 class GURL; |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 | 16 |
| 15 class GeolocationPermissionContext; | 17 class GeolocationPermissionContext; |
| 16 | 18 |
| 17 // GeolocationDispatcherHost is an observer for Geolocation messages. | 19 // GeolocationDispatcherHost is an observer for Geolocation messages. |
| 18 // It's the complement of GeolocationDispatcher (owned by RenderView). | 20 // It's the complement of GeolocationDispatcher (owned by RenderView). |
| 19 class GeolocationDispatcherHost : public WebContentsObserver { | 21 class GeolocationDispatcherHost : public WebContentsObserver { |
| 20 public: | 22 public: |
| 21 explicit GeolocationDispatcherHost(WebContents* web_contents); | 23 explicit GeolocationDispatcherHost(WebContents* web_contents); |
| 22 virtual ~GeolocationDispatcherHost(); | 24 virtual ~GeolocationDispatcherHost(); |
| 23 | 25 |
| 24 // Pause or resumes geolocation. Resuming when nothing is paused is a no-op. | 26 // Pause or resumes geolocation. Resuming when nothing is paused is a no-op. |
| 25 // If the web contents is paused while not currently using geolocation but | 27 // If the web contents is paused while not currently using geolocation but |
| 26 // then goes on to do so before being resumed, then it will not get | 28 // then goes on to do so before being resumed, then it will not get |
| 27 // geolocation updates until it is resumed. | 29 // geolocation updates until it is resumed. |
| 28 void PauseOrResume(bool should_pause); | 30 void PauseOrResume(bool should_pause); |
| 29 | 31 |
| 30 private: | 32 private: |
| 31 // WebContentsObserver | 33 // WebContentsObserver |
| 34 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE; |
| 32 virtual void RenderViewHostChanged(RenderViewHost* old_host, | 35 virtual void RenderViewHostChanged(RenderViewHost* old_host, |
| 33 RenderViewHost* new_host) OVERRIDE; | 36 RenderViewHost* new_host) OVERRIDE; |
| 34 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 37 virtual bool OnMessageReceived( |
| 38 const IPC::Message& msg, RenderFrameHost* render_frame_host) OVERRIDE; |
| 35 | 39 |
| 36 // Message handlers: | 40 // Message handlers: |
| 37 void OnRequestPermission(int bridge_id, | 41 void OnRequestPermission(RenderFrameHost* render_frame_host, |
| 42 int bridge_id, |
| 38 const GURL& requesting_frame, | 43 const GURL& requesting_frame, |
| 39 bool user_gesture); | 44 bool user_gesture); |
| 40 void OnCancelPermissionRequest(int bridge_id, | 45 void OnCancelPermissionRequest(RenderFrameHost* render_frame_host, |
| 46 int bridge_id, |
| 41 const GURL& requesting_frame); | 47 const GURL& requesting_frame); |
| 42 void OnStartUpdating(const GURL& requesting_frame, | 48 void OnStartUpdating(RenderFrameHost* render_frame_host, |
| 49 const GURL& requesting_frame, |
| 43 bool enable_high_accuracy); | 50 bool enable_high_accuracy); |
| 44 void OnStopUpdating(); | 51 void OnStopUpdating(RenderFrameHost* render_frame_host); |
| 45 | 52 |
| 46 // Updates the geolocation provider with the currently required update | 53 // Updates the geolocation provider with the currently required update |
| 47 // options. | 54 // options. |
| 48 void RefreshGeolocationOptions(); | 55 void RefreshGeolocationOptions(); |
| 49 | 56 |
| 50 void OnLocationUpdate(const Geoposition& position); | 57 void OnLocationUpdate(const Geoposition& position); |
| 51 | 58 |
| 52 scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; | 59 scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; |
| 53 | 60 |
| 54 bool watching_requested_; | 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_; |
| 55 bool paused_; | 64 bool paused_; |
| 56 bool high_accuracy_; | |
| 57 | 65 |
| 58 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; | 66 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; |
| 59 | 67 |
| 60 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost); | 68 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost); |
| 61 }; | 69 }; |
| 62 | 70 |
| 63 } // namespace content | 71 } // namespace content |
| 64 | 72 |
| 65 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ | 73 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ |
| OLD | NEW |