| 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 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/containers/scoped_ptr_hash_map.h" | 11 #include "base/containers/scoped_ptr_hash_map.h" |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 14 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 15 #include "chrome/browser/permissions/permission_request.h" | 14 #include "chrome/browser/permissions/permission_request.h" |
| 16 #include "components/content_settings/core/common/content_settings.h" | 15 #include "components/content_settings/core/common/content_settings.h" |
| 17 #include "components/content_settings/core/common/content_settings_types.h" | 16 #include "components/content_settings/core/common/content_settings_types.h" |
| 18 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 19 #include "content/public/browser/permission_type.h" | 18 #include "content/public/browser/permission_type.h" |
| 20 #include "url/gurl.h" | |
| 21 | 19 |
| 22 #if defined(OS_ANDROID) | 20 #if defined(OS_ANDROID) |
| 23 class PermissionQueueController; | 21 class PermissionQueueController; |
| 24 #endif | 22 #endif |
| 23 class GURL; |
| 24 class PermissionDecisionAutoBlocker; |
| 25 class PermissionRequestID; | 25 class PermissionRequestID; |
| 26 class Profile; | 26 class Profile; |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 class WebContents; | 29 class WebContents; |
| 30 } | 30 } |
| 31 | 31 |
| 32 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; | 32 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; |
| 33 | 33 |
| 34 // This base class contains common operations for granting permissions. | 34 // This base class contains common operations for granting permissions. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 // Whether the permission should be restricted to secure origins. | 151 // Whether the permission should be restricted to secure origins. |
| 152 virtual bool IsRestrictedToSecureOrigins() const = 0; | 152 virtual bool IsRestrictedToSecureOrigins() const = 0; |
| 153 | 153 |
| 154 content::PermissionType permission_type() const { return permission_type_; } | 154 content::PermissionType permission_type() const { return permission_type_; } |
| 155 ContentSettingsType content_settings_type() const { | 155 ContentSettingsType content_settings_type() const { |
| 156 return content_settings_type_; | 156 return content_settings_type_; |
| 157 } | 157 } |
| 158 | 158 |
| 159 private: | 159 private: |
| 160 friend class PermissionContextBaseTests; |
| 161 |
| 160 // Called when a request is no longer used so it can be cleaned up. | 162 // Called when a request is no longer used so it can be cleaned up. |
| 161 void CleanUpRequest(const PermissionRequestID& id); | 163 void CleanUpRequest(const PermissionRequestID& id); |
| 162 | 164 |
| 163 Profile* profile_; | 165 Profile* profile_; |
| 166 std::unique_ptr<PermissionDecisionAutoBlocker> decision_auto_blocker_; |
| 164 const content::PermissionType permission_type_; | 167 const content::PermissionType permission_type_; |
| 165 const ContentSettingsType content_settings_type_; | 168 const ContentSettingsType content_settings_type_; |
| 166 #if defined(OS_ANDROID) | 169 #if defined(OS_ANDROID) |
| 167 std::unique_ptr<PermissionQueueController> permission_queue_controller_; | 170 std::unique_ptr<PermissionQueueController> permission_queue_controller_; |
| 168 #endif | 171 #endif |
| 169 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionRequest>> | 172 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionRequest>> |
| 170 pending_requests_; | 173 pending_requests_; |
| 171 | 174 |
| 172 // Must be the last member, to ensure that it will be | 175 // Must be the last member, to ensure that it will be |
| 173 // destroyed first, which will invalidate weak pointers | 176 // destroyed first, which will invalidate weak pointers |
| 174 base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 177 base::WeakPtrFactory<PermissionContextBase> weak_factory_; |
| 175 }; | 178 }; |
| 176 | 179 |
| 177 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ | 180 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ |
| OLD | NEW |