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

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: Fix test failures 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 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(int request_id) override;
31 content::RenderFrameHost* render_frame_host,
32 int request_id,
33 const GURL& requesting_origin) override;
34 void ResetPermission(content::PermissionType permission, 32 void ResetPermission(content::PermissionType permission,
35 const GURL& requesting_origin, 33 const GURL& requesting_origin,
36 const GURL& embedding_origin) override; 34 const GURL& embedding_origin) override;
37 content::PermissionStatus GetPermissionStatus( 35 content::PermissionStatus GetPermissionStatus(
38 content::PermissionType permission, 36 content::PermissionType permission,
39 const GURL& requesting_origin, 37 const GURL& requesting_origin,
40 const GURL& embedding_origin) override; 38 const GURL& embedding_origin) override;
41 void RegisterPermissionUsage(content::PermissionType permission, 39 void RegisterPermissionUsage(content::PermissionType permission,
42 const GURL& requesting_origin, 40 const GURL& requesting_origin,
43 const GURL& embedding_origin) override; 41 const GURL& embedding_origin) override;
44 int SubscribePermissionStatusChange( 42 int SubscribePermissionStatusChange(
45 content::PermissionType permission, 43 content::PermissionType permission,
46 const GURL& requesting_origin, 44 const GURL& requesting_origin,
47 const GURL& embedding_origin, 45 const GURL& embedding_origin,
48 const base::Callback<void(content::PermissionStatus)>& callback) override; 46 const base::Callback<void(content::PermissionStatus)>& callback) override;
49 void UnsubscribePermissionStatusChange(int subscription_id) override; 47 void UnsubscribePermissionStatusChange(int subscription_id) override;
50 48
51 private: 49 private:
50 struct PendingRequest;
51 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
52
53 static void OnRequestResponse(
54 const base::WeakPtr<AwPermissionManager>& manager,
mlamouri (slow - plz ping) 2015/09/16 14:42:56 Don't make the method static, having a WeakPtr wil
Lalit Maganti 2015/09/16 16:41:10 As discussed offline.
55 int request_id,
56 const base::Callback<void(content::PermissionStatus)>& callback,
57 content::PermissionType permission,
58 const GURL& requesting_origin,
59 const GURL& embedding_origin,
60 bool allowed);
61 int AddPendingRequestToMap(
62 int render_process_id,
63 int render_frame_id,
64 content::PermissionType permission,
65 const GURL& requesting_origin);
66
67 PendingRequestsMap pending_requests_;
52 scoped_ptr<LastRequestResultCache> result_cache_; 68 scoped_ptr<LastRequestResultCache> result_cache_;
53 69
70 base::WeakPtrFactory<AwPermissionManager> weak_ptr_factory_;
71
54 DISALLOW_COPY_AND_ASSIGN(AwPermissionManager); 72 DISALLOW_COPY_AND_ASSIGN(AwPermissionManager);
55 }; 73 };
56 74
57 } // namespace android_webview 75 } // namespace android_webview
58 76
59 #endif // ANDROID_WEBVIEW_BROWSER_AW_PERMISSION_MANAGER_H_ 77 #endif // ANDROID_WEBVIEW_BROWSER_AW_PERMISSION_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | android_webview/browser/aw_permission_manager.cc » ('j') | android_webview/browser/aw_permission_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698