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