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.
5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_
11 #include "base/callback_forward.h"
12 #include "base/memory/weak_ptr.h"
13 #include "content/public/browser/web_contents_observer.h"
19 // GeolocationDispatcherHost is an observer for Geolocation permissions-related
20 // messages. In this role, it's the complement of GeolocationDispatcher (owned
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 {
27 explicit GeolocationDispatcherHost(WebContents* web_contents);
28 ~GeolocationDispatcherHost() override;
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;
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,
44 const GURL& requesting_origin,
47 void SendGeolocationPermissionResponse(int render_process_id,
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);
56 struct PendingPermission {
57 PendingPermission(int render_frame_id,
58 int render_process_id,
63 int render_process_id;
67 std::vector<PendingPermission> pending_permissions_;
69 base::WeakPtrFactory<GeolocationDispatcherHost> weak_factory_;
71 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost);
74 } // namespace content
76 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_