Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/permission_menu_model.h" | 10 #include "chrome/browser/ui/page_info/permission_menu_model.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 label_ = new views::Label( | 246 label_ = new views::Label( |
| 247 WebsiteSettingsUI::PermissionTypeToUIString(permission.type)); | 247 WebsiteSettingsUI::PermissionTypeToUIString(permission.type)); |
| 248 layout->AddView(label_, 1, 1, views::GridLayout::LEADING, | 248 layout->AddView(label_, 1, 1, views::GridLayout::LEADING, |
| 249 views::GridLayout::CENTER); | 249 views::GridLayout::CENTER); |
| 250 // Create the menu model. | 250 // Create the menu model. |
| 251 menu_model_.reset(new PermissionMenuModel( | 251 menu_model_.reset(new PermissionMenuModel( |
| 252 profile, url, permission, | 252 profile, url, permission, |
| 253 base::Bind(&PermissionSelectorRow::PermissionChanged, | 253 base::Bind(&PermissionSelectorRow::PermissionChanged, |
| 254 base::Unretained(this)))); | 254 base::Unretained(this)))); |
| 255 | 255 |
| 256 // Create the permission menu button. | 256 // Create the permission menu button. |
| 257 #if defined(OS_MACOSX) | 257 #if defined(OS_MACOSX) |
| 258 bool use_real_combobox = true; | 258 bool use_real_combobox = true; |
| 259 #else | 259 #else |
| 260 bool use_real_combobox = | 260 bool use_real_combobox = |
| 261 ui::MaterialDesignController::IsSecondaryUiMaterial(); | 261 ui::MaterialDesignController::IsSecondaryUiMaterial(); |
| 262 #endif | 262 #endif |
| 263 if (use_real_combobox) | 263 if (use_real_combobox) |
| 264 InitializeComboboxView(layout, permission); | 264 InitializeComboboxView(layout, permission); |
| 265 else | 265 else |
| 266 InitializeMenuButtonView(layout, permission); | 266 InitializeMenuButtonView(layout, permission); |
| 267 | |
| 268 // Show the permission decision reason, if it was not the user. | |
|
dominickn
2017/03/26 23:46:24
Same comment as above
Patti Lor
2017/03/27 05:52:41
Done.
| |
| 269 base::string16 reason = WebsiteSettingsUI::PermissionDecisionReasonToString( | |
| 270 profile, permission, url); | |
| 271 if (!reason.empty()) { | |
| 272 layout->StartRow(1, 1); | |
| 273 layout->SkipColumns(1); | |
| 274 views::Label* permission_decision_reason = new views::Label(reason); | |
| 275 permission_decision_reason->SetEnabledColor(SK_ColorGRAY); | |
| 276 // Long labels should span the remaining width of the row. | |
| 277 views::ColumnSet* column_set = layout->GetColumnSet(1); | |
| 278 DCHECK(!!column_set); | |
| 279 layout->AddView(permission_decision_reason, column_set->num_columns() - 2, | |
| 280 1, views::GridLayout::LEADING, views::GridLayout::CENTER); | |
| 281 } | |
| 267 } | 282 } |
| 268 | 283 |
| 269 void PermissionSelectorRow::AddObserver( | 284 void PermissionSelectorRow::AddObserver( |
| 270 PermissionSelectorRowObserver* observer) { | 285 PermissionSelectorRowObserver* observer) { |
| 271 observer_list_.AddObserver(observer); | 286 observer_list_.AddObserver(observer); |
| 272 } | 287 } |
| 273 | 288 |
| 274 PermissionSelectorRow::~PermissionSelectorRow() { | 289 PermissionSelectorRow::~PermissionSelectorRow() { |
| 275 // Gross. On paper the Combobox and the ComboboxModelAdapter are both owned by | 290 // Gross. On paper the Combobox and the ComboboxModelAdapter are both owned by |
| 276 // this class, but actually, the Combobox is owned by View and will be | 291 // 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 Loading... | |
| 342 observer.OnPermissionChanged(permission); | 357 observer.OnPermissionChanged(permission); |
| 343 } | 358 } |
| 344 | 359 |
| 345 views::View* PermissionSelectorRow::button() { | 360 views::View* PermissionSelectorRow::button() { |
| 346 // These casts are required because the two arms of a ?: cannot have different | 361 // These casts are required because the two arms of a ?: cannot have different |
| 347 // types T1 and T2, even if the resulting value of the ?: is about to be a T | 362 // types T1 and T2, even if the resulting value of the ?: is about to be a T |
| 348 // and T1 and T2 are both subtypes of T. | 363 // and T1 and T2 are both subtypes of T. |
| 349 return menu_button_ ? static_cast<views::View*>(menu_button_) | 364 return menu_button_ ? static_cast<views::View*>(menu_button_) |
| 350 : static_cast<views::View*>(combobox_); | 365 : static_cast<views::View*>(combobox_); |
| 351 } | 366 } |
| OLD | NEW |