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

Side by Side Diff: chrome/browser/ui/views/website_settings/permission_prompt_impl.cc

Issue 2385063005: Make PermissionRequest::GetIconId return different types (Closed)
Patch Set: git cl try Created 4 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 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/ui/views/website_settings/permission_prompt_impl.h" 5 #include "chrome/browser/ui/views/website_settings/permission_prompt_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 set_close_on_deactivate(false); 196 set_close_on_deactivate(false);
197 197
198 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 198 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
199 kItemMajorSpacing)); 199 kItemMajorSpacing));
200 200
201 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( 201 display_origin_ = url_formatter::FormatUrlForSecurityDisplay(
202 requests[0]->GetOrigin(), 202 requests[0]->GetOrigin(),
203 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); 203 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
204 204
205 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
206 bool show_persistence_toggle = true; 205 bool show_persistence_toggle = true;
207 for (size_t index = 0; index < requests.size(); index++) { 206 for (size_t index = 0; index < requests.size(); index++) {
208 DCHECK(index < accept_state.size()); 207 DCHECK(index < accept_state.size());
209 // The row is laid out containing a leading-aligned label area and a 208 // The row is laid out containing a leading-aligned label area and a
210 // trailing column which will be filled if there are multiple permission 209 // trailing column which will be filled if there are multiple permission
211 // requests. 210 // requests.
212 views::View* row = new views::View(); 211 views::View* row = new views::View();
213 views::GridLayout* row_layout = new views::GridLayout(row); 212 views::GridLayout* row_layout = new views::GridLayout(row);
214 row->SetLayoutManager(row_layout); 213 row->SetLayoutManager(row_layout);
215 views::ColumnSet* columns = row_layout->AddColumnSet(0); 214 views::ColumnSet* columns = row_layout->AddColumnSet(0);
216 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 215 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL,
217 0, views::GridLayout::USE_PREF, 0, 0); 216 0, views::GridLayout::USE_PREF, 0, 0);
218 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, 217 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL,
219 100, views::GridLayout::USE_PREF, 0, 0); 218 100, views::GridLayout::USE_PREF, 0, 0);
220 row_layout->StartRow(0, 0); 219 row_layout->StartRow(0, 0);
221 220
222 views::View* label_container = new views::View(); 221 views::View* label_container = new views::View();
223 label_container->SetLayoutManager(new views::BoxLayout( 222 label_container->SetLayoutManager(new views::BoxLayout(
224 views::BoxLayout::kHorizontal, views::kCheckboxIndent, 0, 223 views::BoxLayout::kHorizontal, views::kCheckboxIndent, 0,
225 views::kItemLabelSpacing)); 224 views::kItemLabelSpacing));
226 views::ImageView* icon = new views::ImageView(); 225 views::ImageView* icon = new views::ImageView();
227 gfx::VectorIconId vector_id = requests[index]->GetVectorIconId(); 226 gfx::VectorIconId vector_id = requests[index]->GetIconId();
Peter Kasting 2016/10/06 07:10:30 Nit: Seems like this should technically be Pe
Evan Stade 2016/10/06 15:33:50 I dunno, because at some point you do have to assu
228 if (vector_id != gfx::VectorIconId::VECTOR_ICON_NONE) { 227 if (vector_id != gfx::VectorIconId::VECTOR_ICON_NONE) {
229 icon->SetImage( 228 icon->SetImage(
230 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); 229 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey));
231 } else {
232 icon->SetImage(bundle.GetImageSkiaNamed(requests.at(index)->GetIconId()));
233 icon->SetImageSize(gfx::Size(kIconSize, kIconSize));
234 } 230 }
235 icon->SetTooltipText(base::string16()); // Redundant with the text fragment 231 icon->SetTooltipText(base::string16()); // Redundant with the text fragment
236 label_container->AddChildView(icon); 232 label_container->AddChildView(icon);
237 views::Label* label = 233 views::Label* label =
238 new views::Label(requests.at(index)->GetMessageTextFragment()); 234 new views::Label(requests.at(index)->GetMessageTextFragment());
239 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 235 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
240 label_container->AddChildView(label); 236 label_container->AddChildView(label);
241 row_layout->AddView(label_container); 237 row_layout->AddView(label_container);
242 238
243 // Only show the toggle if every request wants to show it. 239 // Only show the toggle if every request wants to show it.
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 472
477 void PermissionPromptImpl::Accept() { 473 void PermissionPromptImpl::Accept() {
478 if (delegate_) 474 if (delegate_)
479 delegate_->Accept(); 475 delegate_->Accept();
480 } 476 }
481 477
482 void PermissionPromptImpl::Deny() { 478 void PermissionPromptImpl::Deny() {
483 if (delegate_) 479 if (delegate_)
484 delegate_->Deny(); 480 delegate_->Deny();
485 } 481 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698