OLD | NEW |
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/browser/geolocation/geolocation_provider_impl.h" |
14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
15 | 15 |
16 class GURL; | 16 class GURL; |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 // GeolocationDispatcherHost is an observer for Geolocation messages. | 20 // GeolocationDispatcherHost is an observer for Geolocation messages. |
21 // It's the complement of GeolocationDispatcher (owned by RenderView). | 21 // It's the complement of GeolocationDispatcher (owned by RenderView). |
22 class GeolocationDispatcherHost : public WebContentsObserver { | 22 class GeolocationDispatcherHost : public WebContentsObserver { |
23 public: | 23 public: |
24 explicit GeolocationDispatcherHost(WebContents* web_contents); | 24 explicit GeolocationDispatcherHost(WebContents* web_contents); |
25 virtual ~GeolocationDispatcherHost(); | 25 ~GeolocationDispatcherHost() override; |
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 | 33 // Enables geolocation override. This method is used by DevTools to |
34 // trigger possible location-specific behavior in particular web contents. | 34 // trigger possible location-specific behavior in particular web contents. |
35 void SetOverride(scoped_ptr<Geoposition> geoposition); | 35 void SetOverride(scoped_ptr<Geoposition> geoposition); |
36 | 36 |
37 // Disables geolocation override. | 37 // Disables geolocation override. |
38 void ClearOverride(); | 38 void ClearOverride(); |
39 | 39 |
40 private: | 40 private: |
41 // WebContentsObserver | 41 // WebContentsObserver |
42 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; | 42 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; |
43 virtual void RenderViewHostChanged(RenderViewHost* old_host, | 43 void RenderViewHostChanged(RenderViewHost* old_host, |
44 RenderViewHost* new_host) override; | 44 RenderViewHost* new_host) override; |
45 virtual void DidNavigateAnyFrame(RenderFrameHost* render_frame_host, | 45 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host, |
46 const LoadCommittedDetails& details, | 46 const LoadCommittedDetails& details, |
47 const FrameNavigateParams& params) override; | 47 const FrameNavigateParams& params) override; |
48 virtual bool OnMessageReceived( | 48 bool OnMessageReceived(const IPC::Message& msg, |
49 const IPC::Message& msg, RenderFrameHost* render_frame_host) override; | 49 RenderFrameHost* render_frame_host) override; |
50 | 50 |
51 // Message handlers: | 51 // Message handlers: |
52 // TODO(mlamouri): |requesting_origin| should be a security origin to | 52 // TODO(mlamouri): |requesting_origin| should be a security origin to |
53 // guarantee that a proper origin is passed. | 53 // guarantee that a proper origin is passed. |
54 void OnRequestPermission(RenderFrameHost* render_frame_host, | 54 void OnRequestPermission(RenderFrameHost* render_frame_host, |
55 int bridge_id, | 55 int bridge_id, |
56 const GURL& requesting_origin, | 56 const GURL& requesting_origin, |
57 bool user_gesture); | 57 bool user_gesture); |
58 void OnStartUpdating(RenderFrameHost* render_frame_host, | 58 void OnStartUpdating(RenderFrameHost* render_frame_host, |
59 const GURL& requesting_origin, | 59 const GURL& requesting_origin, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 scoped_ptr<Geoposition> geoposition_override_; | 98 scoped_ptr<Geoposition> geoposition_override_; |
99 | 99 |
100 base::WeakPtrFactory<GeolocationDispatcherHost> weak_factory_; | 100 base::WeakPtrFactory<GeolocationDispatcherHost> weak_factory_; |
101 | 101 |
102 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost); | 102 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost); |
103 }; | 103 }; |
104 | 104 |
105 } // namespace content | 105 } // namespace content |
106 | 106 |
107 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ | 107 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ |
OLD | NEW |