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

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: Overhaul of previous implementation 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.
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/shell.h"
8 #include "ash/strings/grit/ash_strings.h" 9 #include "ash/strings/grit/ash_strings.h"
9 #include "ash/system/tray/hover_highlight_view.h" 10 #include "ash/system/tray/hover_highlight_view.h"
10 #include "ash/system/tray/system_menu_button.h" 11 #include "ash/system/tray/system_menu_button.h"
11 #include "ash/system/tray/system_tray.h" 12 #include "ash/system/tray/system_tray.h"
13 #include "ash/system/tray/system_tray_controller.h"
12 #include "ash/system/tray/system_tray_item.h" 14 #include "ash/system/tray/system_tray_item.h"
13 #include "ash/system/tray/tray_constants.h" 15 #include "ash/system/tray/tray_constants.h"
14 #include "ash/system/tray/tray_popup_item_style.h" 16 #include "ash/system/tray/tray_popup_item_style.h"
15 #include "ash/system/tray/tray_popup_utils.h" 17 #include "ash/system/tray/tray_popup_utils.h"
16 #include "ash/system/tray/tri_view.h" 18 #include "ash/system/tray/tri_view.h"
17 #include "base/containers/adapters.h" 19 #include "base/containers/adapters.h"
18 #include "base/memory/ptr_util.h" 20 #include "base/memory/ptr_util.h"
19 #include "third_party/skia/include/core/SkDrawLooper.h" 21 #include "third_party/skia/include/core/SkDrawLooper.h"
20 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 const int kTitleRowProgressBarHeight = 2; 235 const int kTitleRowProgressBarHeight = 2;
234 const int kTitleRowPaddingTop = kTitleRowVerticalPadding; 236 const int kTitleRowPaddingTop = kTitleRowVerticalPadding;
235 const int kTitleRowPaddingBottom = 237 const int kTitleRowPaddingBottom =
236 kTitleRowVerticalPadding - kTitleRowProgressBarHeight; 238 kTitleRowVerticalPadding - kTitleRowProgressBarHeight;
237 239
238 } // namespace 240 } // namespace
239 241
240 //////////////////////////////////////////////////////////////////////////////// 242 ////////////////////////////////////////////////////////////////////////////////
241 // TrayDetailsView::InfoLabel: 243 // TrayDetailsView::InfoLabel:
242 244
243 TrayDetailsView::InfoLabel::InfoLabel(int message_id) 245 TrayDetailsView::InfoLabel::InfoLabel(int message_id) {
Kyle Horimoto 2017/07/07 17:33:59 Nothing is actually done with |message_id|.
lesliewatkins 2017/07/09 00:57:47 Acknowledged.
244 : label_(TrayPopupUtils::CreateDefaultLabel()) {
245 SetLayoutManager(new views::FillLayout); 246 SetLayoutManager(new views::FillLayout);
247 }
246 248
247 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SYSTEM_INFO); 249 ////////////////////////////////////////////////////////////////////////////////
248 style.SetupLabel(label_); 250 // TrayDetailsView::InfoLabelNoAction:
249 251
252 TrayDetailsView::InfoLabelNoAction::InfoLabelNoAction(int message_id)
253 : TrayDetailsView::InfoLabel(message_id),
254 label_(TrayPopupUtils::CreateDefaultLabel()) {
250 TriView* tri_view = TrayPopupUtils::CreateMultiTargetRowView(); 255 TriView* tri_view = TrayPopupUtils::CreateMultiTargetRowView();
251 tri_view->SetInsets(gfx::Insets(0, 256 tri_view->SetInsets(gfx::Insets(0,
252 kMenuExtraMarginFromLeftEdge + 257 kMenuExtraMarginFromLeftEdge +
253 kTrayPopupPaddingHorizontal - 258 kTrayPopupPaddingHorizontal -
254 kTrayPopupLabelHorizontalPadding, 259 kTrayPopupLabelHorizontalPadding,
255 0, kTrayPopupPaddingHorizontal)); 260 0, kTrayPopupPaddingHorizontal));
256 tri_view->SetContainerVisible(TriView::Container::START, false); 261 tri_view->SetContainerVisible(TriView::Container::START, false);
257 tri_view->SetContainerVisible(TriView::Container::END, false); 262 tri_view->SetContainerVisible(TriView::Container::END, false);
258 tri_view->AddView(TriView::Container::CENTER, label_); 263 tri_view->AddView(TriView::Container::CENTER, label_);
264
259 AddChildView(tri_view); 265 AddChildView(tri_view);
260 266
267 TrayPopupItemStyle::FontStyle font_style =
268 TrayPopupItemStyle::FontStyle::SYSTEM_INFO;
269
270 TrayPopupItemStyle style(font_style);
271 style.SetupLabel(label_);
272
261 SetMessage(message_id); 273 SetMessage(message_id);
262 } 274 }
263 275
264 TrayDetailsView::InfoLabel::~InfoLabel() {} 276 void TrayDetailsView::InfoLabelNoAction::SetMessage(int message_id) {
277 label_->SetText(l10n_util::GetStringUTF16(message_id));
278 }
265 279
266 void TrayDetailsView::InfoLabel::SetMessage(int message_id) { 280 ////////////////////////////////////////////////////////////////////////////////
267 label_->SetText(l10n_util::GetStringUTF16(message_id)); 281 // TrayDetailsView::BluetoothInfoLabel:
282
283 TrayDetailsView::InfoLabelEnableBluetooth::InfoLabelEnableBluetooth(
284 int message_id)
285 : TrayDetailsView::InfoLabel(message_id),
286 label_button_(
287 new views::LabelButton(this, l10n_util::GetStringUTF16(message_id))) {
288 TriView* tri_view = TrayPopupUtils::CreateMultiTargetRowView();
Kyle Horimoto 2017/07/07 17:33:59 AFAICT, this is the same code as in the label clas
289 tri_view->SetInsets(gfx::Insets(0,
290 kMenuExtraMarginFromLeftEdge +
291 kTrayPopupPaddingHorizontal -
292 kTrayPopupLabelHorizontalPadding,
293 0, kTrayPopupPaddingHorizontal));
294 tri_view->SetContainerVisible(TriView::Container::START, false);
295 tri_view->SetContainerVisible(TriView::Container::END, false);
296 tri_view->AddView(TriView::Container::CENTER, label_button_);
297
298 AddChildView(tri_view);
299
300 label_button_->SetEnabledTextColors(
301 label_button_->GetNativeTheme()->GetSystemColor(
302 ui::NativeTheme::kColorId_ProminentButtonColor));
303 label_button_->SetInkDropMode(views::InkDropHostView::InkDropMode::ON);
304 label_button_->set_ink_drop_base_color(kTrayPopupInkDropBaseColor);
305
306 SetMessage(message_id);
307 }
308
309 void TrayDetailsView::InfoLabelEnableBluetooth::SetMessage(int message_id) {
310 label_button_->SetText(l10n_util::GetStringUTF16(message_id));
311 }
312
313 void TrayDetailsView::InfoLabelEnableBluetooth::ButtonPressed(
314 views::Button* button,
315 const ui::Event& event) {
316 Shell::Get()->system_tray_controller()->ShowBluetoothSettings();
268 } 317 }
269 318
270 //////////////////////////////////////////////////////////////////////////////// 319 ////////////////////////////////////////////////////////////////////////////////
271 // TrayDetailsView: 320 // TrayDetailsView:
272 321
322 TrayDetailsView::InfoLabel* TrayDetailsView::CreateInfoLabel(int message_id) {
323 if (message_id == IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH)
324 return new InfoLabelEnableBluetooth(message_id);
325
326 return new InfoLabelNoAction(message_id);
327 }
328
273 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) 329 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner)
274 : owner_(owner), 330 : owner_(owner),
275 box_layout_(new views::BoxLayout(views::BoxLayout::kVertical)), 331 box_layout_(new views::BoxLayout(views::BoxLayout::kVertical)),
276 scroller_(nullptr), 332 scroller_(nullptr),
277 scroll_content_(nullptr), 333 scroll_content_(nullptr),
278 progress_bar_(nullptr), 334 progress_bar_(nullptr),
279 tri_view_(nullptr), 335 tri_view_(nullptr),
280 back_button_(nullptr) { 336 back_button_(nullptr) {
281 SetLayoutManager(box_layout_); 337 SetLayoutManager(box_layout_);
282 SetBackground(views::CreateThemedSolidBackground( 338 SetBackground(views::CreateThemedSolidBackground(
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (bounds().IsEmpty()) 557 if (bounds().IsEmpty())
502 return views::View::GetHeightForWidth(width); 558 return views::View::GetHeightForWidth(width);
503 559
504 // The height of the bubble that contains this detailed view is set to 560 // 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 561 // the preferred height of the default view, and that determines the
506 // initial height of |this|. Always request to stay the same height. 562 // initial height of |this|. Always request to stay the same height.
507 return height(); 563 return height();
508 } 564 }
509 565
510 } // namespace ash 566 } // namespace ash
OLDNEW
« ash/system/tray/tray_details_view.h ('K') | « ash/system/tray/tray_details_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698