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

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

Issue 680323002: Revert of Partially convert geolocation IPC to Mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "content/browser/geolocation/geolocation_provider_impl.h"
13 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
14 15
15 class GURL; 16 class GURL;
16 17
17 namespace content { 18 namespace content {
18 19
19 // GeolocationDispatcherHost is an observer for Geolocation permissions-related 20 // GeolocationDispatcherHost is an observer for Geolocation messages.
20 // messages. In this role, it's the complement of GeolocationDispatcher (owned 21 // It's the complement of GeolocationDispatcher (owned by RenderView).
21 // by RenderFrame).
22 // TODO(blundell): Eliminate this class in favor of having
23 // Mojo handle permissions for geolocation once there is resolution on how
24 // that will work. crbug.com/420498
25 class GeolocationDispatcherHost : public WebContentsObserver { 22 class GeolocationDispatcherHost : public WebContentsObserver {
26 public: 23 public:
27 explicit GeolocationDispatcherHost(WebContents* web_contents); 24 explicit GeolocationDispatcherHost(WebContents* web_contents);
28 ~GeolocationDispatcherHost() override; 25 ~GeolocationDispatcherHost() override;
29 26
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
29 // then goes on to do so before being resumed, then it will not get
30 // geolocation updates until it is resumed.
31 void PauseOrResume(bool should_pause);
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
30 private: 40 private:
31 // WebContentsObserver 41 // WebContentsObserver
32 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; 42 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
43 void RenderViewHostChanged(RenderViewHost* old_host,
44 RenderViewHost* new_host) override;
33 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host, 45 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
34 const LoadCommittedDetails& details, 46 const LoadCommittedDetails& details,
35 const FrameNavigateParams& params) override; 47 const FrameNavigateParams& params) override;
36 bool OnMessageReceived(const IPC::Message& msg, 48 bool OnMessageReceived(const IPC::Message& msg,
37 RenderFrameHost* render_frame_host) override; 49 RenderFrameHost* render_frame_host) override;
38 50
39 // Message handlers: 51 // Message handlers:
40 // TODO(mlamouri): |requesting_origin| should be a security origin to 52 // TODO(mlamouri): |requesting_origin| should be a security origin to
41 // guarantee that a proper origin is passed. 53 // guarantee that a proper origin is passed.
42 void OnRequestPermission(RenderFrameHost* render_frame_host, 54 void OnRequestPermission(RenderFrameHost* render_frame_host,
43 int bridge_id, 55 int bridge_id,
44 const GURL& requesting_origin, 56 const GURL& requesting_origin,
45 bool user_gesture); 57 bool user_gesture);
58 void OnStartUpdating(RenderFrameHost* render_frame_host,
59 const GURL& requesting_origin,
60 bool enable_high_accuracy);
61 void OnStopUpdating(RenderFrameHost* render_frame_host);
62
63 // Updates the geolocation provider with the currently required update
64 // options.
65 void RefreshGeolocationOptions();
66
67 void OnLocationUpdate(const Geoposition& position);
68 void UpdateGeoposition(RenderFrameHost* frame, const Geoposition& position);
46 69
47 void SendGeolocationPermissionResponse(int render_process_id, 70 void SendGeolocationPermissionResponse(int render_process_id,
48 int render_frame_id, 71 int render_frame_id,
49 int bridge_id, 72 int bridge_id,
50 bool allowed); 73 bool allowed);
51 74
52 // Clear pending permissions associated with a given frame and request the 75 // Clear pending permissions associated with a given frame and request the
53 // browser to cancel the permission requests. 76 // browser to cancel the permission requests.
54 void CancelPermissionRequestsForFrame(RenderFrameHost* render_frame_host); 77 void CancelPermissionRequestsForFrame(RenderFrameHost* render_frame_host);
55 78
79 // A map from the RenderFrameHosts that have requested geolocation updates to
80 // the type of accuracy they requested (true = high accuracy).
81 std::map<RenderFrameHost*, bool> updating_frames_;
82 bool paused_;
83
56 struct PendingPermission { 84 struct PendingPermission {
57 PendingPermission(int render_frame_id, 85 PendingPermission(int render_frame_id,
58 int render_process_id, 86 int render_process_id,
59 int bridge_id, 87 int bridge_id,
60 const GURL& origin); 88 const GURL& origin);
61 ~PendingPermission(); 89 ~PendingPermission();
62 int render_frame_id; 90 int render_frame_id;
63 int render_process_id; 91 int render_process_id;
64 int bridge_id; 92 int bridge_id;
65 GURL origin; 93 GURL origin;
66 }; 94 };
67 std::vector<PendingPermission> pending_permissions_; 95 std::vector<PendingPermission> pending_permissions_;
68 96
97 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_;
98 scoped_ptr<Geoposition> geoposition_override_;
99
69 base::WeakPtrFactory<GeolocationDispatcherHost> weak_factory_; 100 base::WeakPtrFactory<GeolocationDispatcherHost> weak_factory_;
70 101
71 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost); 102 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost);
72 }; 103 };
73 104
74 } // namespace content 105 } // namespace content
75 106
76 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ 107 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/geolocation/geolocation_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698