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/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 Loading... |
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( |
| 278 PageInfoUI::GetPermissionDecisionTextColor()); |
| 279 // Long labels should span the remaining width of the row. |
| 280 views::ColumnSet* column_set = layout->GetColumnSet(1); |
| 281 DCHECK(column_set); |
| 282 layout->AddView(permission_decision_reason, column_set->num_columns() - 2, |
| 283 1, views::GridLayout::LEADING, views::GridLayout::CENTER); |
| 284 } |
269 } | 285 } |
270 | 286 |
271 void PermissionSelectorRow::AddObserver( | 287 void PermissionSelectorRow::AddObserver( |
272 PermissionSelectorRowObserver* observer) { | 288 PermissionSelectorRowObserver* observer) { |
273 observer_list_.AddObserver(observer); | 289 observer_list_.AddObserver(observer); |
274 } | 290 } |
275 | 291 |
276 PermissionSelectorRow::~PermissionSelectorRow() { | 292 PermissionSelectorRow::~PermissionSelectorRow() { |
277 // Gross. On paper the Combobox and the ComboboxModelAdapter are both owned by | 293 // 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 | 294 // 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... |
344 observer.OnPermissionChanged(permission); | 360 observer.OnPermissionChanged(permission); |
345 } | 361 } |
346 | 362 |
347 views::View* PermissionSelectorRow::button() { | 363 views::View* PermissionSelectorRow::button() { |
348 // These casts are required because the two arms of a ?: cannot have different | 364 // 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 | 365 // 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. | 366 // and T1 and T2 are both subtypes of T. |
351 return menu_button_ ? static_cast<views::View*>(menu_button_) | 367 return menu_button_ ? static_cast<views::View*>(menu_button_) |
352 : static_cast<views::View*>(combobox_); | 368 : static_cast<views::View*>(combobox_); |
353 } | 369 } |
OLD | NEW |