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

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

Issue 2444253002: Change accept state of PermissionRequestManager from grouped infobar (Closed)
Patch Set: remove unused stuff Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/grouped_permission_infobar_delegate_android .h" 5 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android .h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/android/android_theme_resources.h" 8 #include "chrome/browser/android/android_theme_resources.h"
9 #include "chrome/browser/infobars/infobar_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/browser/permissions/permission_prompt_android.h" 10 #include "chrome/browser/permissions/permission_prompt_android.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 base::string16 GroupedPermissionInfoBarDelegate::GetMessageTextFragment( 50 base::string16 GroupedPermissionInfoBarDelegate::GetMessageTextFragment(
51 size_t position) const { 51 size_t position) const {
52 DCHECK_LT(position, requests_.size()); 52 DCHECK_LT(position, requests_.size());
53 return requests_[position]->GetMessageTextFragment(); 53 return requests_[position]->GetMessageTextFragment();
54 } 54 }
55 55
56 void GroupedPermissionInfoBarDelegate::ToggleAccept(size_t position, 56 void GroupedPermissionInfoBarDelegate::ToggleAccept(size_t position,
57 bool new_value) { 57 bool new_value) {
58 DCHECK_LT(position, requests_.size()); 58 DCHECK_LT(position, requests_.size());
59 accept_states_[position] = new_value; 59 if (permission_prompt_)
60 permission_prompt_->ToggleAccept(position, new_value);
60 } 61 }
61 62
62 base::string16 GroupedPermissionInfoBarDelegate::GetMessageText() const { 63 base::string16 GroupedPermissionInfoBarDelegate::GetMessageText() const {
63 return l10n_util::GetStringFUTF16( 64 return l10n_util::GetStringFUTF16(
64 IDS_PERMISSIONS_BUBBLE_PROMPT, 65 IDS_PERMISSIONS_BUBBLE_PROMPT,
65 url_formatter::FormatUrlForSecurityDisplay(requesting_origin_)); 66 url_formatter::FormatUrlForSecurityDisplay(requesting_origin_));
66 } 67 }
67 68
68 bool GroupedPermissionInfoBarDelegate::Accept() { 69 bool GroupedPermissionInfoBarDelegate::Accept() {
69 if (permission_prompt_) 70 if (permission_prompt_)
70 permission_prompt_->Accept(); 71 permission_prompt_->Accept();
71 return true; 72 return true;
72 } 73 }
73 74
74 bool GroupedPermissionInfoBarDelegate::Cancel() { 75 bool GroupedPermissionInfoBarDelegate::Cancel() {
75 if (permission_prompt_) 76 if (permission_prompt_)
76 permission_prompt_->Deny(); 77 permission_prompt_->Deny();
77 return true; 78 return true;
78 } 79 }
79 80
80 void GroupedPermissionInfoBarDelegate::PermissionPromptDestroyed() { 81 void GroupedPermissionInfoBarDelegate::PermissionPromptDestroyed() {
81 permission_prompt_ = nullptr; 82 permission_prompt_ = nullptr;
82 } 83 }
83 84
84 bool GroupedPermissionInfoBarDelegate::GetAcceptState(size_t position) {
85 DCHECK_LT(position, requests_.size());
86 return accept_states_[position];
87 }
88
89 GroupedPermissionInfoBarDelegate::GroupedPermissionInfoBarDelegate( 85 GroupedPermissionInfoBarDelegate::GroupedPermissionInfoBarDelegate(
90 PermissionPromptAndroid* permission_prompt, 86 PermissionPromptAndroid* permission_prompt,
91 const GURL& requesting_origin, 87 const GURL& requesting_origin,
92 const std::vector<PermissionRequest*>& requests) 88 const std::vector<PermissionRequest*>& requests)
93 : requesting_origin_(requesting_origin), 89 : requesting_origin_(requesting_origin),
94 requests_(requests), 90 requests_(requests),
95 accept_states_(requests_.size(), true),
96 persist_(true), 91 persist_(true),
97 permission_prompt_(permission_prompt) { 92 permission_prompt_(permission_prompt) {
98 DCHECK(permission_prompt); 93 DCHECK(permission_prompt);
99 } 94 }
100 95
101 infobars::InfoBarDelegate::InfoBarIdentifier 96 infobars::InfoBarDelegate::InfoBarIdentifier
102 GroupedPermissionInfoBarDelegate::GetIdentifier() const { 97 GroupedPermissionInfoBarDelegate::GetIdentifier() const {
103 return GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROID; 98 return GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROID;
104 } 99 }
105 100
(...skipping 13 matching lines...) Expand all
119 base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel( 114 base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel(
120 InfoBarButton button) const { 115 InfoBarButton button) const {
121 if (permission_count() > 1) { 116 if (permission_count() > 1) {
122 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_APP_OK 117 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_APP_OK
123 : IDS_APP_CANCEL); 118 : IDS_APP_CANCEL);
124 } 119 }
125 120
126 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_PERMISSION_ALLOW 121 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_PERMISSION_ALLOW
127 : IDS_PERMISSION_DENY); 122 : IDS_PERMISSION_DENY);
128 } 123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698