| 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/harmony/chrome_typography.h" |
| 12 #include "chrome/browser/ui/views/page_info/non_accessible_image_view.h" | 13 #include "chrome/browser/ui/views/page_info/non_accessible_image_view.h" |
| 13 #include "chrome/browser/ui/views/page_info/page_info_bubble_view.h" | 14 #include "chrome/browser/ui/views/page_info/page_info_bubble_view.h" |
| 14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 15 #include "ui/accessibility/ax_node_data.h" | 16 #include "ui/accessibility/ax_node_data.h" |
| 16 #include "ui/base/material_design/material_design_controller.h" | 17 #include "ui/base/material_design/material_design_controller.h" |
| 17 #include "ui/base/models/combobox_model.h" | 18 #include "ui/base/models/combobox_model.h" |
| 18 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 19 #include "ui/views/controls/button/menu_button.h" | 20 #include "ui/views/controls/button/menu_button.h" |
| 20 #include "ui/views/controls/combobox/combobox.h" | 21 #include "ui/views/controls/combobox/combobox.h" |
| 21 #include "ui/views/controls/combobox/combobox_listener.h" | 22 #include "ui/views/controls/combobox/combobox_listener.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 views::GridLayout* layout) | 240 views::GridLayout* layout) |
| 240 : profile_(profile), icon_(NULL), menu_button_(NULL), combobox_(NULL) { | 241 : profile_(profile), icon_(NULL), menu_button_(NULL), combobox_(NULL) { |
| 241 // Create the permission icon. | 242 // Create the permission icon. |
| 242 icon_ = new NonAccessibleImageView(); | 243 icon_ = new NonAccessibleImageView(); |
| 243 const gfx::Image& image = PageInfoUI::GetPermissionIcon(permission); | 244 const gfx::Image& image = PageInfoUI::GetPermissionIcon(permission); |
| 244 icon_->SetImage(image.ToImageSkia()); | 245 icon_->SetImage(image.ToImageSkia()); |
| 245 layout->AddView(icon_, 1, 1, views::GridLayout::CENTER, | 246 layout->AddView(icon_, 1, 1, views::GridLayout::CENTER, |
| 246 views::GridLayout::CENTER); | 247 views::GridLayout::CENTER); |
| 247 // Create the label that displays the permission type. | 248 // Create the label that displays the permission type. |
| 248 label_ = | 249 label_ = |
| 249 new views::Label(PageInfoUI::PermissionTypeToUIString(permission.type)); | 250 new views::Label(PageInfoUI::PermissionTypeToUIString(permission.type), |
| 251 CONTEXT_BODY_TEXT_LARGE); |
| 250 layout->AddView(label_, 1, 1, views::GridLayout::LEADING, | 252 layout->AddView(label_, 1, 1, views::GridLayout::LEADING, |
| 251 views::GridLayout::CENTER); | 253 views::GridLayout::CENTER); |
| 252 // Create the menu model. | 254 // Create the menu model. |
| 253 menu_model_.reset(new PermissionMenuModel( | 255 menu_model_.reset(new PermissionMenuModel( |
| 254 profile, url, permission, | 256 profile, url, permission, |
| 255 base::Bind(&PermissionSelectorRow::PermissionChanged, | 257 base::Bind(&PermissionSelectorRow::PermissionChanged, |
| 256 base::Unretained(this)))); | 258 base::Unretained(this)))); |
| 257 | 259 |
| 258 // Create the permission menu button. | 260 // Create the permission menu button. |
| 259 #if defined(OS_MACOSX) | 261 #if defined(OS_MACOSX) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 observer.OnPermissionChanged(permission); | 362 observer.OnPermissionChanged(permission); |
| 361 } | 363 } |
| 362 | 364 |
| 363 views::View* PermissionSelectorRow::button() { | 365 views::View* PermissionSelectorRow::button() { |
| 364 // These casts are required because the two arms of a ?: cannot have different | 366 // 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 | 367 // 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. | 368 // and T1 and T2 are both subtypes of T. |
| 367 return menu_button_ ? static_cast<views::View*>(menu_button_) | 369 return menu_button_ ? static_cast<views::View*>(menu_button_) |
| 368 : static_cast<views::View*>(combobox_); | 370 : static_cast<views::View*>(combobox_); |
| 369 } | 371 } |
| OLD | NEW |