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

Side by Side Diff: android_webview/browser/aw_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: Focus on just request in this CL 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 ANDROID_WEBVIEW_BROWSER_AW_PERMISSION_MANAGER_H_ 5 #ifndef ANDROID_WEBVIEW_BROWSER_AW_PERMISSION_MANAGER_H_
6 #define ANDROID_WEBVIEW_BROWSER_AW_PERMISSION_MANAGER_H_ 6 #define ANDROID_WEBVIEW_BROWSER_AW_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/macros.h" 10 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
11 #include "content/public/browser/permission_manager.h" 13 #include "content/public/browser/permission_manager.h"
12 14
13 namespace android_webview { 15 namespace android_webview {
14 16
15 class LastRequestResultCache; 17 class LastRequestResultCache;
16 18
17 class AwPermissionManager : public content::PermissionManager { 19 class AwPermissionManager : public content::PermissionManager {
18 public: 20 public:
19 AwPermissionManager(); 21 AwPermissionManager();
20 ~AwPermissionManager() override; 22 ~AwPermissionManager() override;
21 23
22 // PermissionManager implementation. 24 // PermissionManager implementation.
23 void RequestPermission( 25 int RequestPermission(
24 content::PermissionType permission, 26 content::PermissionType permission,
25 content::RenderFrameHost* render_frame_host, 27 content::RenderFrameHost* render_frame_host,
26 int request_id,
27 const GURL& requesting_origin, 28 const GURL& requesting_origin,
28 bool user_gesture, 29 bool user_gesture,
29 const base::Callback<void(content::PermissionStatus)>& callback) override; 30 const base::Callback<void(content::PermissionStatus)>& callback) override;
30 void CancelPermissionRequest(content::PermissionType permission, 31 void CancelPermissionRequest(content::PermissionType permission,
31 content::RenderFrameHost* render_frame_host, 32 content::RenderFrameHost* render_frame_host,
32 int request_id, 33 int request_id,
33 const GURL& requesting_origin) override; 34 const GURL& requesting_origin) override;
34 void ResetPermission(content::PermissionType permission, 35 void ResetPermission(content::PermissionType permission,
35 const GURL& requesting_origin, 36 const GURL& requesting_origin,
36 const GURL& embedding_origin) override; 37 const GURL& embedding_origin) override;
37 content::PermissionStatus GetPermissionStatus( 38 content::PermissionStatus GetPermissionStatus(
38 content::PermissionType permission, 39 content::PermissionType permission,
39 const GURL& requesting_origin, 40 const GURL& requesting_origin,
40 const GURL& embedding_origin) override; 41 const GURL& embedding_origin) override;
41 void RegisterPermissionUsage(content::PermissionType permission, 42 void RegisterPermissionUsage(content::PermissionType permission,
42 const GURL& requesting_origin, 43 const GURL& requesting_origin,
43 const GURL& embedding_origin) override; 44 const GURL& embedding_origin) override;
44 int SubscribePermissionStatusChange( 45 int SubscribePermissionStatusChange(
45 content::PermissionType permission, 46 content::PermissionType permission,
46 const GURL& requesting_origin, 47 const GURL& requesting_origin,
47 const GURL& embedding_origin, 48 const GURL& embedding_origin,
48 const base::Callback<void(content::PermissionStatus)>& callback) override; 49 const base::Callback<void(content::PermissionStatus)>& callback) override;
49 void UnsubscribePermissionStatusChange(int subscription_id) override; 50 void UnsubscribePermissionStatusChange(int subscription_id) override;
50 51
51 private: 52 private:
53 class PendingRequest;
54 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
55
56 // The weak pointer to this is used to clean up any information which is
57 // stored in the pending request or result cache maps. However, the callback
58 // should be run regardless of whether the class is still alive so the method
59 // is static.
60 static void OnRequestResponse(
mlamouri (slow - plz ping) 2015/09/28 14:15:04 Move that to the .cc file?
Lalit Maganti 2015/09/28 16:07:01 Done. Apologies for missing your earlier comment
Lalit Maganti 2015/09/29 09:08:00 I've had to switch this back because I utilize som
61 const base::WeakPtr<AwPermissionManager>& manager,
62 int request_id,
63 const base::Callback<void(content::PermissionStatus)>& callback,
64 bool allowed);
65
66 PendingRequestsMap pending_requests_;
52 scoped_ptr<LastRequestResultCache> result_cache_; 67 scoped_ptr<LastRequestResultCache> result_cache_;
53 68
69 base::WeakPtrFactory<AwPermissionManager> weak_ptr_factory_;
70
54 DISALLOW_COPY_AND_ASSIGN(AwPermissionManager); 71 DISALLOW_COPY_AND_ASSIGN(AwPermissionManager);
55 }; 72 };
56 73
57 } // namespace android_webview 74 } // namespace android_webview
58 75
59 #endif // ANDROID_WEBVIEW_BROWSER_AW_PERMISSION_MANAGER_H_ 76 #endif // ANDROID_WEBVIEW_BROWSER_AW_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698