| 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" |
| 11 #include "chrome/browser/ui/page_info/permission_menu_model.h" | 11 #include "chrome/browser/ui/page_info/permission_menu_model.h" |
| 12 #include "chrome/browser/ui/views/page_info/non_accessible_image_view.h" | 12 #include "chrome/browser/ui/views/page_info/non_accessible_image_view.h" |
| 13 #include "chrome/browser/ui/views/page_info/page_info_popup_view.h" | 13 #include "chrome/browser/ui/views/page_info/page_info_bubble_view.h" |
| 14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 15 #include "ui/accessibility/ax_node_data.h" | 15 #include "ui/accessibility/ax_node_data.h" |
| 16 #include "ui/base/material_design/material_design_controller.h" | 16 #include "ui/base/material_design/material_design_controller.h" |
| 17 #include "ui/base/models/combobox_model.h" | 17 #include "ui/base/models/combobox_model.h" |
| 18 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 19 #include "ui/views/controls/button/menu_button.h" | 19 #include "ui/views/controls/button/menu_button.h" |
| 20 #include "ui/views/controls/combobox/combobox.h" | 20 #include "ui/views/controls/combobox/combobox.h" |
| 21 #include "ui/views/controls/combobox/combobox_listener.h" | 21 #include "ui/views/controls/combobox/combobox_listener.h" |
| 22 #include "ui/views/controls/image_view.h" | 22 #include "ui/views/controls/image_view.h" |
| 23 #include "ui/views/controls/label.h" | 23 #include "ui/views/controls/label.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // Change the permission icon to reflect the selected setting. | 340 // Change the permission icon to reflect the selected setting. |
| 341 const gfx::Image& image = PageInfoUI::GetPermissionIcon(permission); | 341 const gfx::Image& image = PageInfoUI::GetPermissionIcon(permission); |
| 342 icon_->SetImage(image.ToImageSkia()); | 342 icon_->SetImage(image.ToImageSkia()); |
| 343 | 343 |
| 344 // Update the menu button text to reflect the new setting. | 344 // Update the menu button text to reflect the new setting. |
| 345 if (menu_button_) { | 345 if (menu_button_) { |
| 346 menu_button_->SetText(PageInfoUI::PermissionActionToUIString( | 346 menu_button_->SetText(PageInfoUI::PermissionActionToUIString( |
| 347 profile_, permission.type, permission.setting, | 347 profile_, permission.type, permission.setting, |
| 348 permission.default_setting, content_settings::SETTING_SOURCE_USER)); | 348 permission.default_setting, content_settings::SETTING_SOURCE_USER)); |
| 349 menu_button_->SizeToPreferredSize(); | 349 menu_button_->SizeToPreferredSize(); |
| 350 // Re-layout will be done at the |PageInfoPopupView| level, since | 350 // Re-layout will be done at the |PageInfoBubbleView| level, since |
| 351 // that view may need to resize itself to accomodate the new sizes of its | 351 // that view may need to resize itself to accomodate the new sizes of its |
| 352 // contents. | 352 // contents. |
| 353 menu_button_->InvalidateLayout(); | 353 menu_button_->InvalidateLayout(); |
| 354 } else if (combobox_) { | 354 } else if (combobox_) { |
| 355 bool use_default = permission.setting == CONTENT_SETTING_DEFAULT; | 355 bool use_default = permission.setting == CONTENT_SETTING_DEFAULT; |
| 356 combobox_->UpdateSelectedIndex(use_default); | 356 combobox_->UpdateSelectedIndex(use_default); |
| 357 } | 357 } |
| 358 | 358 |
| 359 for (PermissionSelectorRowObserver& observer : observer_list_) | 359 for (PermissionSelectorRowObserver& observer : observer_list_) |
| 360 observer.OnPermissionChanged(permission); | 360 observer.OnPermissionChanged(permission); |
| 361 } | 361 } |
| 362 | 362 |
| 363 views::View* PermissionSelectorRow::button() { | 363 views::View* PermissionSelectorRow::button() { |
| 364 // 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 |
| 365 // 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 |
| 366 // and T1 and T2 are both subtypes of T. | 366 // and T1 and T2 are both subtypes of T. |
| 367 return menu_button_ ? static_cast<views::View*>(menu_button_) | 367 return menu_button_ ? static_cast<views::View*>(menu_button_) |
| 368 : static_cast<views::View*>(combobox_); | 368 : static_cast<views::View*>(combobox_); |
| 369 } | 369 } |
| OLD | NEW |