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" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | 12 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
13 #include "chrome/common/content_settings_types.h" | 13 #include "chrome/common/content_settings_types.h" |
14 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 class PermissionQueueController; | 17 class PermissionQueueController; |
18 class PermissionRequestID; | 18 class PermissionRequestID; |
19 class Profile; | 19 class Profile; |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 class WebContents; | 22 class WebContents; |
23 } | 23 } |
24 | 24 |
25 // Enum for UMA purposes, make sure you update histograms.xml if you | |
26 // add new pemissions. | |
Mark P
2014/07/08 20:49:03
Please explicitly use = 0, = 1, and so on. Also s
| |
27 enum PermissionType { | |
28 PERMISSION_UNKNOWN, | |
29 PERMISSION_MIDI_SYSEX, | |
30 PERMISSION_PUSH_MESSAGING, | |
31 | |
32 // Always keep this at the end. | |
33 PERMISSION_NUM, | |
Mark P
2014/07/08 20:49:03
optional nit: consider PERMISSION_MAX
Miguel Garcia
2014/07/09 11:17:19
Done.
| |
34 }; | |
35 | |
25 typedef base::Callback<void(bool)> BrowserPermissionCallback; | 36 typedef base::Callback<void(bool)> BrowserPermissionCallback; |
26 | 37 |
27 // This base class contains common operations for granting permissions. | 38 // This base class contains common operations for granting permissions. |
28 // It offers the following functionality: | 39 // It offers the following functionality: |
29 // - Creates a bubble or infobar when a permission is needed | 40 // - Creates a bubble or infobar when a permission is needed |
30 // - If accepted/denied the permission is saved in content settings for | 41 // - If accepted/denied the permission is saved in content settings for |
31 // future uses (for the domain that requested it). | 42 // future uses (for the domain that requested it). |
32 // - If dismissed the permission is not saved but it's considered denied for | 43 // - If dismissed the permission is not saved but it's considered denied for |
33 // this one request | 44 // this one request |
34 // - In any case the BrowserPermissionCallback is executed once a decision | 45 // - In any case the BrowserPermissionCallback is executed once a decision |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 const GURL& requesting_origin, | 83 const GURL& requesting_origin, |
73 const GURL& embedder_origin, | 84 const GURL& embedder_origin, |
74 bool user_gesture, | 85 bool user_gesture, |
75 const BrowserPermissionCallback& callback); | 86 const BrowserPermissionCallback& callback); |
76 | 87 |
77 // Called when permission is granted without interactively asking the user. | 88 // Called when permission is granted without interactively asking the user. |
78 void PermissionDecided(const PermissionRequestID& id, | 89 void PermissionDecided(const PermissionRequestID& id, |
79 const GURL& requesting_origin, | 90 const GURL& requesting_origin, |
80 const GURL& embedder_origin, | 91 const GURL& embedder_origin, |
81 const BrowserPermissionCallback& callback, | 92 const BrowserPermissionCallback& callback, |
93 bool persist, | |
82 bool allowed); | 94 bool allowed); |
83 | 95 |
84 void NotifyPermissionSet(const PermissionRequestID& id, | 96 void NotifyPermissionSet(const PermissionRequestID& id, |
85 const GURL& requesting_origin, | 97 const GURL& requesting_origin, |
86 const GURL& embedder_origin, | 98 const GURL& embedder_origin, |
87 const BrowserPermissionCallback& callback, | 99 const BrowserPermissionCallback& callback, |
88 bool persist, | 100 bool persist, |
89 bool allowed); | 101 bool allowed); |
90 | 102 |
91 // Implementors can override this method to update the icons on the | 103 // Implementors can override this method to update the icons on the |
(...skipping 16 matching lines...) Expand all Loading... | |
108 | 120 |
109 Profile* profile_; | 121 Profile* profile_; |
110 const ContentSettingsType permission_type_; | 122 const ContentSettingsType permission_type_; |
111 base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 123 base::WeakPtrFactory<PermissionContextBase> weak_factory_; |
112 scoped_ptr<PermissionQueueController> permission_queue_controller_; | 124 scoped_ptr<PermissionQueueController> permission_queue_controller_; |
113 base::ScopedPtrHashMap<std::string, PermissionBubbleRequest> | 125 base::ScopedPtrHashMap<std::string, PermissionBubbleRequest> |
114 pending_bubbles_; | 126 pending_bubbles_; |
115 }; | 127 }; |
116 | 128 |
117 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 129 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
OLD | NEW |