| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_GEOLOCATION_PERMISSION_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_H_ | 6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 : public base::RefCountedThreadSafe<GeolocationPermissionContext> { | 29 : public base::RefCountedThreadSafe<GeolocationPermissionContext> { |
| 30 public: | 30 public: |
| 31 explicit GeolocationPermissionContext(Profile* profile); | 31 explicit GeolocationPermissionContext(Profile* profile); |
| 32 | 32 |
| 33 // See ContentBrowserClient method of the same name. | 33 // See ContentBrowserClient method of the same name. |
| 34 void RequestGeolocationPermission( | 34 void RequestGeolocationPermission( |
| 35 content::WebContents* web_contents, | 35 content::WebContents* web_contents, |
| 36 int bridge_id, | 36 int bridge_id, |
| 37 const GURL& requesting_frame, | 37 const GURL& requesting_frame, |
| 38 bool user_gesture, | 38 bool user_gesture, |
| 39 base::Callback<void(bool)> result_callback, | 39 base::Callback<void(int, bool)> result_callback, |
| 40 base::Closure* cancel_callback); | 40 base::Closure* cancel_callback); |
| 41 | 41 |
| 42 // 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. |
| 43 void ShutdownOnUIThread(); | 43 void ShutdownOnUIThread(); |
| 44 | 44 |
| 45 // Notifies whether or not the corresponding bridge is allowed to use | 45 // Notifies whether or not the corresponding bridge is allowed to use |
| 46 // geolocation via | 46 // geolocation via |
| 47 // GeolocationPermissionContext::SetGeolocationPermissionResponse(). | 47 // GeolocationPermissionContext::SetGeolocationPermissionResponse(). |
| 48 // Called on the UI thread. | 48 // Called on the UI thread. |
| 49 void NotifyInfoBarPermissionSet(const PermissionRequestID& id, |
| 50 const GURL& requesting_frame, |
| 51 base::Callback<void(bool)> callback, |
| 52 bool allowed); |
| 49 void NotifyPermissionSet(const PermissionRequestID& id, | 53 void NotifyPermissionSet(const PermissionRequestID& id, |
| 50 const GURL& requesting_frame, | 54 const GURL& requesting_frame, |
| 51 base::Callback<void(bool)> callback, | 55 base::Callback<void(int, bool)> callback, |
| 52 bool allowed); | 56 bool allowed); |
| 57 void NotifyPermissionSet(const PermissionRequestID& id, |
| 58 const GURL& requesting_frame, |
| 59 base::Callback<void(int, bool)> callback, |
| 60 bool allowed, |
| 61 int choice); |
| 53 | 62 |
| 54 protected: | 63 protected: |
| 55 virtual ~GeolocationPermissionContext(); | 64 virtual ~GeolocationPermissionContext(); |
| 56 | 65 |
| 57 Profile* profile() const { return profile_; } | 66 Profile* profile() const { return profile_; } |
| 58 | 67 |
| 59 // Return an instance of the infobar queue controller, creating it | 68 // Return an instance of the infobar queue controller, creating it |
| 60 // if necessary. | 69 // if necessary. |
| 61 PermissionQueueController* QueueController(); | 70 PermissionQueueController* QueueController(); |
| 62 | 71 |
| 63 void CancelGeolocationPermissionRequest( | 72 void CancelGeolocationPermissionRequest( |
| 64 int render_process_id, | 73 int render_process_id, |
| 65 int render_view_id, | 74 int render_view_id, |
| 66 int bridge_id); | 75 int bridge_id); |
| 67 | 76 |
| 68 // GeolocationPermissionContext implementation: | 77 // GeolocationPermissionContext implementation: |
| 69 // Decide whether the geolocation permission should be granted. | 78 // Decide whether the geolocation permission should be granted. |
| 70 // Calls PermissionDecided if permission can be decided non-interactively, | 79 // Calls PermissionDecided if permission can be decided non-interactively, |
| 71 // or NotifyPermissionSet if permission decided by presenting an | 80 // or NotifyPermissionSet if permission decided by presenting an |
| 72 // infobar to the user. Called on the UI thread. | 81 // infobar to the user. Called on the UI thread. |
| 73 virtual void DecidePermission(content::WebContents* web_contents, | 82 virtual void DecidePermission(content::WebContents* web_contents, |
| 74 const PermissionRequestID& id, | 83 const PermissionRequestID& id, |
| 75 const GURL& requesting_frame, | 84 const GURL& requesting_frame, |
| 76 bool user_gesture, | 85 bool user_gesture, |
| 77 const GURL& embedder, | 86 const GURL& embedder, |
| 78 base::Callback<void(bool)> callback); | 87 base::Callback<void(int, bool)> callback); |
| 79 | 88 |
| 80 // Called when permission is granted without interactively asking | 89 // Called when permission is granted without interactively asking |
| 81 // the user. Can be overridden to introduce additional UI flow. | 90 // the user. Can be overridden to introduce additional UI flow. |
| 82 // Should ultimately ensure that NotifyPermissionSet is called. | 91 // Should ultimately ensure that NotifyPermissionSet is called. |
| 83 // Called on the UI thread. | 92 // Called on the UI thread. |
| 84 virtual void PermissionDecided(const PermissionRequestID& id, | 93 virtual void PermissionDecided(const PermissionRequestID& id, |
| 85 const GURL& requesting_frame, | 94 const GURL& requesting_frame, |
| 86 const GURL& embedder, | 95 const GURL& embedder, |
| 87 base::Callback<void(bool)> callback, | 96 base::Callback<void(int, bool)> callback, |
| 88 bool allowed); | 97 bool allowed); |
| 89 | 98 |
| 90 // Create an PermissionQueueController. overriden in derived classes to | 99 // Create an PermissionQueueController. overriden in derived classes to |
| 91 // provide additional UI flow. Called on the UI thread. | 100 // provide additional UI flow. Called on the UI thread. |
| 92 virtual PermissionQueueController* CreateQueueController(); | 101 virtual PermissionQueueController* CreateQueueController(); |
| 93 | 102 |
| 94 private: | 103 private: |
| 95 friend class base::RefCountedThreadSafe<GeolocationPermissionContext>; | 104 friend class base::RefCountedThreadSafe<GeolocationPermissionContext>; |
| 96 friend class GeolocationPermissionRequest; | 105 friend class GeolocationPermissionRequest; |
| 97 | 106 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 113 scoped_ptr<PermissionQueueController> permission_queue_controller_; | 122 scoped_ptr<PermissionQueueController> permission_queue_controller_; |
| 114 GeolocationPermissionContextExtensions extensions_context_; | 123 GeolocationPermissionContextExtensions extensions_context_; |
| 115 | 124 |
| 116 base::ScopedPtrHashMap<std::string, GeolocationPermissionRequest> | 125 base::ScopedPtrHashMap<std::string, GeolocationPermissionRequest> |
| 117 pending_requests_; | 126 pending_requests_; |
| 118 | 127 |
| 119 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContext); | 128 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContext); |
| 120 }; | 129 }; |
| 121 | 130 |
| 122 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_H_ | 131 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_H_ |
| OLD | NEW |