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

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: Address review comments 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..007a919900e8ea4c53c381300c0c07299e5bbf92 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,17 +22,13 @@ 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;
- void CancelPermissionRequest(content::PermissionType permission,
- content::RenderFrameHost* render_frame_host,
- int request_id,
- const GURL& requesting_origin) override;
+ void CancelPermissionRequest(int request_id) override;
void ResetPermission(content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
@@ -49,8 +47,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(
+ const base::WeakPtr<AwPermissionManager>& manager,
+ int request_id,
+ const base::Callback<void(content::PermissionStatus)>& callback,
+ bool allowed);
michaelbai 2015/09/23 16:57:26 This hasn't to be class's static method, move it t
+
+ PendingRequestsMap pending_requests_;
scoped_ptr<LastRequestResultCache> result_cache_;
+ base::WeakPtrFactory<AwPermissionManager> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(AwPermissionManager);
};
« 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