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

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

Issue 1260193009: renderer: implement multiple permission requesting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permissions-request-multiple
Patch Set: Fix review comments Created 5 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/containers/scoped_ptr_hash_map.h"
9 #include "base/id_map.h" 10 #include "base/id_map.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
11 #include "components/content_settings/core/browser/content_settings_observer.h" 13 #include "components/content_settings/core/browser/content_settings_observer.h"
14 #include "components/content_settings/core/common/content_settings.h"
12 #include "components/keyed_service/core/keyed_service.h" 15 #include "components/keyed_service/core/keyed_service.h"
13 #include "content/public/browser/permission_manager.h" 16 #include "content/public/browser/permission_manager.h"
14 17
15 18
19 class PermissionRequestID;
16 class Profile; 20 class Profile;
17 21
18 namespace content { 22 namespace content {
19 enum class PermissionType; 23 enum class PermissionType;
20 }; // namespace content 24 }; // namespace content
21 25
22 class PermissionManager : public KeyedService, 26 class PermissionManager : public KeyedService,
23 public content::PermissionManager, 27 public content::PermissionManager,
24 public content_settings::Observer { 28 public content_settings::Observer {
25 public: 29 public:
26 explicit PermissionManager(Profile* profile); 30 explicit PermissionManager(Profile* profile);
27 ~PermissionManager() override; 31 ~PermissionManager() override;
28 32
29 // content::PermissionManager implementation. 33 // content::PermissionManager implementation.
30 void RequestPermission( 34 void RequestPermission(
31 content::PermissionType permission, 35 content::PermissionType permission,
32 content::RenderFrameHost* render_frame_host, 36 content::RenderFrameHost* render_frame_host,
33 int request_id, 37 int request_id,
34 const GURL& requesting_origin, 38 const GURL& requesting_origin,
35 bool user_gesture, 39 bool user_gesture,
36 const base::Callback<void(content::PermissionStatus)>& callback) override; 40 const RequestCallback& callback) override;
37 void CancelPermissionRequest(content::PermissionType permission, 41 void RequestPermission(
mlamouri (slow - plz ping) 2015/09/02 11:36:41 RequestPermissions ?
Lalit Maganti 2015/09/02 14:24:50 Done.
38 content::RenderFrameHost* render_frame_host, 42 const std::vector<content::PermissionType>& permissions,
39 int request_id, 43 content::RenderFrameHost* render_frame_host,
40 const GURL& requesting_origin) override; 44 int request_id,
45 const GURL& requesting_origin,
46 bool user_gesture,
47 const BatchRequestCallback& callback) override;
mlamouri (slow - plz ping) 2015/09/02 11:36:41 use the real callback type?
Lalit Maganti 2015/09/02 14:24:50 Makes the line too long and breaking it up looks u
48 void CancelPermissionRequest(content::RenderFrameHost* render_frame_host,
49 int request_id) override;
41 void ResetPermission(content::PermissionType permission, 50 void ResetPermission(content::PermissionType permission,
42 const GURL& requesting_origin, 51 const GURL& requesting_origin,
43 const GURL& embedding_origin) override; 52 const GURL& embedding_origin) override;
44 content::PermissionStatus GetPermissionStatus( 53 content::PermissionStatus GetPermissionStatus(
45 content::PermissionType permission, 54 content::PermissionType permission,
46 const GURL& requesting_origin, 55 const GURL& requesting_origin,
47 const GURL& embedding_origin) override; 56 const GURL& embedding_origin) override;
48 void RegisterPermissionUsage(content::PermissionType permission, 57 void RegisterPermissionUsage(content::PermissionType permission,
49 const GURL& requesting_origin, 58 const GURL& requesting_origin,
50 const GURL& embedding_origin) override; 59 const GURL& embedding_origin) override;
51 int SubscribePermissionStatusChange( 60 int SubscribePermissionStatusChange(
52 content::PermissionType permission, 61 content::PermissionType permission,
53 const GURL& requesting_origin, 62 const GURL& requesting_origin,
54 const GURL& embedding_origin, 63 const GURL& embedding_origin,
55 const base::Callback<void(content::PermissionStatus)>& callback) override; 64 const base::Callback<void(content::PermissionStatus)>& callback) override;
56 void UnsubscribePermissionStatusChange(int subscription_id) override; 65 void UnsubscribePermissionStatusChange(int subscription_id) override;
57 66
58 private: 67 private:
59 struct Subscription; 68 struct Subscription;
60 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; 69 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>;
61 70
71 struct PendingResponses;
72 struct PendingResponse;
73 using PendingResponseMap
74 = base::ScopedPtrHashMap<int, scoped_ptr<PendingResponses>>;
mlamouri (slow - plz ping) 2015/09/02 11:36:41 nit: = on previous line.
Lalit Maganti 2015/09/02 14:24:50 Done.
75
76 void RequestPermissionInternal(
77 const std::vector<content::PermissionType>& permissions,
78 content::RenderFrameHost* render_frame_host,
79 int request_id,
80 const GURL& requesting_origin,
81 bool user_gesture,
82 const BatchRequestCallback& callback);
83
84 void OnRequestResponse(
85 const BatchRequestCallback& callback,
86 const PermissionRequestID request,
87 PendingResponses* pending_responses,
88 int index,
89 ContentSetting content_setting);
90
62 // content_settings::Observer implementation. 91 // content_settings::Observer implementation.
63 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 92 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
64 const ContentSettingsPattern& secondary_pattern, 93 const ContentSettingsPattern& secondary_pattern,
65 ContentSettingsType content_type, 94 ContentSettingsType content_type,
66 std::string resource_identifier) override; 95 std::string resource_identifier) override;
67 96
68 Profile* profile_; 97 Profile* profile_;
69 SubscriptionsMap subscriptions_; 98 SubscriptionsMap subscriptions_;
99 PendingResponseMap pending_responses_;
100
101 // Need to keep this as the last member so it is destroyed before any other
102 // fields.
103 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_;
70 104
71 DISALLOW_COPY_AND_ASSIGN(PermissionManager); 105 DISALLOW_COPY_AND_ASSIGN(PermissionManager);
72 }; 106 };
73 107
74 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ 108 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698