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