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