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 "ash/common/system/tray/tray_notification_view.h" | 5 #include "ash/common/system/tray/tray_notification_view.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/system/tray/system_tray_item.h" | 8 #include "ash/common/system/tray/system_tray_item.h" |
| 9 #include "ash/common/system/tray/tray_constants.h" | 9 #include "ash/common/system/tray/tray_constants.h" |
| 10 #include "ash/resources/vector_icons/vector_icons.h" | |
| 10 #include "grit/ash_resources.h" | 11 #include "grit/ash_resources.h" |
| 11 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
| 12 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
| 13 #include "ui/gfx/paint_vector_icon.h" | 14 #include "ui/gfx/paint_vector_icon.h" |
| 14 #include "ui/gfx/vector_icons_public.h" | |
| 15 #include "ui/resources/grit/ui_resources.h" | 15 #include "ui/resources/grit/ui_resources.h" |
| 16 #include "ui/views/background.h" | 16 #include "ui/views/background.h" |
| 17 #include "ui/views/controls/button/image_button.h" | 17 #include "ui/views/controls/button/image_button.h" |
| 18 #include "ui/views/controls/image_view.h" | 18 #include "ui/views/controls/image_view.h" |
| 19 #include "ui/views/layout/grid_layout.h" | 19 #include "ui/views/layout/grid_layout.h" |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Maps a non-MD PNG resource id to its corresponding MD vector icon id. | 25 // Maps a non-MD PNG resource id to its corresponding MD vector icon id. |
|
tdanderson
2016/09/07 22:36:13
same as previous comment
Evan Stade
2016/09/07 22:41:52
Done.
| |
| 26 // TODO(tdanderson): Remove this once material design is enabled by | 26 // TODO(tdanderson): Remove this once material design is enabled by |
| 27 // default. See crbug.com/614453. | 27 // default. See crbug.com/614453. |
| 28 gfx::VectorIconId ResourceIdToVectorIconId(int resource_id) { | 28 const gfx::VectorIcon& ResourceIdToVectorIcon(int resource_id) { |
| 29 gfx::VectorIconId vector_id = gfx::VectorIconId::VECTOR_ICON_NONE; | |
| 30 switch (resource_id) { | 29 switch (resource_id) { |
| 31 case IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK: | 30 case IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK: |
| 32 return gfx::VectorIconId::SYSTEM_MENU_ACCESSIBILITY; | 31 return kSystemMenuAccessibilityIcon; |
| 33 #if defined(OS_CHROMEOS) | 32 #if defined(OS_CHROMEOS) |
| 34 case IDR_AURA_UBER_TRAY_SMS: | 33 case IDR_AURA_UBER_TRAY_SMS: |
| 35 return gfx::VectorIconId::SYSTEM_MENU_SMS; | 34 return kSystemMenuSmsIcon; |
| 36 #endif | 35 #endif |
| 37 default: | 36 default: |
| 38 NOTREACHED(); | 37 NOTREACHED(); |
| 39 break; | 38 break; |
| 40 } | 39 } |
| 41 | 40 |
| 42 return vector_id; | 41 return gfx::kNoneIcon; |
| 43 } | 42 } |
| 44 | 43 |
| 45 } // namespace | 44 } // namespace |
| 46 | 45 |
| 47 TrayNotificationView::TrayNotificationView(SystemTrayItem* owner, int icon_id) | 46 TrayNotificationView::TrayNotificationView(SystemTrayItem* owner, int icon_id) |
| 48 : owner_(owner), icon_id_(icon_id), icon_(NULL), autoclose_delay_(0) {} | 47 : owner_(owner), icon_id_(icon_id), icon_(NULL), autoclose_delay_(0) {} |
| 49 | 48 |
| 50 TrayNotificationView::~TrayNotificationView() {} | 49 TrayNotificationView::~TrayNotificationView() {} |
| 51 | 50 |
| 52 void TrayNotificationView::InitView(views::View* contents) { | 51 void TrayNotificationView::InitView(views::View* contents) { |
| 53 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | 52 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
| 54 | 53 |
| 55 views::GridLayout* layout = new views::GridLayout(this); | 54 views::GridLayout* layout = new views::GridLayout(this); |
| 56 SetLayoutManager(layout); | 55 SetLayoutManager(layout); |
| 57 | 56 |
| 58 views::ImageButton* close_button = new views::ImageButton(this); | 57 views::ImageButton* close_button = new views::ImageButton(this); |
| 59 close_button->SetImage( | 58 close_button->SetImage( |
| 60 views::CustomButton::STATE_NORMAL, | 59 views::CustomButton::STATE_NORMAL, |
| 61 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); | 60 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); |
| 62 close_button->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 61 close_button->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 63 views::ImageButton::ALIGN_MIDDLE); | 62 views::ImageButton::ALIGN_MIDDLE); |
| 64 | 63 |
| 65 icon_ = new views::ImageView; | 64 icon_ = new views::ImageView; |
| 66 if (icon_id_ != 0) { | 65 if (icon_id_ != 0) { |
| 67 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { | 66 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { |
| 68 icon_->SetImage(gfx::CreateVectorIcon(ResourceIdToVectorIconId(icon_id_), | 67 icon_->SetImage(gfx::CreateVectorIcon(ResourceIdToVectorIcon(icon_id_), |
| 69 kMenuIconColor)); | 68 kMenuIconColor)); |
| 70 } else { | 69 } else { |
| 71 icon_->SetImage( | 70 icon_->SetImage( |
| 72 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id_)); | 71 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id_)); |
| 73 } | 72 } |
| 74 } | 73 } |
| 75 | 74 |
| 76 views::ColumnSet* columns = layout->AddColumnSet(0); | 75 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 77 | 76 |
| 78 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); | 77 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 OnClose(); | 165 OnClose(); |
| 167 owner_->HideNotificationView(); | 166 owner_->HideNotificationView(); |
| 168 } | 167 } |
| 169 | 168 |
| 170 void TrayNotificationView::HandleClickAction() { | 169 void TrayNotificationView::HandleClickAction() { |
| 171 HandleClose(); | 170 HandleClose(); |
| 172 OnClickAction(); | 171 OnClickAction(); |
| 173 } | 172 } |
| 174 | 173 |
| 175 } // namespace ash | 174 } // namespace ash |
| OLD | NEW |