Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: content/browser/geolocation/geolocation_dispatcher_host.h

Issue 603323004: DevTools: Add geolocation override in browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 explicit GeolocationDispatcherHost(WebContents* web_contents); 24 explicit GeolocationDispatcherHost(WebContents* web_contents);
25 virtual ~GeolocationDispatcherHost(); 25 virtual ~GeolocationDispatcherHost();
26 26
27 // Pause or resumes geolocation. Resuming when nothing is paused is a no-op. 27 // Pause or resumes geolocation. Resuming when nothing is paused is a no-op.
28 // If the web contents is paused while not currently using geolocation but 28 // If the web contents is paused while not currently using geolocation but
29 // then goes on to do so before being resumed, then it will not get 29 // then goes on to do so before being resumed, then it will not get
30 // geolocation updates until it is resumed. 30 // geolocation updates until it is resumed.
31 void PauseOrResume(bool should_pause); 31 void PauseOrResume(bool should_pause);
32 32
33 // Enables geolocation override.
34 void SetOverride(scoped_ptr<Geoposition> geoposition);
Michael van Ouwerkerk 2014/10/06 13:38:23 Why do you need to introduce a new way to override
vkuzkokov 2014/10/06 13:48:21 OverrideLocationForTesting works on all browser. W
35
36 // Disables geolocation override.
37 void ClearOverride();
38
33 private: 39 private:
34 // WebContentsObserver 40 // WebContentsObserver
35 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE; 41 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE;
36 virtual void RenderViewHostChanged(RenderViewHost* old_host, 42 virtual void RenderViewHostChanged(RenderViewHost* old_host,
37 RenderViewHost* new_host) OVERRIDE; 43 RenderViewHost* new_host) OVERRIDE;
38 virtual bool OnMessageReceived( 44 virtual bool OnMessageReceived(
39 const IPC::Message& msg, RenderFrameHost* render_frame_host) OVERRIDE; 45 const IPC::Message& msg, RenderFrameHost* render_frame_host) OVERRIDE;
40 46
41 // Message handlers: 47 // Message handlers:
42 void OnRequestPermission(RenderFrameHost* render_frame_host, 48 void OnRequestPermission(RenderFrameHost* render_frame_host,
43 int bridge_id, 49 int bridge_id,
44 const GURL& requesting_frame, 50 const GURL& requesting_frame,
45 bool user_gesture); 51 bool user_gesture);
46 void OnCancelPermissionRequest(RenderFrameHost* render_frame_host, 52 void OnCancelPermissionRequest(RenderFrameHost* render_frame_host,
47 int bridge_id, 53 int bridge_id,
48 const GURL& requesting_frame); 54 const GURL& requesting_frame);
49 void OnStartUpdating(RenderFrameHost* render_frame_host, 55 void OnStartUpdating(RenderFrameHost* render_frame_host,
50 const GURL& requesting_frame, 56 const GURL& requesting_frame,
51 bool enable_high_accuracy); 57 bool enable_high_accuracy);
52 void OnStopUpdating(RenderFrameHost* render_frame_host); 58 void OnStopUpdating(RenderFrameHost* render_frame_host);
53 59
54 // Updates the geolocation provider with the currently required update 60 // Updates the geolocation provider with the currently required update
55 // options. 61 // options.
56 void RefreshGeolocationOptions(); 62 void RefreshGeolocationOptions();
57 63
58 void OnLocationUpdate(const Geoposition& position); 64 void OnLocationUpdate(const Geoposition& position);
65 void UpdateGeoposition(RenderFrameHost* frame, const Geoposition& position);
59 66
60 void SendGeolocationPermissionResponse(int render_process_id, 67 void SendGeolocationPermissionResponse(int render_process_id,
61 int render_frame_id, 68 int render_frame_id,
62 int bridge_id, 69 int bridge_id,
63 bool allowed); 70 bool allowed);
64 71
65 // A map from the RenderFrameHosts that have requested geolocation updates to 72 // A map from the RenderFrameHosts that have requested geolocation updates to
66 // the type of accuracy they requested (true = high accuracy). 73 // the type of accuracy they requested (true = high accuracy).
67 std::map<RenderFrameHost*, bool> updating_frames_; 74 std::map<RenderFrameHost*, bool> updating_frames_;
68 bool paused_; 75 bool paused_;
69 76
70 struct PendingPermission { 77 struct PendingPermission {
71 PendingPermission(int render_frame_id, 78 PendingPermission(int render_frame_id,
72 int render_process_id, 79 int render_process_id,
73 int bridge_id); 80 int bridge_id);
74 ~PendingPermission(); 81 ~PendingPermission();
75 int render_frame_id; 82 int render_frame_id;
76 int render_process_id; 83 int render_process_id;
77 int bridge_id; 84 int bridge_id;
78 }; 85 };
79 std::vector<PendingPermission> pending_permissions_; 86 std::vector<PendingPermission> pending_permissions_;
80 87
81 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; 88 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_;
89 scoped_ptr<Geoposition> geoposition_override_;
82 90
83 base::WeakPtrFactory<GeolocationDispatcherHost> weak_factory_; 91 base::WeakPtrFactory<GeolocationDispatcherHost> weak_factory_;
84 92
85 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost); 93 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost);
86 }; 94 };
87 95
88 } // namespace content 96 } // namespace content
89 97
90 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ 98 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698