Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: ash/common/system/tray/label_tray_view.cc

Issue 2715463004: Remove non-MD code from LabelTrayView (Closed)
Patch Set: estade comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/tray/label_tray_view.h ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/label_tray_view.cc
diff --git a/ash/common/system/tray/label_tray_view.cc b/ash/common/system/tray/label_tray_view.cc
index 0f2c94305b2fc8fe4a68334b7e2543bd46598cb6..0c9e4dcdf87dc09be40ae893940e21ccfc36df46 100644
--- a/ash/common/system/tray/label_tray_view.cc
+++ b/ash/common/system/tray/label_tray_view.cc
@@ -4,48 +4,21 @@
#include "ash/common/system/tray/label_tray_view.h"
-#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/system/tray/hover_highlight_view.h"
#include "ash/common/system/tray/tray_constants.h"
#include "ash/common/system/tray/view_click_listener.h"
#include "ash/resources/grit/ash_resources.h"
#include "ash/resources/vector_icons/vector_icons.h"
-#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/font.h"
#include "ui/gfx/paint_vector_icon.h"
-#include "ui/views/border.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
namespace ash {
-namespace {
-
-// Maps a non-MD PNG resource id to its corresponding MD vector icon.
-// TODO(tdanderson): Remove this once material design is enabled by
-// default. See crbug.com/614453.
-const gfx::VectorIcon& ResourceIdToVectorIcon(int resource_id) {
- switch (resource_id) {
- case IDR_AURA_UBER_TRAY_ENTERPRISE:
- return kSystemMenuBusinessIcon;
- case IDR_AURA_UBER_TRAY_BUBBLE_SESSION_LENGTH_LIMIT:
- return kSystemMenuTimerIcon;
- case IDR_AURA_UBER_TRAY_CHILD_USER:
- return kSystemMenuChildUserIcon;
- case IDR_AURA_UBER_TRAY_SUPERVISED_USER:
- return kSystemMenuSupervisedUserIcon;
- default:
- NOTREACHED();
- break;
- }
- return gfx::kNoneIcon;
-}
-
-} // namespace
-
LabelTrayView::LabelTrayView(ViewClickListener* click_listener,
- int icon_resource_id)
- : click_listener_(click_listener), icon_resource_id_(icon_resource_id) {
+ const gfx::VectorIcon& icon)
+ : click_listener_(click_listener), icon_(icon) {
SetLayoutManager(new views::FillLayout());
SetVisible(false);
}
@@ -70,26 +43,10 @@ void LabelTrayView::SetMessage(const base::string16& message) {
views::View* LabelTrayView::CreateChildView(
const base::string16& message) const {
HoverHighlightView* child = new HoverHighlightView(click_listener_);
- if (icon_resource_id_) {
- const bool use_md = MaterialDesignController::IsSystemTrayMenuMaterial();
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- gfx::ImageSkia icon =
- use_md ? gfx::CreateVectorIcon(
- ResourceIdToVectorIcon(icon_resource_id_), kMenuIconColor)
- : *rb.GetImageSkiaNamed(icon_resource_id_);
- child->AddIconAndLabelForDefaultView(icon, message, false /* highlight */);
- child->text_label()->SetMultiLine(true);
- if (!use_md) {
- child->SetBorder(views::CreateEmptyBorder(
- 0, kTrayPopupPaddingHorizontal, 0, kTrayPopupPaddingHorizontal));
- child->text_label()->SizeToFit(kTrayNotificationContentsWidth);
- }
- } else {
- child->AddLabel(message, gfx::ALIGN_LEFT, false /* highlight */);
- child->text_label()->SetMultiLine(true);
- child->text_label()->SizeToFit(kTrayNotificationContentsWidth +
- kNotificationIconWidth);
- }
+ gfx::ImageSkia icon_image = gfx::CreateVectorIcon(icon_, kMenuIconColor);
+ child->AddIconAndLabelForDefaultView(icon_image, message,
+ false /* highlight */);
+ child->text_label()->SetMultiLine(true);
child->text_label()->SetAllowCharacterBreak(true);
child->SetExpandable(true);
child->SetVisible(true);
« no previous file with comments | « ash/common/system/tray/label_tray_view.h ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698