Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: chrome/browser/permissions/permission_context_base.h

Issue 2123653006: Rename PermissionBubbleRequest to PermissionRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission_manager_rename
Patch Set: Fix missed file Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.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" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" 15 #include "chrome/browser/permissions/permission_request.h"
16 #include "components/content_settings/core/common/content_settings.h" 16 #include "components/content_settings/core/common/content_settings.h"
17 #include "components/content_settings/core/common/content_settings_types.h" 17 #include "components/content_settings/core/common/content_settings_types.h"
18 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
19 #include "content/public/browser/permission_type.h" 19 #include "content/public/browser/permission_type.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 #if defined(OS_ANDROID) 22 #if defined(OS_ANDROID)
23 class PermissionQueueController; 23 class PermissionQueueController;
24 #endif 24 #endif
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.
35 // It offers the following functionality: 35 // It offers the following functionality:
36 // - Creates a bubble or infobar when a permission is needed 36 // - Creates a permission request when needed.
37 // - If accepted/denied the permission is saved in content settings for 37 // - If accepted/denied the permission is saved in content settings for
38 // future uses (for the domain that requested it). 38 // future uses (for the domain that requested it).
39 // - If dismissed the permission is not saved but it's considered denied for 39 // - If dismissed the permission is not saved but it's considered denied for
40 // this one request 40 // this one request
41 // - In any case the BrowserPermissionCallback is executed once a decision 41 // - In any case the BrowserPermissionCallback is executed once a decision
42 // about the permission is made by the user. 42 // about the permission is made by the user.
43 // The bare minimum you need to create a new permission request is 43 // The bare minimum you need to create a new permission request is
44 // - Define your new permission in the ContentSettingsType enum. 44 // - Define your new permission in the ContentSettingsType enum.
45 // - Create a class that inherits from PermissionContextBase and passes the 45 // - Create a class that inherits from PermissionContextBase and passes the
46 // new permission. 46 // new permission.
47 // - Inherit from PermissionInfobarDelegate and implement 47 // - Inherit from PermissionInfobarDelegate and implement
48 // |GetMessageText| 48 // |GetMessageText|
49 // - Edit the PermissionBubbleRequestImpl methods to add the new text for 49 // - Edit the PermissionRequestImpl methods to add the new text.
50 // the bubble.
51 // - Hit several asserts for the missing plumbing and fix them :) 50 // - Hit several asserts for the missing plumbing and fix them :)
52 // After this you can override several other methods to customize behavior, 51 // After this you can override several other methods to customize behavior,
53 // in particular it is advised to override UpdateTabContext in order to manage 52 // in particular it is advised to override UpdateTabContext in order to manage
54 // the permission from the omnibox. 53 // the permission from the omnibox.
55 // It is mandatory to override IsRestrictedToSecureOrigin. 54 // It is mandatory to override IsRestrictedToSecureOrigin.
56 // See midi_permission_context.h/cc or push_permission_context.cc/h for some 55 // See midi_permission_context.h/cc or push_permission_context.cc/h for some
57 // examples. 56 // examples.
58 57
59 class PermissionContextBase : public KeyedService { 58 class PermissionContextBase : public KeyedService {
60 public: 59 public:
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 149
151 // Whether the permission should be restricted to secure origins. 150 // Whether the permission should be restricted to secure origins.
152 virtual bool IsRestrictedToSecureOrigins() const = 0; 151 virtual bool IsRestrictedToSecureOrigins() const = 0;
153 152
154 content::PermissionType permission_type() const { return permission_type_; } 153 content::PermissionType permission_type() const { return permission_type_; }
155 ContentSettingsType content_settings_type() const { 154 ContentSettingsType content_settings_type() const {
156 return content_settings_type_; 155 return content_settings_type_;
157 } 156 }
158 157
159 private: 158 private:
160 // Called when a bubble is no longer used so it can be cleaned up. 159 // Called when a request is no longer used so it can be cleaned up.
161 void CleanUpBubble(const PermissionRequestID& id); 160 void CleanUpRequest(const PermissionRequestID& id);
162 161
163 Profile* profile_; 162 Profile* profile_;
164 const content::PermissionType permission_type_; 163 const content::PermissionType permission_type_;
165 const ContentSettingsType content_settings_type_; 164 const ContentSettingsType content_settings_type_;
166 #if defined(OS_ANDROID) 165 #if defined(OS_ANDROID)
167 std::unique_ptr<PermissionQueueController> permission_queue_controller_; 166 std::unique_ptr<PermissionQueueController> permission_queue_controller_;
168 #endif 167 #endif
169 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionBubbleRequest>> 168 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionRequest>>
170 pending_bubbles_; 169 pending_requests_;
171 170
172 // Must be the last member, to ensure that it will be 171 // Must be the last member, to ensure that it will be
173 // destroyed first, which will invalidate weak pointers 172 // destroyed first, which will invalidate weak pointers
174 base::WeakPtrFactory<PermissionContextBase> weak_factory_; 173 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
175 }; 174 };
176 175
177 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 176 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_bubble_request_impl.cc ('k') | chrome/browser/permissions/permission_context_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698