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

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

Issue 2454813004: Make PermissionRequest::GetIconId return different types on desktop and Android so that the IDR_ an… (Closed)
Patch Set: 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 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 set_close_on_deactivate(false); 199 set_close_on_deactivate(false);
200 200
201 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 201 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
202 kItemMajorSpacing)); 202 kItemMajorSpacing));
203 203
204 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( 204 display_origin_ = url_formatter::FormatUrlForSecurityDisplay(
205 requests[0]->GetOrigin(), 205 requests[0]->GetOrigin(),
206 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); 206 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
207 207
208 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
209 bool show_persistence_toggle = true; 208 bool show_persistence_toggle = true;
210 for (size_t index = 0; index < requests.size(); index++) { 209 for (size_t index = 0; index < requests.size(); index++) {
211 DCHECK(index < accept_state.size()); 210 DCHECK(index < accept_state.size());
212 // The row is laid out containing a leading-aligned label area and a 211 // The row is laid out containing a leading-aligned label area and a
213 // trailing column which will be filled if there are multiple permission 212 // trailing column which will be filled if there are multiple permission
214 // requests. 213 // requests.
215 views::View* row = new views::View(); 214 views::View* row = new views::View();
216 views::GridLayout* row_layout = new views::GridLayout(row); 215 views::GridLayout* row_layout = new views::GridLayout(row);
217 row->SetLayoutManager(row_layout); 216 row->SetLayoutManager(row_layout);
218 views::ColumnSet* columns = row_layout->AddColumnSet(0); 217 views::ColumnSet* columns = row_layout->AddColumnSet(0);
219 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 218 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL,
220 0, views::GridLayout::USE_PREF, 0, 0); 219 0, views::GridLayout::USE_PREF, 0, 0);
221 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, 220 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL,
222 100, views::GridLayout::USE_PREF, 0, 0); 221 100, views::GridLayout::USE_PREF, 0, 0);
223 row_layout->StartRow(0, 0); 222 row_layout->StartRow(0, 0);
224 223
225 views::View* label_container = new views::View(); 224 views::View* label_container = new views::View();
226 label_container->SetLayoutManager(new views::BoxLayout( 225 label_container->SetLayoutManager(new views::BoxLayout(
227 views::BoxLayout::kHorizontal, views::kCheckboxIndent, 0, 226 views::BoxLayout::kHorizontal, views::kCheckboxIndent, 0,
228 views::kItemLabelSpacing)); 227 views::kItemLabelSpacing));
229 views::ImageView* icon = new views::ImageView(); 228 views::ImageView* icon = new views::ImageView();
230 gfx::VectorIconId vector_id = requests[index]->GetVectorIconId(); 229 gfx::VectorIconId vector_id = requests[index]->GetIconId();
231 if (vector_id != gfx::VectorIconId::VECTOR_ICON_NONE) { 230 if (vector_id != gfx::VectorIconId::VECTOR_ICON_NONE) {
232 icon->SetImage( 231 icon->SetImage(
233 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); 232 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey));
234 } else {
235 icon->SetImage(bundle.GetImageSkiaNamed(requests.at(index)->GetIconId()));
236 icon->SetImageSize(gfx::Size(kIconSize, kIconSize));
237 } 233 }
238 icon->SetTooltipText(base::string16()); // Redundant with the text fragment 234 icon->SetTooltipText(base::string16()); // Redundant with the text fragment
239 label_container->AddChildView(icon); 235 label_container->AddChildView(icon);
240 views::Label* label = 236 views::Label* label =
241 new views::Label(requests.at(index)->GetMessageTextFragment()); 237 new views::Label(requests.at(index)->GetMessageTextFragment());
242 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 238 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
243 label_container->AddChildView(label); 239 label_container->AddChildView(label);
244 row_layout->AddView(label_container); 240 row_layout->AddView(label_container);
245 241
246 // Only show the toggle if every request wants to show it. 242 // Only show the toggle if every request wants to show it.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 } 479 }
484 480
485 void PermissionPromptImpl::Deny() { 481 void PermissionPromptImpl::Deny() {
486 if (delegate_) 482 if (delegate_)
487 delegate_->Deny(); 483 delegate_->Deny();
488 } 484 }
489 485
490 Profile* PermissionPromptImpl::GetProfile() { 486 Profile* PermissionPromptImpl::GetProfile() {
491 return browser_->profile(); 487 return browser_->profile();
492 } 488 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698