| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/media_gallery_checkbox_view.h" | 5 #include "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 7 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
| 8 #include "chrome/grit/generated_resources.h" | 8 #include "chrome/grit/generated_resources.h" |
| 9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
| 10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 15 #include "ui/views/context_menu_controller.h" | 15 #include "ui/views/context_menu_controller.h" |
| 16 #include "ui/views/controls/button/button.h" | 16 #include "ui/views/controls/button/button.h" |
| 17 #include "ui/views/controls/button/checkbox.h" | 17 #include "ui/views/controls/button/checkbox.h" |
| 18 #include "ui/views/controls/button/image_button.h" | 18 #include "ui/views/controls/button/image_button.h" |
| 19 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 20 #include "ui/views/layout/box_layout.h" | 20 #include "ui/views/layout/box_layout.h" |
| 21 #include "ui/views/layout/layout_constants.h" | 21 #include "ui/views/layout/layout_constants.h" |
| 22 #include "ui/views/style/platform_style.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Equal to the #9F9F9F color used in spec (note WebUI color is #999). | 26 // Equal to the #9F9F9F color used in spec (note WebUI color is #999). |
| 26 const SkColor kDeemphasizedTextColor = SkColorSetRGB(159, 159, 159); | 27 const SkColor kDeemphasizedTextColor = SkColorSetRGB(159, 159, 159); |
| 27 | 28 |
| 28 } // namespace | 29 } // namespace |
| 29 | 30 |
| 30 MediaGalleryCheckboxView::MediaGalleryCheckboxView( | 31 MediaGalleryCheckboxView::MediaGalleryCheckboxView( |
| 31 const MediaGalleryPrefInfo& pref_info, | 32 const MediaGalleryPrefInfo& pref_info, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 53 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 54 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 54 folder_viewer_button_ = new views::ImageButton(button_listener); | 55 folder_viewer_button_ = new views::ImageButton(button_listener); |
| 55 if (menu_controller) | 56 if (menu_controller) |
| 56 folder_viewer_button_->set_context_menu_controller(menu_controller); | 57 folder_viewer_button_->set_context_menu_controller(menu_controller); |
| 57 folder_viewer_button_->SetImage(views::ImageButton::STATE_NORMAL, | 58 folder_viewer_button_->SetImage(views::ImageButton::STATE_NORMAL, |
| 58 rb.GetImageSkiaNamed(IDR_FILE_FOLDER)); | 59 rb.GetImageSkiaNamed(IDR_FILE_FOLDER)); |
| 59 folder_viewer_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 60 folder_viewer_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 60 views::ImageButton::ALIGN_MIDDLE); | 61 views::ImageButton::ALIGN_MIDDLE); |
| 61 folder_viewer_button_->SetAccessibleName(l10n_util::GetStringUTF16( | 62 folder_viewer_button_->SetAccessibleName(l10n_util::GetStringUTF16( |
| 62 IDS_MEDIA_GALLERIES_SCAN_RESULT_OPEN_FOLDER_VIEW_ACCESSIBILITY_NAME)); | 63 IDS_MEDIA_GALLERIES_SCAN_RESULT_OPEN_FOLDER_VIEW_ACCESSIBILITY_NAME)); |
| 63 folder_viewer_button_->SetFocusable(true); | 64 views::PlatformStyle::SetControlStyleFocus(folder_viewer_button_); |
| 64 folder_viewer_button_->SetVisible(show_folder_button); | 65 folder_viewer_button_->SetVisible(show_folder_button); |
| 65 folder_viewer_button_->SetBorder(views::Border::CreateEmptyBorder( | 66 folder_viewer_button_->SetBorder(views::Border::CreateEmptyBorder( |
| 66 0, views::kRelatedControlSmallHorizontalSpacing, 0, 0)); | 67 0, views::kRelatedControlSmallHorizontalSpacing, 0, 0)); |
| 67 | 68 |
| 68 base::string16 details = pref_info.GetGalleryAdditionalDetails(); | 69 base::string16 details = pref_info.GetGalleryAdditionalDetails(); |
| 69 secondary_text_ = new views::Label(details); | 70 secondary_text_ = new views::Label(details); |
| 70 if (menu_controller) | 71 if (menu_controller) |
| 71 secondary_text_->set_context_menu_controller(menu_controller); | 72 secondary_text_->set_context_menu_controller(menu_controller); |
| 72 secondary_text_->SetVisible(details.length() > 0); | 73 secondary_text_->SetVisible(details.length() > 0); |
| 73 secondary_text_->SetEnabledColor(kDeemphasizedTextColor); | 74 secondary_text_->SetEnabledColor(kDeemphasizedTextColor); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 if (folder_viewer_button_->visible()) { | 114 if (folder_viewer_button_->visible()) { |
| 114 folder_viewer_button_->SetBounds(checkbox_->x() + checkbox_width, area.y(), | 115 folder_viewer_button_->SetBounds(checkbox_->x() + checkbox_width, area.y(), |
| 115 folder_viewer_width, area.height()); | 116 folder_viewer_width, area.height()); |
| 116 } | 117 } |
| 117 if (secondary_text_->visible()) { | 118 if (secondary_text_->visible()) { |
| 118 secondary_text_->SetBounds( | 119 secondary_text_->SetBounds( |
| 119 checkbox_->x() + checkbox_width + folder_viewer_width, | 120 checkbox_->x() + checkbox_width + folder_viewer_width, |
| 120 area.y(), secondary_text_width, area.height()); | 121 area.y(), secondary_text_width, area.height()); |
| 121 } | 122 } |
| 122 } | 123 } |
| OLD | NEW |