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

Side by Side Diff: ash/common/system/chromeos/screen_security/screen_tray_item.cc

Issue 2635103003: [ash-md] Fixed Label::GetTextSize() to account for insets. (Closed)
Patch Set: Added SizeToFit() example use. Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/controls/label.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/screen_security/screen_tray_item.h" 5 #include "ash/common/system/chromeos/screen_security/screen_tray_item.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/shelf/wm_shelf_util.h" 8 #include "ash/common/shelf/wm_shelf_util.h"
9 #include "ash/common/system/tray/fixed_sized_image_view.h" 9 #include "ash/common/system/tray/fixed_sized_image_view.h"
10 #include "ash/common/system/tray/tray_constants.h" 10 #include "ash/common/system/tray/tray_constants.h"
11 #include "ash/common/system/tray/tray_popup_item_style.h" 11 #include "ash/common/system/tray/tray_popup_item_style.h"
12 #include "ash/common/system/tray/tray_popup_utils.h" 12 #include "ash/common/system/tray/tray_popup_utils.h"
13 #include "ash/resources/vector_icons/vector_icons.h" 13 #include "ash/resources/vector_icons/vector_icons.h"
14 #include "grit/ash_resources.h" 14 #include "grit/ash_resources.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/paint_vector_icon.h" 16 #include "ui/gfx/paint_vector_icon.h"
17 #include "ui/message_center/message_center.h" 17 #include "ui/message_center/message_center.h"
18 #include "ui/views/controls/button/label_button.h" 18 #include "ui/views/controls/button/label_button.h"
19 #include "ui/views/controls/label.h" 19 #include "ui/views/controls/label.h"
20 #include "ui/views/layout/fill_layout.h" 20 #include "ui/views/layout/fill_layout.h"
21 21
22 #include "base/strings/utf_string_conversions.h"
23
22 namespace ash { 24 namespace ash {
23 namespace tray { 25 namespace tray {
24 26
25 // ScreenTrayView implementations. 27 // ScreenTrayView implementations.
26 ScreenTrayView::ScreenTrayView(ScreenTrayItem* screen_tray_item) 28 ScreenTrayView::ScreenTrayView(ScreenTrayItem* screen_tray_item)
27 : TrayItemView(screen_tray_item), screen_tray_item_(screen_tray_item) { 29 : TrayItemView(screen_tray_item), screen_tray_item_(screen_tray_item) {
28 CreateImageView(); 30 CreateImageView();
29 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { 31 if (MaterialDesignController::UseMaterialDesignSystemIcons()) {
30 image_view()->SetImage( 32 image_view()->SetImage(
31 gfx::CreateVectorIcon(kSystemTrayScreenShareIcon, kTrayIconColor)); 33 gfx::CreateVectorIcon(kSystemTrayScreenShareIcon, kTrayIconColor));
32 } else { 34 } else {
33 image_view()->SetImage(ui::ResourceBundle::GetSharedInstance() 35 image_view()->SetImage(ui::ResourceBundle::GetSharedInstance()
34 .GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE) 36 .GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE)
35 .ToImageSkia()); 37 .ToImageSkia());
36 } 38 }
37 Update(); 39 Update();
38 } 40 }
39 41
40 ScreenTrayView::~ScreenTrayView() {} 42 ScreenTrayView::~ScreenTrayView() {}
41 43
42 void ScreenTrayView::Update() { 44 void ScreenTrayView::Update() {
43 SetVisible(screen_tray_item_->is_started()); 45 SetVisible(screen_tray_item_->is_started());
46 SetVisible(true);
44 } 47 }
45 48
46 // ScreenStatusView implementations. 49 // ScreenStatusView implementations.
47 ScreenStatusView::ScreenStatusView(ScreenTrayItem* screen_tray_item, 50 ScreenStatusView::ScreenStatusView(ScreenTrayItem* screen_tray_item,
48 const base::string16& label_text, 51 const base::string16& label_text,
49 const base::string16& stop_button_text) 52 const base::string16& stop_button_text)
50 : screen_tray_item_(screen_tray_item), 53 : screen_tray_item_(screen_tray_item),
51 icon_(nullptr), 54 icon_(nullptr),
52 label_(nullptr), 55 label_(nullptr),
53 stop_button_(nullptr), 56 stop_button_(nullptr),
54 label_text_(label_text), 57 label_text_(label_text),
55 stop_button_text_(stop_button_text) { 58 stop_button_text_(stop_button_text) {
59 label_text_ = base::ASCIIToUTF16(
60 "Google Hangouts is sharing a window with hangouts.google.com. Google "
61 "Hangouts is sharing a window with hangouts.google.com. Google Hangouts "
62 "is sharing a window with hangouts.google.com. Google Hangouts is "
63 "sharing a window with hangouts.google.com.");
56 CreateItems(); 64 CreateItems();
57 TriView* tri_view(TrayPopupUtils::CreateDefaultRowView()); 65 TriView* tri_view(TrayPopupUtils::CreateDefaultRowView());
58 SetLayoutManager(new views::FillLayout); 66 SetLayoutManager(new views::FillLayout);
59 AddChildView(tri_view); 67 AddChildView(tri_view);
60 tri_view->AddView(TriView::Container::START, icon_); 68 tri_view->AddView(TriView::Container::START, icon_);
61 tri_view->AddView(TriView::Container::CENTER, label_); 69 tri_view->AddView(TriView::Container::CENTER, label_);
62 tri_view->AddView(TriView::Container::END, stop_button_); 70 tri_view->AddView(TriView::Container::END, stop_button_);
63 tri_view->SetContainerBorder( 71 tri_view->SetContainerBorder(
64 TriView::Container::END, 72 TriView::Container::END,
65 views::CreateEmptyBorder(0, 0, 0, kTrayPopupButtonEndMargin)); 73 views::CreateEmptyBorder(0, 0, 0, kTrayPopupButtonEndMargin));
66 if (screen_tray_item_) 74 if (screen_tray_item_)
67 UpdateFromScreenTrayItem(); 75 UpdateFromScreenTrayItem();
76 label_->SizeToFit(225);
68 } 77 }
69 78
70 ScreenStatusView::~ScreenStatusView() {} 79 ScreenStatusView::~ScreenStatusView() {}
71 80
72 void ScreenStatusView::ButtonPressed(views::Button* sender, 81 void ScreenStatusView::ButtonPressed(views::Button* sender,
73 const ui::Event& event) { 82 const ui::Event& event) {
74 DCHECK(sender == stop_button_); 83 DCHECK(sender == stop_button_);
75 screen_tray_item_->Stop(); 84 screen_tray_item_->Stop();
76 screen_tray_item_->RecordStoppedFromDefaultViewMetric(); 85 screen_tray_item_->RecordStoppedFromDefaultViewMetric();
77 } 86 }
(...skipping 15 matching lines...) Expand all
93 label_->SetMultiLine(true); 102 label_->SetMultiLine(true);
94 label_->SetText(label_text_); 103 label_->SetText(label_text_);
95 104
96 stop_button_ = TrayPopupUtils::CreateTrayPopupButton(this, stop_button_text_); 105 stop_button_ = TrayPopupUtils::CreateTrayPopupButton(this, stop_button_text_);
97 } 106 }
98 107
99 void ScreenStatusView::UpdateFromScreenTrayItem() { 108 void ScreenStatusView::UpdateFromScreenTrayItem() {
100 // Hide the notification bubble when the ash tray bubble opens. 109 // Hide the notification bubble when the ash tray bubble opens.
101 screen_tray_item_->HideNotificationView(); 110 screen_tray_item_->HideNotificationView();
102 SetVisible(screen_tray_item_->is_started()); 111 SetVisible(screen_tray_item_->is_started());
112 SetVisible(true);
103 } 113 }
104 114
105 void ScreenStatusView::OnNativeThemeChanged(const ui::NativeTheme* theme) { 115 void ScreenStatusView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
106 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { 116 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) {
107 views::View::OnNativeThemeChanged(theme); 117 views::View::OnNativeThemeChanged(theme);
108 return; 118 return;
109 } 119 }
110 120
111 if (theme) { 121 if (theme) {
112 TrayPopupItemStyle style(theme, 122 TrayPopupItemStyle style(theme,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 200
191 void ScreenTrayItem::DestroyTrayView() { 201 void ScreenTrayItem::DestroyTrayView() {
192 tray_view_ = nullptr; 202 tray_view_ = nullptr;
193 } 203 }
194 204
195 void ScreenTrayItem::DestroyDefaultView() { 205 void ScreenTrayItem::DestroyDefaultView() {
196 default_view_ = nullptr; 206 default_view_ = nullptr;
197 } 207 }
198 208
199 } // namespace ash 209 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698