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

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

Issue 1342833002: permissions: handle request ids for permissions in permission manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile properly Created 5 years, 2 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/id_map.h" 9 #include "base/id_map.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
11 #include "components/content_settings/core/browser/content_settings_observer.h" 12 #include "components/content_settings/core/browser/content_settings_observer.h"
13 #include "components/content_settings/core/common/content_settings.h"
12 #include "components/keyed_service/core/keyed_service.h" 14 #include "components/keyed_service/core/keyed_service.h"
13 #include "content/public/browser/permission_manager.h" 15 #include "content/public/browser/permission_manager.h"
14 16
15 17
16 class Profile; 18 class Profile;
17 19
18 namespace content { 20 namespace content {
19 enum class PermissionType; 21 enum class PermissionType;
20 class WebContents; 22 class WebContents;
21 }; // namespace content 23 }; // namespace content
22 24
23 class PermissionManager : public KeyedService, 25 class PermissionManager : public KeyedService,
24 public content::PermissionManager, 26 public content::PermissionManager,
25 public content_settings::Observer { 27 public content_settings::Observer {
26 public: 28 public:
27 explicit PermissionManager(Profile* profile); 29 explicit PermissionManager(Profile* profile);
28 ~PermissionManager() override; 30 ~PermissionManager() override;
29 31
30 // content::PermissionManager implementation. 32 // content::PermissionManager implementation.
31 void RequestPermission( 33 int RequestPermission(
32 content::PermissionType permission, 34 content::PermissionType permission,
33 content::RenderFrameHost* render_frame_host, 35 content::RenderFrameHost* render_frame_host,
34 int request_id,
35 const GURL& requesting_origin, 36 const GURL& requesting_origin,
36 bool user_gesture, 37 bool user_gesture,
37 const base::Callback<void(content::PermissionStatus)>& callback) override; 38 const base::Callback<void(content::PermissionStatus)>& callback) override;
38 void CancelPermissionRequest(content::PermissionType permission, 39 void CancelPermissionRequest(content::PermissionType permission,
39 content::RenderFrameHost* render_frame_host, 40 content::RenderFrameHost* render_frame_host,
40 int request_id, 41 int request_id,
41 const GURL& requesting_origin) override; 42 const GURL& requesting_origin) override;
42 void ResetPermission(content::PermissionType permission, 43 void ResetPermission(content::PermissionType permission,
43 const GURL& requesting_origin, 44 const GURL& requesting_origin,
44 const GURL& embedding_origin) override; 45 const GURL& embedding_origin) override;
45 content::PermissionStatus GetPermissionStatus( 46 content::PermissionStatus GetPermissionStatus(
46 content::PermissionType permission, 47 content::PermissionType permission,
47 const GURL& requesting_origin, 48 const GURL& requesting_origin,
48 const GURL& embedding_origin) override; 49 const GURL& embedding_origin) override;
49 void RegisterPermissionUsage(content::PermissionType permission, 50 void RegisterPermissionUsage(content::PermissionType permission,
50 const GURL& requesting_origin, 51 const GURL& requesting_origin,
51 const GURL& embedding_origin) override; 52 const GURL& embedding_origin) override;
52 int SubscribePermissionStatusChange( 53 int SubscribePermissionStatusChange(
53 content::PermissionType permission, 54 content::PermissionType permission,
54 const GURL& requesting_origin, 55 const GURL& requesting_origin,
55 const GURL& embedding_origin, 56 const GURL& embedding_origin,
56 const base::Callback<void(content::PermissionStatus)>& callback) override; 57 const base::Callback<void(content::PermissionStatus)>& callback) override;
57 void UnsubscribePermissionStatusChange(int subscription_id) override; 58 void UnsubscribePermissionStatusChange(int subscription_id) override;
58 59
59 private: 60 private:
61 struct PendingRequest;
62 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
63
60 struct Subscription; 64 struct Subscription;
61 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; 65 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>;
62 66
67 void OnPermissionRequestResponse(
68 int request_id,
69 const base::Callback<void(content::PermissionStatus)>& callback,
70 ContentSetting content_setting);
71
63 // Not all WebContents are able to display permission requests. If the PBM 72 // Not all WebContents are able to display permission requests. If the PBM
64 // is required but missing for |web_contents|, don't pass along the request. 73 // is required but missing for |web_contents|, don't pass along the request.
65 bool IsPermissionBubbleManagerMissing(content::WebContents* web_contents); 74 bool IsPermissionBubbleManagerMissing(content::WebContents* web_contents);
66 75
67 // content_settings::Observer implementation. 76 // content_settings::Observer implementation.
68 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 77 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
69 const ContentSettingsPattern& secondary_pattern, 78 const ContentSettingsPattern& secondary_pattern,
70 ContentSettingsType content_type, 79 ContentSettingsType content_type,
71 std::string resource_identifier) override; 80 std::string resource_identifier) override;
72 81
73 Profile* profile_; 82 Profile* profile_;
83 PendingRequestsMap pending_requests_;
74 SubscriptionsMap subscriptions_; 84 SubscriptionsMap subscriptions_;
75 85
86 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_;
87
76 DISALLOW_COPY_AND_ASSIGN(PermissionManager); 88 DISALLOW_COPY_AND_ASSIGN(PermissionManager);
77 }; 89 };
78 90
79 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ 91 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698