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

Side by Side Diff: chrome/browser/ui/views/page_info/permission_selector_row.cc

Issue 2743423004: Permissions: Show the reason for permission decisions made on the user's behalf. (Closed)
Patch Set: Rebase with review comments. Created 3 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/page_info/permission_selector_row.h" 5 #include "chrome/browser/ui/views/page_info/permission_selector_row.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/ui/page_info/page_info_ui.h" 10 #include "chrome/browser/ui/page_info/page_info_ui.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 #if defined(OS_MACOSX) 259 #if defined(OS_MACOSX)
260 bool use_real_combobox = true; 260 bool use_real_combobox = true;
261 #else 261 #else
262 bool use_real_combobox = 262 bool use_real_combobox =
263 ui::MaterialDesignController::IsSecondaryUiMaterial(); 263 ui::MaterialDesignController::IsSecondaryUiMaterial();
264 #endif 264 #endif
265 if (use_real_combobox) 265 if (use_real_combobox)
266 InitializeComboboxView(layout, permission); 266 InitializeComboboxView(layout, permission);
267 else 267 else
268 InitializeMenuButtonView(layout, permission); 268 InitializeMenuButtonView(layout, permission);
269
270 // Show the permission decision reason, if it was not the user.
271 base::string16 reason =
272 PageInfoUI::PermissionDecisionReasonToUIString(profile, permission, url);
273 if (!reason.empty()) {
274 layout->StartRow(1, 1);
275 layout->SkipColumns(1);
276 views::Label* permission_decision_reason = new views::Label(reason);
277 permission_decision_reason->SetEnabledColor(SK_ColorGRAY);
lgarron 2017/03/29 05:49:26 Note that "High Contrast Black" mode on Windows ha
Patti Lor 2017/03/30 03:27:29 No, they don't - there actually aren't any for non
278 // Long labels should span the remaining width of the row.
279 views::ColumnSet* column_set = layout->GetColumnSet(1);
280 DCHECK(!!column_set);
lgarron 2017/03/29 05:49:26 More of a question for me to learn: Is this patter
Patti Lor 2017/03/30 03:27:29 Good point - I've seen it before but I don't think
281 layout->AddView(permission_decision_reason, column_set->num_columns() - 2,
282 1, views::GridLayout::LEADING, views::GridLayout::CENTER);
283 }
269 } 284 }
270 285
271 void PermissionSelectorRow::AddObserver( 286 void PermissionSelectorRow::AddObserver(
272 PermissionSelectorRowObserver* observer) { 287 PermissionSelectorRowObserver* observer) {
273 observer_list_.AddObserver(observer); 288 observer_list_.AddObserver(observer);
274 } 289 }
275 290
276 PermissionSelectorRow::~PermissionSelectorRow() { 291 PermissionSelectorRow::~PermissionSelectorRow() {
277 // Gross. On paper the Combobox and the ComboboxModelAdapter are both owned by 292 // Gross. On paper the Combobox and the ComboboxModelAdapter are both owned by
278 // this class, but actually, the Combobox is owned by View and will be 293 // this class, but actually, the Combobox is owned by View and will be
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 observer.OnPermissionChanged(permission); 359 observer.OnPermissionChanged(permission);
345 } 360 }
346 361
347 views::View* PermissionSelectorRow::button() { 362 views::View* PermissionSelectorRow::button() {
348 // These casts are required because the two arms of a ?: cannot have different 363 // These casts are required because the two arms of a ?: cannot have different
349 // types T1 and T2, even if the resulting value of the ?: is about to be a T 364 // types T1 and T2, even if the resulting value of the ?: is about to be a T
350 // and T1 and T2 are both subtypes of T. 365 // and T1 and T2 are both subtypes of T.
351 return menu_button_ ? static_cast<views::View*>(menu_button_) 366 return menu_button_ ? static_cast<views::View*>(menu_button_)
352 : static_cast<views::View*>(combobox_); 367 : static_cast<views::View*>(combobox_);
353 } 368 }
OLDNEW
« chrome/browser/ui/page_info/page_info_ui.cc ('K') | « chrome/browser/ui/page_info/page_info_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698