Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/containers/scoped_ptr_hash_map.h" | 9 #include "base/containers/scoped_ptr_hash_map.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 | 56 |
| 57 // The renderer is requesting permission to push messages. | 57 // The renderer is requesting permission to push messages. |
| 58 // When the answer to a permission request has been determined, |callback| | 58 // When the answer to a permission request has been determined, |callback| |
| 59 // should be called with the result. | 59 // should be called with the result. |
| 60 virtual void RequestPermission(content::WebContents* web_contents, | 60 virtual void RequestPermission(content::WebContents* web_contents, |
| 61 const PermissionRequestID& id, | 61 const PermissionRequestID& id, |
| 62 const GURL& requesting_frame, | 62 const GURL& requesting_frame, |
| 63 bool user_gesture, | 63 bool user_gesture, |
| 64 const BrowserPermissionCallback& callback); | 64 const BrowserPermissionCallback& callback); |
| 65 | 65 |
| 66 // Withdraw an existing permission request, no op if the permission request | |
| 67 // was already cancelled by some other means. | |
| 68 virtual void CancelPermissionRequest(content::WebContents* web_contents, | |
| 69 const PermissionRequestID& id); | |
| 70 | |
| 66 protected: | 71 protected: |
| 67 // Decide whether the permission should be granted. | 72 // Decide whether the permission should be granted. |
| 68 // Calls PermissionDecided if permission can be decided non-interactively, | 73 // Calls PermissionDecided if permission can be decided non-interactively, |
| 69 // or NotifyPermissionSet if permission decided by presenting an infobar. | 74 // or NotifyPermissionSet if permission decided by presenting an infobar. |
| 70 void DecidePermission(content::WebContents* web_contents, | 75 void DecidePermission(content::WebContents* web_contents, |
| 71 const PermissionRequestID& id, | 76 const PermissionRequestID& id, |
| 72 const GURL& requesting_origin, | 77 const GURL& requesting_origin, |
| 73 const GURL& embedder_origin, | 78 const GURL& embedder_origin, |
| 74 bool user_gesture, | 79 bool user_gesture, |
| 75 const BrowserPermissionCallback& callback); | 80 const BrowserPermissionCallback& callback); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 91 | 96 |
| 92 // Implementors can override this method to update the icons on the | 97 // Implementors can override this method to update the icons on the |
| 93 // url bar with the result of the new permission. | 98 // url bar with the result of the new permission. |
| 94 virtual void UpdateTabContext(const PermissionRequestID& id, | 99 virtual void UpdateTabContext(const PermissionRequestID& id, |
| 95 const GURL& requesting_origin, | 100 const GURL& requesting_origin, |
| 96 bool allowed) {} | 101 bool allowed) {} |
| 97 | 102 |
| 98 // Return an instance of the infobar queue controller, creating it if needed. | 103 // Return an instance of the infobar queue controller, creating it if needed. |
| 99 PermissionQueueController* GetQueueController(); | 104 PermissionQueueController* GetQueueController(); |
| 100 | 105 |
| 106 // KeyedService: | |
| 107 // Called when the associated profile is destroyed. | |
| 108 virtual void Shutdown() OVERRIDE; | |
| 109 | |
| 101 private: | 110 private: |
| 102 void UpdateContentSetting( | 111 void UpdateContentSetting( |
| 103 const GURL& requesting_origin, | 112 const GURL& requesting_origin, |
| 104 const GURL& embedder_origin, | 113 const GURL& embedder_origin, |
| 105 bool allowed); | 114 bool allowed); |
| 106 | 115 |
| 107 // Called when a bubble is no longer used so it can be cleaned up. | 116 // Called when a bubble is no longer used so it can be cleaned up. |
| 108 void CleanUpBubble(const PermissionRequestID& id); | 117 void CleanUpBubble(const PermissionRequestID& id); |
| 109 | 118 |
| 110 Profile* profile_; | 119 Profile* profile_; |
| 111 const ContentSettingsType permission_type_; | 120 const ContentSettingsType permission_type_; |
| 112 base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 121 base::WeakPtrFactory<PermissionContextBase> weak_factory_; |
|
Bernhard Bauer
2014/08/13 13:34:32
The WeakPtrFactory should be the last member, to e
Miguel Garcia
2014/08/13 14:25:50
Done.
| |
| 113 scoped_ptr<PermissionQueueController> permission_queue_controller_; | 122 scoped_ptr<PermissionQueueController> permission_queue_controller_; |
| 114 base::ScopedPtrHashMap<std::string, PermissionBubbleRequest> | 123 base::ScopedPtrHashMap<std::string, PermissionBubbleRequest> |
| 115 pending_bubbles_; | 124 pending_bubbles_; |
| 125 bool shutting_down_; | |
| 116 }; | 126 }; |
| 117 | 127 |
| 118 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 128 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
| OLD | NEW |