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

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: Rebased. Expanded SetOverride description. 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. This method is used by DevTools to
34 // trigger possible location-specific behavior in particular web contents.
35 void SetOverride(scoped_ptr<Geoposition> geoposition);
36
37 // Disables geolocation override.
38 void ClearOverride();
39
33 private: 40 private:
34 // WebContentsObserver 41 // WebContentsObserver
35 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; 42 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
36 virtual void RenderViewHostChanged(RenderViewHost* old_host, 43 virtual void RenderViewHostChanged(RenderViewHost* old_host,
37 RenderViewHost* new_host) override; 44 RenderViewHost* new_host) override;
38 virtual bool OnMessageReceived( 45 virtual bool OnMessageReceived(
39 const IPC::Message& msg, RenderFrameHost* render_frame_host) override; 46 const IPC::Message& msg, RenderFrameHost* render_frame_host) override;
40 47
41 // Message handlers: 48 // Message handlers:
42 void OnRequestPermission(RenderFrameHost* render_frame_host, 49 void OnRequestPermission(RenderFrameHost* render_frame_host,
43 int bridge_id, 50 int bridge_id,
44 const GURL& requesting_frame, 51 const GURL& requesting_frame,
45 bool user_gesture); 52 bool user_gesture);
46 void OnCancelPermissionRequest(RenderFrameHost* render_frame_host, 53 void OnCancelPermissionRequest(RenderFrameHost* render_frame_host,
47 int bridge_id, 54 int bridge_id,
48 const GURL& requesting_frame); 55 const GURL& requesting_frame);
49 void OnStartUpdating(RenderFrameHost* render_frame_host, 56 void OnStartUpdating(RenderFrameHost* render_frame_host,
50 const GURL& requesting_frame, 57 const GURL& requesting_frame,
51 bool enable_high_accuracy); 58 bool enable_high_accuracy);
52 void OnStopUpdating(RenderFrameHost* render_frame_host); 59 void OnStopUpdating(RenderFrameHost* render_frame_host);
53 60
54 // Updates the geolocation provider with the currently required update 61 // Updates the geolocation provider with the currently required update
55 // options. 62 // options.
56 void RefreshGeolocationOptions(); 63 void RefreshGeolocationOptions();
57 64
58 void OnLocationUpdate(const Geoposition& position); 65 void OnLocationUpdate(const Geoposition& position);
66 void UpdateGeoposition(RenderFrameHost* frame, const Geoposition& position);
59 67
60 void SendGeolocationPermissionResponse(int render_process_id, 68 void SendGeolocationPermissionResponse(int render_process_id,
61 int render_frame_id, 69 int render_frame_id,
62 int bridge_id, 70 int bridge_id,
63 bool allowed); 71 bool allowed);
64 72
65 // A map from the RenderFrameHosts that have requested geolocation updates to 73 // A map from the RenderFrameHosts that have requested geolocation updates to
66 // the type of accuracy they requested (true = high accuracy). 74 // the type of accuracy they requested (true = high accuracy).
67 std::map<RenderFrameHost*, bool> updating_frames_; 75 std::map<RenderFrameHost*, bool> updating_frames_;
68 bool paused_; 76 bool paused_;
69 77
70 struct PendingPermission { 78 struct PendingPermission {
71 PendingPermission(int render_frame_id, 79 PendingPermission(int render_frame_id,
72 int render_process_id, 80 int render_process_id,
73 int bridge_id); 81 int bridge_id);
74 ~PendingPermission(); 82 ~PendingPermission();
75 int render_frame_id; 83 int render_frame_id;
76 int render_process_id; 84 int render_process_id;
77 int bridge_id; 85 int bridge_id;
78 }; 86 };
79 std::vector<PendingPermission> pending_permissions_; 87 std::vector<PendingPermission> pending_permissions_;
80 88
81 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; 89 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_;
90 scoped_ptr<Geoposition> geoposition_override_;
82 91
83 base::WeakPtrFactory<GeolocationDispatcherHost> weak_factory_; 92 base::WeakPtrFactory<GeolocationDispatcherHost> weak_factory_;
84 93
85 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost); 94 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost);
86 }; 95 };
87 96
88 } // namespace content 97 } // namespace content
89 98
90 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ 99 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698