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

Unified Diff: chrome/browser/permissions/permission_context_base.cc

Issue 1337903002: permissions: remove PermissionQueueController and introduce PermissionInfoBarManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@callbacks-delegates
Patch Set: Fix compile failures Created 5 years, 2 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: chrome/browser/permissions/permission_context_base.cc
diff --git a/chrome/browser/permissions/permission_context_base.cc b/chrome/browser/permissions/permission_context_base.cc
index f329b2bbb640a9b6826ee85bac39ff266dbc7528..cdda6467ae3bb5ae38e78c133b5dca3c4a3300cb 100644
--- a/chrome/browser/permissions/permission_context_base.cc
+++ b/chrome/browser/permissions/permission_context_base.cc
@@ -9,7 +9,7 @@
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/permissions/permission_bubble_request_impl.h"
#include "chrome/browser/permissions/permission_context_uma_util.h"
-#include "chrome/browser/permissions/permission_queue_controller.h"
+#include "chrome/browser/permissions/permission_infobar_manager.h"
#include "chrome/browser/permissions/permission_request_id.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
@@ -26,8 +26,6 @@ PermissionContextBase::PermissionContextBase(
: profile_(profile),
permission_type_(permission_type),
weak_factory_(this) {
- permission_queue_controller_.reset(
- new PermissionQueueController(profile_, permission_type_));
}
PermissionContextBase::~PermissionContextBase() {
@@ -79,18 +77,20 @@ void PermissionContextBase::CancelPermissionRequest(
const PermissionRequestID& id) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- if (PermissionBubbleManager::Enabled()) {
- PermissionBubbleRequest* cancelling =
- pending_bubbles_.get(id.ToString());
- if (cancelling != NULL && web_contents != NULL &&
- PermissionBubbleManager::FromWebContents(web_contents) != NULL) {
+ if (!web_contents)
+ return;
+
+ if (PermissionBubbleManager::Enabled() &&
+ PermissionBubbleManager::FromWebContents(web_contents)) {
+ PermissionBubbleRequest* cancelling = pending_bubbles_.get(id.ToString());
+ if (cancelling) {
PermissionBubbleManager::FromWebContents(web_contents)->
CancelRequest(cancelling);
}
- return;
+ } else if (PermissionInfoBarManager::FromWebContents(web_contents)) {
+ PermissionInfoBarManager::FromWebContents(web_contents)->
+ CancelRequest(id);
}
-
- GetQueueController()->CancelInfoBarRequest(id);
}
void PermissionContextBase::DecidePermission(
@@ -162,16 +162,15 @@ void PermissionContextBase::DecidePermission(
return;
}
- // TODO(gbillock): Delete this and the infobar delegate when
- // we're using only bubbles. crbug.com/337458
- GetQueueController()->CreateInfoBarRequest(
- id, requesting_origin, embedding_origin,
+ PermissionInfoBarManager* infobar_manager =
+ PermissionInfoBarManager::FromWebContents(web_contents);
+ DCHECK(infobar_manager);
+ infobar_manager->CreateRequest(
+ permission_type_, id,
+ requesting_origin, embedding_origin,
base::Bind(&PermissionContextBase::PermissionDecided,
weak_factory_.GetWeakPtr(), id, requesting_origin,
- embedding_origin, callback,
- // the queue controller takes care of persisting the
- // permission
- false));
+ embedding_origin, callback));
}
void PermissionContextBase::PermissionDecided(
@@ -181,33 +180,25 @@ void PermissionContextBase::PermissionDecided(
const BrowserPermissionCallback& callback,
bool persist,
ContentSetting content_setting) {
- // Infobar persistance and its related UMA is tracked on the infobar
- // controller directly.
- if (PermissionBubbleManager::Enabled()) {
- if (persist) {
- DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
- content_setting == CONTENT_SETTING_BLOCK);
- if (content_setting == CONTENT_SETTING_ALLOW)
- PermissionContextUmaUtil::PermissionGranted(permission_type_,
- requesting_origin);
- else
- PermissionContextUmaUtil::PermissionDenied(permission_type_,
- requesting_origin);
- } else {
- DCHECK_EQ(content_setting, CONTENT_SETTING_DEFAULT);
- PermissionContextUmaUtil::PermissionDismissed(permission_type_,
- requesting_origin);
- }
+ if (persist) {
+ DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
+ content_setting == CONTENT_SETTING_BLOCK);
+ if (content_setting == CONTENT_SETTING_ALLOW)
+ PermissionContextUmaUtil::PermissionGranted(permission_type_,
+ requesting_origin);
+ else
+ PermissionContextUmaUtil::PermissionDenied(permission_type_,
+ requesting_origin);
+ } else {
+ DCHECK_EQ(content_setting, CONTENT_SETTING_DEFAULT);
+ PermissionContextUmaUtil::PermissionDismissed(permission_type_,
+ requesting_origin);
}
NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
persist, content_setting);
}
-PermissionQueueController* PermissionContextBase::GetQueueController() {
- return permission_queue_controller_.get();
-}
-
Profile* PermissionContextBase::profile() const {
return profile_;
}
« no previous file with comments | « chrome/browser/permissions/permission_context_base.h ('k') | chrome/browser/permissions/permission_context_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698