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

Side by Side Diff: chrome/browser/permissions/permission_infobar_delegate.cc

Issue 1332293002: permissions: switch from explicitly passing queue controller to callbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/permissions/permission_infobar_delegate.h" 5 #include "chrome/browser/permissions/permission_infobar_delegate.h"
6 6
7 #include "chrome/browser/permissions/permission_context_uma_util.h" 7 #include "chrome/browser/permissions/permission_context_uma_util.h"
8 #include "chrome/browser/permissions/permission_queue_controller.h"
9 #include "chrome/grit/generated_resources.h" 8 #include "chrome/grit/generated_resources.h"
10 #include "components/infobars/core/infobar.h" 9 #include "components/infobars/core/infobar.h"
11 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
12 11
13 PermissionInfobarDelegate::~PermissionInfobarDelegate() { 12 PermissionInfobarDelegate::~PermissionInfobarDelegate() {
14 if (!action_taken_) 13 if (!action_taken_)
15 PermissionContextUmaUtil::PermissionIgnored(type_, requesting_origin_); 14 PermissionContextUmaUtil::PermissionIgnored(type_, requesting_origin_);
16 } 15 }
17 16
18 PermissionInfobarDelegate::PermissionInfobarDelegate( 17 PermissionInfobarDelegate::PermissionInfobarDelegate(
19 PermissionQueueController* controller,
20 const PermissionRequestID& id,
21 const GURL& requesting_origin, 18 const GURL& requesting_origin,
22 ContentSettingsType type) 19 ContentSettingsType type,
23 : controller_(controller), id_(id), requesting_origin_(requesting_origin), 20 const base::Callback<void(bool, bool)>& callback)
21 : requesting_origin_(requesting_origin),
24 action_taken_(false), 22 action_taken_(false),
25 type_(type) { 23 type_(type),
24 callback_(callback) {
26 } 25 }
27 26
28 infobars::InfoBarDelegate::Type 27 infobars::InfoBarDelegate::Type
29 PermissionInfobarDelegate::GetInfoBarType() const { 28 PermissionInfobarDelegate::GetInfoBarType() const {
30 return PAGE_ACTION_TYPE; 29 return PAGE_ACTION_TYPE;
31 } 30 }
32 31
33 void PermissionInfobarDelegate::InfoBarDismissed() { 32 void PermissionInfobarDelegate::InfoBarDismissed() {
34 SetPermission(false, false); 33 SetPermission(false, false);
35 } 34 }
(...skipping 15 matching lines...) Expand all
51 } 50 }
52 51
53 bool PermissionInfobarDelegate::Cancel() { 52 bool PermissionInfobarDelegate::Cancel() {
54 SetPermission(true, false); 53 SetPermission(true, false);
55 return true; 54 return true;
56 } 55 }
57 56
58 void PermissionInfobarDelegate::SetPermission(bool update_content_setting, 57 void PermissionInfobarDelegate::SetPermission(bool update_content_setting,
59 bool allowed) { 58 bool allowed) {
60 action_taken_ = true; 59 action_taken_ = true;
61 controller_->OnPermissionSet( 60 callback_.Run(update_content_setting, allowed);
62 id_, requesting_origin_,
63 InfoBarService::WebContentsFromInfoBar(
64 infobar())->GetLastCommittedURL().GetOrigin(),
65 update_content_setting, allowed);
66 } 61 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_infobar_delegate.h ('k') | chrome/browser/permissions/permission_queue_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698