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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/browser/aw_permission_manager.h
diff --git a/android_webview/browser/aw_permission_manager.h b/android_webview/browser/aw_permission_manager.h
index 842170b0bf55a396e80dfa47b15897b212d58fec..cd2b85d692b95c612329e000163099cffbbf24e1 100644
--- a/android_webview/browser/aw_permission_manager.h
+++ b/android_webview/browser/aw_permission_manager.h
@@ -6,8 +6,10 @@
#define ANDROID_WEBVIEW_BROWSER_AW_PERMISSION_MANAGER_H_
#include "base/callback_forward.h"
+#include "base/id_map.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/browser/permission_manager.h"
namespace android_webview {
@@ -20,10 +22,9 @@ class AwPermissionManager : public content::PermissionManager {
~AwPermissionManager() override;
// PermissionManager implementation.
- void RequestPermission(
+ int RequestPermission(
content::PermissionType permission,
content::RenderFrameHost* render_frame_host,
- int request_id,
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(content::PermissionStatus)>& callback) override;
@@ -49,8 +50,24 @@ class AwPermissionManager : public content::PermissionManager {
void UnsubscribePermissionStatusChange(int subscription_id) override;
private:
+ class PendingRequest;
+ using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
+
+ // The weak pointer to this is used to clean up any information which is
+ // stored in the pending request or result cache maps. However, the callback
+ // should be run regardless of whether the class is still alive so the method
+ // is static.
+ 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
+ const base::WeakPtr<AwPermissionManager>& manager,
+ int request_id,
+ const base::Callback<void(content::PermissionStatus)>& callback,
+ bool allowed);
+
+ PendingRequestsMap pending_requests_;
scoped_ptr<LastRequestResultCache> result_cache_;
+ base::WeakPtrFactory<AwPermissionManager> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(AwPermissionManager);
};

Powered by Google App Engine
This is Rietveld 408576698