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

Side by Side Diff: android_webview/browser/aw_permission_manager.h

Issue 2143573002: Implement AwPermissionManager::RequestPermissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: allow multiple requests Created 4 years, 4 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 <memory> 8 #include <memory>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/id_map.h" 11 #include "base/id_map.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "content/public/browser/permission_manager.h" 14 #include "content/public/browser/permission_manager.h"
15 15
16 namespace android_webview { 16 namespace android_webview {
17 17
18 class AwBrowserPermissionRequestDelegate;
18 class LastRequestResultCache; 19 class LastRequestResultCache;
19 20
20 class AwPermissionManager : public content::PermissionManager { 21 class AwPermissionManager : public content::PermissionManager {
21 public: 22 public:
22 AwPermissionManager(); 23 AwPermissionManager();
23 ~AwPermissionManager() override; 24 ~AwPermissionManager() override;
24 25
25 // PermissionManager implementation. 26 // PermissionManager implementation.
26 int RequestPermission( 27 int RequestPermission(
27 content::PermissionType permission, 28 content::PermissionType permission,
(...skipping 22 matching lines...) Expand all
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(blink::mojom::PermissionStatus)>& callback) 57 const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
57 override; 58 override;
58 void UnsubscribePermissionStatusChange(int subscription_id) override; 59 void UnsubscribePermissionStatusChange(int subscription_id) override;
59 60
61 protected:
62 void CancelPermissionRequests();
63
60 private: 64 private:
61 struct PendingRequest; 65 class PendingRequest;
62 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>; 66 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
63 67
68 virtual int GetRenderProcessID(content::RenderFrameHost* render_frame_host);
69 virtual int GetRenderFrameID(content::RenderFrameHost* render_frame_host);
70 virtual GURL LastCommittedOrigin(content::RenderFrameHost* render_frame_host);
71 virtual AwBrowserPermissionRequestDelegate* GetDelegate(int render_process_id,
72 int render_frame_id);
73
64 // The weak pointer to this is used to clean up any information which is 74 // The weak pointer to this is used to clean up any information which is
65 // stored in the pending request or result cache maps. However, the callback 75 // stored in the pending request or result cache maps. However, the callback
66 // should be run regardless of whether the class is still alive so the method 76 // should be run regardless of whether the class is still alive so the method
67 // is static. 77 // is static.
68 static void OnRequestResponse( 78 static void OnRequestResponse(
69 const base::WeakPtr<AwPermissionManager>& manager, 79 const base::WeakPtr<AwPermissionManager>& manager,
70 int request_id, 80 int request_id,
71 const base::Callback<void(blink::mojom::PermissionStatus)>& callback, 81 content::PermissionType permission,
72 bool allowed); 82 bool allowed);
73 83
74 PendingRequestsMap pending_requests_; 84 PendingRequestsMap pending_requests_;
75 std::unique_ptr<LastRequestResultCache> result_cache_; 85 std::unique_ptr<LastRequestResultCache> result_cache_;
76 86
77 base::WeakPtrFactory<AwPermissionManager> weak_ptr_factory_; 87 base::WeakPtrFactory<AwPermissionManager> weak_ptr_factory_;
78 88
79 DISALLOW_COPY_AND_ASSIGN(AwPermissionManager); 89 DISALLOW_COPY_AND_ASSIGN(AwPermissionManager);
80 }; 90 };
81 91
82 } // namespace android_webview 92 } // namespace android_webview
83 93
84 #endif // ANDROID_WEBVIEW_BROWSER_AW_PERMISSION_MANAGER_H_ 94 #endif // ANDROID_WEBVIEW_BROWSER_AW_PERMISSION_MANAGER_H_
OLDNEW
« no previous file with comments | « android_webview/android_webview_tests.gypi ('k') | android_webview/browser/aw_permission_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698