| 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 CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_ | 6 #define CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/content_settings/permission_queue_controller.h" | 11 #include "chrome/browser/content_settings/permission_queue_controller.h" |
| 12 #include "content/public/browser/geolocation_permission_context.h" | 12 #include "content/public/browser/geolocation_permission_context.h" |
| 13 | 13 |
| 14 namespace content { |
| 15 class WebContents; |
| 16 } |
| 17 |
| 14 class PermissionRequestID; | 18 class PermissionRequestID; |
| 15 class Profile; | 19 class Profile; |
| 16 | 20 |
| 17 // Chrome specific implementation of GeolocationPermissionContext; manages | 21 // Chrome specific implementation of GeolocationPermissionContext; manages |
| 18 // Geolocation permissions flow, and delegates UI handling via | 22 // Geolocation permissions flow, and delegates UI handling via |
| 19 // PermissionQueueController. | 23 // PermissionQueueController. |
| 20 class ChromeGeolocationPermissionContext | 24 class ChromeGeolocationPermissionContext |
| 21 : public content::GeolocationPermissionContext { | 25 : public content::GeolocationPermissionContext { |
| 22 public: | 26 public: |
| 23 explicit ChromeGeolocationPermissionContext(Profile* profile); | 27 explicit ChromeGeolocationPermissionContext(Profile* profile); |
| 24 | 28 |
| 25 // GeolocationPermissionContext: | 29 // GeolocationPermissionContext: |
| 26 virtual void RequestGeolocationPermission( | 30 virtual void RequestGeolocationPermission( |
| 27 int render_process_id, | 31 int render_process_id, |
| 28 int render_view_id, | 32 int render_view_id, |
| 29 int bridge_id, | 33 int bridge_id, |
| 30 const GURL& requesting_frame, | 34 const GURL& requesting_frame, |
| 31 base::Callback<void(bool)> callback) OVERRIDE; | 35 base::Callback<void(bool)> callback) OVERRIDE; |
| 32 virtual void CancelGeolocationPermissionRequest( | 36 virtual void CancelGeolocationPermissionRequest( |
| 33 int render_process_id, | 37 int render_process_id, |
| 34 int render_view_id, | 38 int render_view_id, |
| 35 int bridge_id, | 39 int bridge_id, |
| 36 const GURL& requesting_frame) OVERRIDE; | 40 const GURL& requesting_frame) OVERRIDE; |
| 37 | 41 |
| 38 // Called on the UI thread when the profile is about to be destroyed. | 42 // Called on the UI thread when the profile is about to be destroyed. |
| 39 void ShutdownOnUIThread(); | 43 void ShutdownOnUIThread(); |
| 40 | 44 |
| 41 protected: | |
| 42 virtual ~ChromeGeolocationPermissionContext(); | |
| 43 | |
| 44 Profile* profile() const { return profile_; } | |
| 45 | |
| 46 // Return an instance of the infobar queue controller, creating it | |
| 47 // if necessary. | |
| 48 PermissionQueueController* QueueController(); | |
| 49 | |
| 50 // Notifies whether or not the corresponding bridge is allowed to use | 45 // Notifies whether or not the corresponding bridge is allowed to use |
| 51 // geolocation via | 46 // geolocation via |
| 52 // GeolocationPermissionContext::SetGeolocationPermissionResponse(). | 47 // GeolocationPermissionContext::SetGeolocationPermissionResponse(). |
| 53 // Called on the UI thread. | 48 // Called on the UI thread. |
| 54 void NotifyPermissionSet(const PermissionRequestID& id, | 49 void NotifyPermissionSet(const PermissionRequestID& id, |
| 55 const GURL& requesting_frame, | 50 const GURL& requesting_frame, |
| 56 base::Callback<void(bool)> callback, | 51 base::Callback<void(bool)> callback, |
| 57 bool allowed); | 52 bool allowed); |
| 58 | 53 |
| 54 protected: |
| 55 virtual ~ChromeGeolocationPermissionContext(); |
| 56 |
| 57 Profile* profile() const { return profile_; } |
| 58 |
| 59 // Return an instance of the infobar queue controller, creating it |
| 60 // if necessary. |
| 61 PermissionQueueController* QueueController(); |
| 62 |
| 59 // ChromeGeolocationPermissionContext implementation: | 63 // ChromeGeolocationPermissionContext implementation: |
| 60 // Decide whether the geolocation permission should be granted. | 64 // Decide whether the geolocation permission should be granted. |
| 61 // Calls PermissionDecided if permission can be decided non-interactively, | 65 // Calls PermissionDecided if permission can be decided non-interactively, |
| 62 // or NotifyPermissionSet if permission decided by presenting an | 66 // or NotifyPermissionSet if permission decided by presenting an |
| 63 // infobar to the user. Called on the UI thread. | 67 // infobar to the user. Called on the UI thread. |
| 64 virtual void DecidePermission(const PermissionRequestID& id, | 68 virtual void DecidePermission(content::WebContents* web_contents, |
| 69 const PermissionRequestID& id, |
| 65 const GURL& requesting_frame, | 70 const GURL& requesting_frame, |
| 66 const GURL& embedder, | 71 const GURL& embedder, |
| 67 base::Callback<void(bool)> callback); | 72 base::Callback<void(bool)> callback); |
| 68 | 73 |
| 69 // Called when permission is granted without interactively asking | 74 // Called when permission is granted without interactively asking |
| 70 // the user. Can be overridden to introduce additional UI flow. | 75 // the user. Can be overridden to introduce additional UI flow. |
| 71 // Should ultimately ensure that NotifyPermissionSet is called. | 76 // Should ultimately ensure that NotifyPermissionSet is called. |
| 72 // Called on the UI thread. | 77 // Called on the UI thread. |
| 73 virtual void PermissionDecided(const PermissionRequestID& id, | 78 virtual void PermissionDecided(const PermissionRequestID& id, |
| 74 const GURL& requesting_frame, | 79 const GURL& requesting_frame, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 86 | 91 |
| 87 // These must only be accessed from the UI thread. | 92 // These must only be accessed from the UI thread. |
| 88 Profile* const profile_; | 93 Profile* const profile_; |
| 89 bool shutting_down_; | 94 bool shutting_down_; |
| 90 scoped_ptr<PermissionQueueController> permission_queue_controller_; | 95 scoped_ptr<PermissionQueueController> permission_queue_controller_; |
| 91 | 96 |
| 92 DISALLOW_COPY_AND_ASSIGN(ChromeGeolocationPermissionContext); | 97 DISALLOW_COPY_AND_ASSIGN(ChromeGeolocationPermissionContext); |
| 93 }; | 98 }; |
| 94 | 99 |
| 95 #endif // CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_ | 100 #endif // CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_ |
| OLD | NEW |