| 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  | 
|   11 #include "base/callback_forward.h" |   11 #include "base/callback_forward.h" | 
|   12 #include "base/memory/weak_ptr.h" |   12 #include "base/memory/weak_ptr.h" | 
|   13 #include "build/build_config.h" |   13 #include "build/build_config.h" | 
|   14 #include "chrome/browser/permissions/permission_request.h" |   14 #include "chrome/browser/permissions/permission_request.h" | 
 |   15 #include "chrome/browser/permissions/permission_util.h" | 
|   15 #include "components/content_settings/core/common/content_settings.h" |   16 #include "components/content_settings/core/common/content_settings.h" | 
|   16 #include "components/content_settings/core/common/content_settings_types.h" |   17 #include "components/content_settings/core/common/content_settings_types.h" | 
|   17 #include "components/keyed_service/core/keyed_service.h" |   18 #include "components/keyed_service/core/keyed_service.h" | 
|   18  |   19  | 
|   19 #if defined(OS_ANDROID) |   20 #if defined(OS_ANDROID) | 
|   20 class PermissionQueueController; |   21 class PermissionQueueController; | 
|   21 #endif |   22 #endif | 
|   22 class GURL; |   23 class GURL; | 
|   23 class PermissionRequestID; |   24 class PermissionRequestID; | 
|   24 class Profile; |   25 class Profile; | 
|   25  |   26  | 
|   26 namespace content { |   27 namespace content { | 
|   27 class WebContents; |   28 class WebContents; | 
|   28 } |   29 } | 
|   29  |   30  | 
|   30 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; |   31 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; | 
|   31  |   32  | 
|   32 // Identifies the source or reason for a permission status being returned. |  | 
|   33 // TODO(raymes): Add more reasons here and return them correctly. |  | 
|   34 enum class PermissionStatusSource { |  | 
|   35   // The status is the result of being blocked due to the user dismissing a |  | 
|   36   // permission prompt multiple times. |  | 
|   37   MULTIPLE_DISMISSALS, |  | 
|   38  |  | 
|   39   // The status is the resultof being blocked because the permission is on the |  | 
|   40   // safe browsing blacklist. |  | 
|   41   SAFE_BROWSING_BLACKLIST, |  | 
|   42  |  | 
|   43   // The reason for the status is not specified. Avoid returning this value. It |  | 
|   44   // only exists until code has been added to correctly return a source in all |  | 
|   45   // cases. |  | 
|   46   UNSPECIFIED |  | 
|   47 }; |  | 
|   48  |  | 
|   49 struct PermissionResult { |  | 
|   50   PermissionResult(ContentSetting content_setting, |  | 
|   51                    PermissionStatusSource source); |  | 
|   52   ~PermissionResult(); |  | 
|   53  |  | 
|   54   ContentSetting content_setting; |  | 
|   55   PermissionStatusSource source; |  | 
|   56 }; |  | 
|   57  |  | 
|   58 // This base class contains common operations for granting permissions. |   33 // This base class contains common operations for granting permissions. | 
|   59 // It offers the following functionality: |   34 // It offers the following functionality: | 
|   60 //   - Creates a permission request when needed. |   35 //   - Creates a permission request when needed. | 
|   61 //   - If accepted/denied the permission is saved in content settings for |   36 //   - If accepted/denied the permission is saved in content settings for | 
|   62 //     future uses (for the domain that requested it). |   37 //     future uses (for the domain that requested it). | 
|   63 //   - 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 | 
|   64 //     this one request |   39 //     this one request | 
|   65 //   - In any case the BrowserPermissionCallback is executed once a decision |   40 //   - In any case the BrowserPermissionCallback is executed once a decision | 
|   66 //     about the permission is made by the user. |   41 //     about the permission is made by the user. | 
|   67 // The bare minimum you need to create a new permission request is |   42 // The bare minimum you need to create a new permission request is | 
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  212 #endif |  187 #endif | 
|  213   std::unordered_map<std::string, std::unique_ptr<PermissionRequest>> |  188   std::unordered_map<std::string, std::unique_ptr<PermissionRequest>> | 
|  214       pending_requests_; |  189       pending_requests_; | 
|  215  |  190  | 
|  216   // Must be the last member, to ensure that it will be |  191   // Must be the last member, to ensure that it will be | 
|  217   // destroyed first, which will invalidate weak pointers |  192   // destroyed first, which will invalidate weak pointers | 
|  218   base::WeakPtrFactory<PermissionContextBase> weak_factory_; |  193   base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 
|  219 }; |  194 }; | 
|  220  |  195  | 
|  221 #endif  // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ |  196 #endif  // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ | 
| OLD | NEW |