| 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_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ |
| 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class PermissionQueueController; | 21 class PermissionQueueController; |
| 22 #endif | 22 #endif |
| 23 class GURL; | 23 class GURL; |
| 24 class PermissionRequestID; | 24 class PermissionRequestID; |
| 25 class Profile; | 25 class Profile; |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 class WebContents; | 28 class WebContents; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace safe_browsing { | |
| 32 class SafeBrowsingDatabaseManager; | |
| 33 } | |
| 34 | |
| 35 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; | 31 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; |
| 36 | 32 |
| 37 // This base class contains common operations for granting permissions. | 33 // This base class contains common operations for granting permissions. |
| 38 // It offers the following functionality: | 34 // It offers the following functionality: |
| 39 // - Creates a permission request when needed. | 35 // - Creates a permission request when needed. |
| 40 // - If accepted/denied the permission is saved in content settings for | 36 // - If accepted/denied the permission is saved in content settings for |
| 41 // future uses (for the domain that requested it). | 37 // future uses (for the domain that requested it). |
| 42 // - If dismissed the permission is not saved but it's considered denied for | 38 // - If dismissed the permission is not saved but it's considered denied for |
| 43 // this one request | 39 // this one request |
| 44 // - In any case the BrowserPermissionCallback is executed once a decision | 40 // - In any case the BrowserPermissionCallback is executed once a decision |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Browsing. |permission_blocked| determines whether to auto-block the | 170 // Browsing. |permission_blocked| determines whether to auto-block the |
| 175 // permission request without prompting the user for a decision. | 171 // permission request without prompting the user for a decision. |
| 176 void ContinueRequestPermission(content::WebContents* web_contents, | 172 void ContinueRequestPermission(content::WebContents* web_contents, |
| 177 const PermissionRequestID& id, | 173 const PermissionRequestID& id, |
| 178 const GURL& requesting_origin, | 174 const GURL& requesting_origin, |
| 179 const GURL& embedding_origin, | 175 const GURL& embedding_origin, |
| 180 bool user_gesture, | 176 bool user_gesture, |
| 181 const BrowserPermissionCallback& callback, | 177 const BrowserPermissionCallback& callback, |
| 182 bool permission_blocked); | 178 bool permission_blocked); |
| 183 | 179 |
| 184 void SetSafeBrowsingDatabaseManagerAndTimeoutForTest( | |
| 185 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, | |
| 186 int timeout); | |
| 187 | |
| 188 Profile* profile_; | 180 Profile* profile_; |
| 189 const content::PermissionType permission_type_; | 181 const content::PermissionType permission_type_; |
| 190 const ContentSettingsType content_settings_type_; | 182 const ContentSettingsType content_settings_type_; |
| 191 int safe_browsing_timeout_; | |
| 192 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager_; | |
| 193 #if defined(OS_ANDROID) | 183 #if defined(OS_ANDROID) |
| 194 std::unique_ptr<PermissionQueueController> permission_queue_controller_; | 184 std::unique_ptr<PermissionQueueController> permission_queue_controller_; |
| 195 #endif | 185 #endif |
| 196 std::unordered_map<std::string, std::unique_ptr<PermissionRequest>> | 186 std::unordered_map<std::string, std::unique_ptr<PermissionRequest>> |
| 197 pending_requests_; | 187 pending_requests_; |
| 198 | 188 |
| 199 // Must be the last member, to ensure that it will be | 189 // Must be the last member, to ensure that it will be |
| 200 // destroyed first, which will invalidate weak pointers | 190 // destroyed first, which will invalidate weak pointers |
| 201 base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 191 base::WeakPtrFactory<PermissionContextBase> weak_factory_; |
| 202 }; | 192 }; |
| 203 | 193 |
| 204 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ | 194 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ |
| OLD | NEW |