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

Side by Side Diff: ash/system/tray/tray_details_view.cc

Issue 2957043002: Add a row in the network tray to inform users to turn Bluetooth on to enable Tether. (Closed)
Patch Set: tdanderson@ and khorimoto@ comments Created 3 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
Kyle Horimoto 2017/07/10 18:37:08 Please add a test for your clickable label in tray
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/system/tray/tray_details_view.h" 5 #include "ash/system/tray/tray_details_view.h"
6 6
7 #include "ash/ash_view_ids.h" 7 #include "ash/ash_view_ids.h"
8 #include "ash/strings/grit/ash_strings.h" 8 #include "ash/strings/grit/ash_strings.h"
9 #include "ash/system/tray/hover_highlight_view.h" 9 #include "ash/system/tray/hover_highlight_view.h"
10 #include "ash/system/tray/system_menu_button.h" 10 #include "ash/system/tray/system_menu_button.h"
11 #include "ash/system/tray/system_tray.h" 11 #include "ash/system/tray/system_tray.h"
12 #include "ash/system/tray/system_tray_item.h" 12 #include "ash/system/tray/system_tray_item.h"
13 #include "ash/system/tray/tray_constants.h" 13 #include "ash/system/tray/tray_constants.h"
14 #include "ash/system/tray/tray_popup_item_style.h" 14 #include "ash/system/tray/tray_popup_item_style.h"
15 #include "ash/system/tray/tray_popup_utils.h" 15 #include "ash/system/tray/tray_popup_utils.h"
16 #include "ash/system/tray/tri_view.h" 16 #include "ash/system/tray/tri_view.h"
17 #include "base/containers/adapters.h" 17 #include "base/containers/adapters.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "third_party/skia/include/core/SkDrawLooper.h" 19 #include "third_party/skia/include/core/SkDrawLooper.h"
20 #include "ui/accessibility/ax_node_data.h"
20 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/compositor/paint_context.h" 23 #include "ui/compositor/paint_context.h"
23 #include "ui/compositor/paint_recorder.h" 24 #include "ui/compositor/paint_recorder.h"
24 #include "ui/gfx/canvas.h" 25 #include "ui/gfx/canvas.h"
25 #include "ui/gfx/geometry/insets.h" 26 #include "ui/gfx/geometry/insets.h"
26 #include "ui/gfx/image/image_skia.h" 27 #include "ui/gfx/image/image_skia.h"
27 #include "ui/gfx/paint_vector_icon.h" 28 #include "ui/gfx/paint_vector_icon.h"
28 #include "ui/gfx/skia_paint_util.h" 29 #include "ui/gfx/skia_paint_util.h"
29 #include "ui/gfx/vector_icon_types.h" 30 #include "ui/gfx/vector_icon_types.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 const int kTitleRowProgressBarHeight = 2; 234 const int kTitleRowProgressBarHeight = 2;
234 const int kTitleRowPaddingTop = kTitleRowVerticalPadding; 235 const int kTitleRowPaddingTop = kTitleRowVerticalPadding;
235 const int kTitleRowPaddingBottom = 236 const int kTitleRowPaddingBottom =
236 kTitleRowVerticalPadding - kTitleRowProgressBarHeight; 237 kTitleRowVerticalPadding - kTitleRowProgressBarHeight;
237 238
238 } // namespace 239 } // namespace
239 240
240 //////////////////////////////////////////////////////////////////////////////// 241 ////////////////////////////////////////////////////////////////////////////////
241 // TrayDetailsView::InfoLabel: 242 // TrayDetailsView::InfoLabel:
242 243
243 TrayDetailsView::InfoLabel::InfoLabel(int message_id) 244 TrayDetailsView::InfoLabel::InfoLabel(int message_id,
244 : label_(TrayPopupUtils::CreateDefaultLabel()) { 245 InfoLabelDelegate* delegate)
246 : ActionableView(nullptr /*owner*/, TrayPopupInkDropStyle::FILL_BOUNDS),
247 label_(TrayPopupUtils::CreateDefaultLabel()),
248 message_id_(message_id),
249 delegate_(delegate) {
245 SetLayoutManager(new views::FillLayout); 250 SetLayoutManager(new views::FillLayout);
246 251
247 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SYSTEM_INFO);
248 style.SetupLabel(label_);
249
250 TriView* tri_view = TrayPopupUtils::CreateMultiTargetRowView(); 252 TriView* tri_view = TrayPopupUtils::CreateMultiTargetRowView();
251 tri_view->SetInsets(gfx::Insets(0, 253 tri_view->SetInsets(gfx::Insets(0,
252 kMenuExtraMarginFromLeftEdge + 254 kMenuExtraMarginFromLeftEdge +
253 kTrayPopupPaddingHorizontal - 255 kTrayPopupPaddingHorizontal -
254 kTrayPopupLabelHorizontalPadding, 256 kTrayPopupLabelHorizontalPadding,
255 0, kTrayPopupPaddingHorizontal)); 257 0, kTrayPopupPaddingHorizontal));
256 tri_view->SetContainerVisible(TriView::Container::START, false); 258 tri_view->SetContainerVisible(TriView::Container::START, false);
257 tri_view->SetContainerVisible(TriView::Container::END, false); 259 tri_view->SetContainerVisible(TriView::Container::END, false);
258 tri_view->AddView(TriView::Container::CENTER, label_); 260 tri_view->AddView(TriView::Container::CENTER, label_);
261
259 AddChildView(tri_view); 262 AddChildView(tri_view);
260 263
261 SetMessage(message_id); 264 Update(message_id);
262 } 265 }
263 266
264 TrayDetailsView::InfoLabel::~InfoLabel() {} 267 void TrayDetailsView::InfoLabel::Update(int message_id) {
268 message_id_ = message_id;
265 269
266 void TrayDetailsView::InfoLabel::SetMessage(int message_id) { 270 TrayPopupItemStyle::FontStyle font_style;
Kyle Horimoto 2017/07/10 18:37:08 nit: Use a reference: TrayPopupItemStyle::FontSty
lesliewatkins 2017/07/12 21:49:50 This gives a compiler error-- references have to b
271
272 if (IsClickable()) {
273 SetInkDropMode(InkDropHostView::InkDropMode::ON);
274 font_style = TrayPopupItemStyle::FontStyle::CLICKABLE_SYSTEM_INFO;
275 } else {
276 SetInkDropMode(InkDropHostView::InkDropMode::OFF);
277 font_style = TrayPopupItemStyle::FontStyle::SYSTEM_INFO;
278 }
279
280 TrayPopupItemStyle style(font_style);
Kyle Horimoto 2017/07/10 18:37:07 nit: Use const: const TrayPopupItemStyle style(fo
lesliewatkins 2017/07/12 21:49:50 Done.
281 style.SetupLabel(label_);
282
267 label_->SetText(l10n_util::GetStringUTF16(message_id)); 283 label_->SetText(l10n_util::GetStringUTF16(message_id));
268 } 284 }
269 285
286 bool TrayDetailsView::InfoLabel::PerformAction(const ui::Event& event) {
287 if (delegate_)
Kyle Horimoto 2017/07/10 18:37:08 nit: if (delegate_), DCHECK(IsClickable())
lesliewatkins 2017/07/12 21:49:50 Just because it has a delegate doesn't mean it's c
288 delegate_->OnLabelClicked(this);
Kyle Horimoto 2017/07/10 18:37:07 /* parameter_name */
lesliewatkins 2017/07/12 21:49:50 Done.
289 return true;
290 }
291
292 void TrayDetailsView::InfoLabel::GetAccessibleNodeData(
293 ui::AXNodeData* node_data) {
294 if (IsClickable())
295 node_data->role = ui::AX_ROLE_BUTTON;
296 else
297 node_data->role = ui::AX_ROLE_LABEL_TEXT;
298 }
299
300 const int& TrayDetailsView::InfoLabel::message_id() {
301 return message_id_;
302 }
303
304 bool TrayDetailsView::InfoLabel::IsClickable() {
James Cook 2017/07/10 18:43:03 This seems like it should be a delegate method. In
lesliewatkins 2017/07/12 21:49:50 I just had this call delegate_->IsClickable(messag
305 return message_id() == IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH;
306 }
307
270 //////////////////////////////////////////////////////////////////////////////// 308 ////////////////////////////////////////////////////////////////////////////////
271 // TrayDetailsView: 309 // TrayDetailsView:
272 310
273 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) 311 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner)
274 : owner_(owner), 312 : owner_(owner),
275 box_layout_(new views::BoxLayout(views::BoxLayout::kVertical)), 313 box_layout_(new views::BoxLayout(views::BoxLayout::kVertical)),
276 scroller_(nullptr), 314 scroller_(nullptr),
277 scroll_content_(nullptr), 315 scroll_content_(nullptr),
278 progress_bar_(nullptr), 316 progress_bar_(nullptr),
279 tri_view_(nullptr), 317 tri_view_(nullptr),
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (bounds().IsEmpty()) 539 if (bounds().IsEmpty())
502 return views::View::GetHeightForWidth(width); 540 return views::View::GetHeightForWidth(width);
503 541
504 // The height of the bubble that contains this detailed view is set to 542 // The height of the bubble that contains this detailed view is set to
505 // the preferred height of the default view, and that determines the 543 // the preferred height of the default view, and that determines the
506 // initial height of |this|. Always request to stay the same height. 544 // initial height of |this|. Always request to stay the same height.
507 return height(); 545 return height();
508 } 546 }
509 547
510 } // namespace ash 548 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698