| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ | |
| 6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "content/public/browser/web_contents_observer.h" | |
| 14 | |
| 15 class GURL; | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 19 // GeolocationDispatcherHost is an observer for Geolocation permissions-related | |
| 20 // messages. In this role, it's the complement of GeolocationDispatcher (owned | |
| 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 { | |
| 26 public: | |
| 27 explicit GeolocationDispatcherHost(WebContents* web_contents); | |
| 28 ~GeolocationDispatcherHost() override; | |
| 29 | |
| 30 private: | |
| 31 // WebContentsObserver | |
| 32 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; | |
| 33 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host, | |
| 34 const LoadCommittedDetails& details, | |
| 35 const FrameNavigateParams& params) override; | |
| 36 bool OnMessageReceived(const IPC::Message& msg, | |
| 37 RenderFrameHost* render_frame_host) override; | |
| 38 | |
| 39 // Message handlers: | |
| 40 // TODO(mlamouri): |requesting_origin| should be a security origin to | |
| 41 // guarantee that a proper origin is passed. | |
| 42 void OnRequestPermission(RenderFrameHost* render_frame_host, | |
| 43 int bridge_id, | |
| 44 const GURL& requesting_origin, | |
| 45 bool user_gesture); | |
| 46 | |
| 47 void SendGeolocationPermissionResponse(int render_process_id, | |
| 48 int render_frame_id, | |
| 49 int bridge_id, | |
| 50 bool allowed); | |
| 51 | |
| 52 // Clear pending permissions associated with a given frame and request the | |
| 53 // browser to cancel the permission requests. | |
| 54 void CancelPermissionRequestsForFrame(RenderFrameHost* render_frame_host); | |
| 55 | |
| 56 struct PendingPermission { | |
| 57 PendingPermission(int render_frame_id, | |
| 58 int render_process_id, | |
| 59 int bridge_id, | |
| 60 const GURL& origin); | |
| 61 ~PendingPermission(); | |
| 62 int render_frame_id; | |
| 63 int render_process_id; | |
| 64 int bridge_id; | |
| 65 GURL origin; | |
| 66 }; | |
| 67 std::vector<PendingPermission> pending_permissions_; | |
| 68 | |
| 69 base::WeakPtrFactory<GeolocationDispatcherHost> weak_factory_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost); | |
| 72 }; | |
| 73 | |
| 74 } // namespace content | |
| 75 | |
| 76 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ | |
| OLD | NEW |