summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlalitm <lalitm@google.com>2015-10-02 09:00:29 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-02 16:01:03 +0000
commit5bd7eb048923100d1869f895e50f409a0dfdb70d (patch)
tree041306266f139d4f40f0d3cb48c2c963ee3ea5e4
parent8bd06c7f6d554927a29dc90580bd9bb59107b9ff (diff)
downloadchromium_src-5bd7eb048923100d1869f895e50f409a0dfdb70d.zip
chromium_src-5bd7eb048923100d1869f895e50f409a0dfdb70d.tar.gz
chromium_src-5bd7eb048923100d1869f895e50f409a0dfdb70d.tar.bz2
permissions: remove unecessary parameters from cancel
Since WebView and Chrome implementations of permission manager both store the required information, the extraneous parameters from Cancel can be removed. This CL depends on https://codereview.chromium.org/1342833002/ BUG=516626 Review URL: https://codereview.chromium.org/1375563002 Cr-Commit-Position: refs/heads/master@{#352045}
-rw-r--r--android_webview/browser/aw_permission_manager.cc41
-rw-r--r--android_webview/browser/aw_permission_manager.h5
-rw-r--r--chrome/browser/permissions/permission_manager.cc25
-rw-r--r--chrome/browser/permissions/permission_manager.h5
-rw-r--r--chromecast/browser/cast_permission_manager.cc6
-rw-r--r--chromecast/browser/cast_permission_manager.h5
-rw-r--r--content/browser/permissions/permission_service_context.cc10
-rw-r--r--content/browser/permissions/permission_service_context.h2
-rw-r--r--content/browser/permissions/permission_service_impl.cc6
-rw-r--r--content/public/browser/permission_manager.h10
-rw-r--r--content/shell/browser/layout_test/layout_test_permission_manager.cc6
-rw-r--r--content/shell/browser/layout_test/layout_test_permission_manager.h5
-rw-r--r--content/shell/browser/shell_permission_manager.cc6
-rw-r--r--content/shell/browser/shell_permission_manager.h5
14 files changed, 54 insertions, 83 deletions
diff --git a/android_webview/browser/aw_permission_manager.cc b/android_webview/browser/aw_permission_manager.cc
index 6474513..cd15346 100644
--- a/android_webview/browser/aw_permission_manager.cc
+++ b/android_webview/browser/aw_permission_manager.cc
@@ -290,42 +290,49 @@ void AwPermissionManager::OnRequestResponse(
callback.Run(status);
}
-void AwPermissionManager::CancelPermissionRequest(
- PermissionType permission,
- content::RenderFrameHost* render_frame_host,
- int request_id,
- const GURL& origin) {
+void AwPermissionManager::CancelPermissionRequest(int request_id) {
PendingRequest* pending_request = pending_requests_.Lookup(request_id);
if (!pending_request)
return;
+ content::RenderFrameHost* render_frame_host =
+ content::RenderFrameHost::FromID(pending_request->render_process_id,
+ pending_request->render_frame_id);
+ content::WebContents* web_contents =
+ content::WebContents::FromRenderFrameHost(render_frame_host);
+ DCHECK(web_contents);
+
// The caller is canceling (presumably) the most recent request. Assuming the
// request did not complete, the user did not respond to the requset.
// Thus, assume we do not know the result.
- const GURL& embedding_origin =
- content::WebContents::FromRenderFrameHost(render_frame_host)
+ const GURL& embedding_origin = web_contents
->GetLastCommittedURL().GetOrigin();
- result_cache_->ClearResult(permission, origin, embedding_origin);
+ result_cache_->ClearResult(
+ pending_request->permission,
+ pending_request->requesting_origin,
+ embedding_origin);
- int render_process_id = render_frame_host->GetProcess()->GetID();
- int render_frame_id = render_frame_host->GetRoutingID();
AwBrowserPermissionRequestDelegate* delegate =
- AwBrowserPermissionRequestDelegate::FromID(render_process_id,
- render_frame_id);
+ AwBrowserPermissionRequestDelegate::FromID(
+ pending_request->render_process_id,
+ pending_request->render_frame_id);
if (!delegate) {
pending_requests_.Remove(request_id);
return;
}
- switch (permission) {
+ switch (pending_request->permission) {
case PermissionType::GEOLOCATION:
- delegate->CancelGeolocationPermissionRequests(origin);
+ delegate->CancelGeolocationPermissionRequests(
+ pending_request->requesting_origin);
break;
case PermissionType::PROTECTED_MEDIA_IDENTIFIER:
- delegate->CancelProtectedMediaIdentifierPermissionRequests(origin);
+ delegate->CancelProtectedMediaIdentifierPermissionRequests(
+ pending_request->requesting_origin);
break;
case PermissionType::MIDI_SYSEX:
- delegate->CancelMIDISysexPermissionRequests(origin);
+ delegate->CancelMIDISysexPermissionRequests(
+ pending_request->requesting_origin);
break;
case PermissionType::NOTIFICATIONS:
case PermissionType::PUSH_MESSAGING:
@@ -333,7 +340,7 @@ void AwPermissionManager::CancelPermissionRequest(
case PermissionType::AUDIO_CAPTURE:
case PermissionType::VIDEO_CAPTURE:
NOTIMPLEMENTED() << "CancelPermission not implemented for "
- << static_cast<int>(permission);
+ << static_cast<int>(pending_request->permission);
break;
case PermissionType::MIDI:
// There is nothing to cancel so this is simply ignored.
diff --git a/android_webview/browser/aw_permission_manager.h b/android_webview/browser/aw_permission_manager.h
index 6dd954e..ab507ce 100644
--- a/android_webview/browser/aw_permission_manager.h
+++ b/android_webview/browser/aw_permission_manager.h
@@ -28,10 +28,7 @@ class AwPermissionManager : public content::PermissionManager {
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;
diff --git a/chrome/browser/permissions/permission_manager.cc b/chrome/browser/permissions/permission_manager.cc
index 1f18104..a07f865 100644
--- a/chrome/browser/permissions/permission_manager.cc
+++ b/chrome/browser/permissions/permission_manager.cc
@@ -197,30 +197,27 @@ void PermissionManager::OnPermissionRequestResponse(
callback.Run(ContentSettingToPermissionStatus(content_setting));
}
-void PermissionManager::CancelPermissionRequest(
- PermissionType permission,
- content::RenderFrameHost* render_frame_host,
- int request_id,
- const GURL& requesting_origin) {
+void PermissionManager::CancelPermissionRequest(int request_id) {
PendingRequest* pending_request = pending_requests_.Lookup(request_id);
if (!pending_request)
return;
- PermissionContextBase* context = PermissionContext::Get(profile_, permission);
+ PermissionContextBase* context = PermissionContext::Get(
+ profile_, pending_request->permission);
if (!context)
return;
- content::WebContents* web_contents =
- content::WebContents::FromRenderFrameHost(render_frame_host);
- if (IsPermissionBubbleManagerMissing(web_contents))
+ content::WebContents* web_contents = tab_util::GetWebContentsByFrameID(
+ pending_request->render_process_id, pending_request->render_frame_id);
+ DCHECK(web_contents);
+ if (IsPermissionBubbleManagerMissing(web_contents)) {
+ pending_requests_.Remove(request_id);
return;
+ }
- int render_process_id = render_frame_host->GetProcess()->GetID();
- int render_frame_id = render_frame_host->GetRoutingID();
- const PermissionRequestID request(render_process_id,
- render_frame_id,
+ const PermissionRequestID request(pending_request->render_process_id,
+ pending_request->render_frame_id,
request_id);
-
context->CancelPermissionRequest(web_contents, request);
pending_requests_.Remove(request_id);
}
diff --git a/chrome/browser/permissions/permission_manager.h b/chrome/browser/permissions/permission_manager.h
index 8f21c65..118bd3f 100644
--- a/chrome/browser/permissions/permission_manager.h
+++ b/chrome/browser/permissions/permission_manager.h
@@ -36,10 +36,7 @@ class PermissionManager : public KeyedService,
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;
diff --git a/chromecast/browser/cast_permission_manager.cc b/chromecast/browser/cast_permission_manager.cc
index eaa6b94..a0d10f2 100644
--- a/chromecast/browser/cast_permission_manager.cc
+++ b/chromecast/browser/cast_permission_manager.cc
@@ -29,11 +29,7 @@ int CastPermissionManager::RequestPermission(
return kNoPendingOperation;
}
-void CastPermissionManager::CancelPermissionRequest(
- content::PermissionType permission,
- content::RenderFrameHost* render_frame_host,
- int request_id,
- const GURL& origin) {
+void CastPermissionManager::CancelPermissionRequest(int request_id) {
}
void CastPermissionManager::ResetPermission(
diff --git a/chromecast/browser/cast_permission_manager.h b/chromecast/browser/cast_permission_manager.h
index 5eab5a1..cb84c6a 100644
--- a/chromecast/browser/cast_permission_manager.h
+++ b/chromecast/browser/cast_permission_manager.h
@@ -24,10 +24,7 @@ class CastPermissionManager : public content::PermissionManager {
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;
diff --git a/content/browser/permissions/permission_service_context.cc b/content/browser/permissions/permission_service_context.cc
index be03580..ec8c386 100644
--- a/content/browser/permissions/permission_service_context.cc
+++ b/content/browser/permissions/permission_service_context.cc
@@ -41,17 +41,17 @@ void PermissionServiceContext::ServiceHadConnectionError(
services_.erase(it);
}
-void PermissionServiceContext::RenderFrameDeleted(
- RenderFrameHost* render_frame_host) {
- CancelPendingOperations(render_frame_host);
-}
-
void PermissionServiceContext::RenderFrameHostChanged(
RenderFrameHost* old_host,
RenderFrameHost* new_host) {
CancelPendingOperations(old_host);
}
+void PermissionServiceContext::FrameDeleted(
+ RenderFrameHost* render_frame_host) {
+ CancelPendingOperations(render_frame_host);
+}
+
void PermissionServiceContext::DidNavigateAnyFrame(
RenderFrameHost* render_frame_host,
const LoadCommittedDetails& details,
diff --git a/content/browser/permissions/permission_service_context.h b/content/browser/permissions/permission_service_context.h
index e07366d..ac54efb 100644
--- a/content/browser/permissions/permission_service_context.h
+++ b/content/browser/permissions/permission_service_context.h
@@ -40,9 +40,9 @@ class PermissionServiceContext : public WebContentsObserver {
private:
// WebContentsObserver
- void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
void RenderFrameHostChanged(RenderFrameHost* old_host,
RenderFrameHost* new_host) override;
+ void FrameDeleted(RenderFrameHost* render_frame_host) override;
void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
const LoadCommittedDetails& details,
const FrameNavigateParams& params) override;
diff --git a/content/browser/permissions/permission_service_impl.cc b/content/browser/permissions/permission_service_impl.cc
index 79fadd1..4d16c06 100644
--- a/content/browser/permissions/permission_service_impl.cc
+++ b/content/browser/permissions/permission_service_impl.cc
@@ -164,7 +164,6 @@ void PermissionServiceImpl::OnRequestPermissionResponse(
}
void PermissionServiceImpl::CancelPendingOperations() {
- DCHECK(context_->render_frame_host());
DCHECK(context_->GetBrowserContext());
PermissionManager* permission_manager =
@@ -176,10 +175,7 @@ void PermissionServiceImpl::CancelPendingOperations() {
for (RequestsMap::Iterator<PendingRequest> it(&pending_requests_);
!it.IsAtEnd(); it.Advance()) {
permission_manager->CancelPermissionRequest(
- it.GetCurrentValue()->permission,
- context_->render_frame_host(),
- it.GetCurrentKey(),
- it.GetCurrentValue()->origin);
+ it.GetCurrentValue()->id);
}
pending_requests_.Clear();
diff --git a/content/public/browser/permission_manager.h b/content/public/browser/permission_manager.h
index 84571ed..0108b66d 100644
--- a/content/public/browser/permission_manager.h
+++ b/content/public/browser/permission_manager.h
@@ -40,12 +40,10 @@ class CONTENT_EXPORT PermissionManager {
bool user_gesture,
const base::Callback<void(PermissionStatus)>& callback) = 0;
- // Cancels a previously requested permission. The given parameter must match
- // the ones passed to the RequestPermission call.
- virtual void CancelPermissionRequest(PermissionType permission,
- RenderFrameHost* render_frame_host,
- int request_id,
- const GURL& requesting_origin) = 0;
+ // Cancels a previous permission request specified by |request_id|. Cancelling
+ // an already cancelled request or providing the |request_id|
+ // kNoPendingOperation is a no-op.
+ virtual void CancelPermissionRequest(int request_id) = 0;
// Returns the permission status of a given requesting_origin/embedding_origin
// tuple. This is not taking a RenderFrameHost because the call might happen
diff --git a/content/shell/browser/layout_test/layout_test_permission_manager.cc b/content/shell/browser/layout_test/layout_test_permission_manager.cc
index e354f7b..9791db4 100644
--- a/content/shell/browser/layout_test/layout_test_permission_manager.cc
+++ b/content/shell/browser/layout_test/layout_test_permission_manager.cc
@@ -76,11 +76,7 @@ int LayoutTestPermissionManager::RequestPermission(
return kNoPendingOperation;
}
-void LayoutTestPermissionManager::CancelPermissionRequest(
- PermissionType permission,
- RenderFrameHost* render_frame_host,
- int request_id,
- const GURL& requesting_origin) {
+void LayoutTestPermissionManager::CancelPermissionRequest(int request_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
diff --git a/content/shell/browser/layout_test/layout_test_permission_manager.h b/content/shell/browser/layout_test/layout_test_permission_manager.h
index 85cd180..b7fba52 100644
--- a/content/shell/browser/layout_test/layout_test_permission_manager.h
+++ b/content/shell/browser/layout_test/layout_test_permission_manager.h
@@ -27,10 +27,7 @@ class LayoutTestPermissionManager : public PermissionManager {
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(PermissionStatus)>& callback) override;
- void CancelPermissionRequest(PermissionType permission,
- RenderFrameHost* render_frame_host,
- int request_id,
- const GURL& requesting_origin) override;
+ void CancelPermissionRequest(int request_id) override;
void ResetPermission(PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
diff --git a/content/shell/browser/shell_permission_manager.cc b/content/shell/browser/shell_permission_manager.cc
index da12bdb..7c591d8 100644
--- a/content/shell/browser/shell_permission_manager.cc
+++ b/content/shell/browser/shell_permission_manager.cc
@@ -27,11 +27,7 @@ int ShellPermissionManager::RequestPermission(
return kNoPendingOperation;
}
-void ShellPermissionManager::CancelPermissionRequest(
- PermissionType permission,
- RenderFrameHost* render_frame_host,
- int request_id,
- const GURL& requesting_origin) {
+void ShellPermissionManager::CancelPermissionRequest(int request_id) {
}
void ShellPermissionManager::ResetPermission(
diff --git a/content/shell/browser/shell_permission_manager.h b/content/shell/browser/shell_permission_manager.h
index b918372..0b195d4 100644
--- a/content/shell/browser/shell_permission_manager.h
+++ b/content/shell/browser/shell_permission_manager.h
@@ -23,10 +23,7 @@ class ShellPermissionManager : public PermissionManager {
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(PermissionStatus)>& callback) override;
- void CancelPermissionRequest(PermissionType permission,
- RenderFrameHost* render_frame_host,
- int request_id,
- const GURL& requesting_origin) override;
+ void CancelPermissionRequest(int request_id) override;
void ResetPermission(PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;