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

Side by Side Diff: ash/common/system/date/system_info_default_view.cc

Issue 2591553002: Remove non-cros support from ash/common/system. (Closed)
Patch Set: Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/date/system_info_default_view.h" 5 #include "ash/common/system/date/system_info_default_view.h"
6 6
7 #include "ash/common/system/chromeos/power/power_status.h"
8 #include "ash/common/system/chromeos/power/power_status_view.h"
7 #include "ash/common/system/date/date_view.h" 9 #include "ash/common/system/date/date_view.h"
8 #include "ash/common/system/tray/tray_constants.h" 10 #include "ash/common/system/tray/tray_constants.h"
9 #include "ash/common/system/tray/tray_popup_utils.h" 11 #include "ash/common/system/tray/tray_popup_utils.h"
10 #include "ash/common/system/tray/tri_view.h" 12 #include "ash/common/system/tray/tri_view.h"
11 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
12 #include "ui/views/controls/separator.h" 14 #include "ui/views/controls/separator.h"
13 #include "ui/views/layout/box_layout.h" 15 #include "ui/views/layout/box_layout.h"
14 #include "ui/views/layout/fill_layout.h" 16 #include "ui/views/layout/fill_layout.h"
15 17
16 #if defined(OS_CHROMEOS)
17 #include "ash/common/system/chromeos/power/power_status.h"
18 #include "ash/common/system/chromeos/power/power_status_view.h"
19 #endif // defined(OS_CHROMEOS)
20
21 namespace ash { 18 namespace ash {
22 19
23 // The minimum number of menu button widths that the date view should span 20 // The minimum number of menu button widths that the date view should span
24 // horizontally. 21 // horizontally.
25 const int kMinNumTileWidths = 2; 22 const int kMinNumTileWidths = 2;
26 23
27 // The maximum number of menu button widths that the date view should span 24 // The maximum number of menu button widths that the date view should span
28 // horizontally. 25 // horizontally.
29 const int kMaxNumTileWidths = 3; 26 const int kMaxNumTileWidths = 3;
30 27
31 SystemInfoDefaultView::SystemInfoDefaultView(SystemTrayItem* owner, 28 SystemInfoDefaultView::SystemInfoDefaultView(SystemTrayItem* owner,
32 LoginStatus login) 29 LoginStatus login)
33 : date_view_(nullptr), 30 : date_view_(nullptr),
34 tri_view_(TrayPopupUtils::CreateMultiTargetRowView()) { 31 tri_view_(TrayPopupUtils::CreateMultiTargetRowView()) {
35 AddChildView(tri_view_); 32 AddChildView(tri_view_);
36 SetLayoutManager(new views::FillLayout); 33 SetLayoutManager(new views::FillLayout);
37 34
38 date_view_ = new tray::DateView(owner); 35 date_view_ = new tray::DateView(owner);
39 tri_view_->AddView(TriView::Container::START, date_view_); 36 tri_view_->AddView(TriView::Container::START, date_view_);
40 37
41 #if defined(OS_CHROMEOS)
42 if (PowerStatus::Get()->IsBatteryPresent()) { 38 if (PowerStatus::Get()->IsBatteryPresent()) {
43 power_status_view_ = new ash::PowerStatusView(false); 39 power_status_view_ = new ash::PowerStatusView(false);
44 std::unique_ptr<views::BoxLayout> box_layout = 40 std::unique_ptr<views::BoxLayout> box_layout =
45 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kHorizontal, 0, 0, 41 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kHorizontal, 0, 0,
46 0); 42 0);
47 box_layout->set_cross_axis_alignment( 43 box_layout->set_cross_axis_alignment(
48 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 44 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
49 box_layout->set_inside_border_insets( 45 box_layout->set_inside_border_insets(
50 gfx::Insets(0, 0, 0, kTrayPopupLabelRightPadding)); 46 gfx::Insets(0, 0, 0, kTrayPopupLabelRightPadding));
51 tri_view_->SetContainerLayout(TriView::Container::CENTER, 47 tri_view_->SetContainerLayout(TriView::Container::CENTER,
52 std::move(box_layout)); 48 std::move(box_layout));
53 49
54 tri_view_->AddView(TriView::Container::CENTER, 50 tri_view_->AddView(TriView::Container::CENTER,
55 TrayPopupUtils::CreateVerticalSeparator()); 51 TrayPopupUtils::CreateVerticalSeparator());
56 tri_view_->AddView(TriView::Container::CENTER, power_status_view_); 52 tri_view_->AddView(TriView::Container::CENTER, power_status_view_);
57 } 53 }
58 #endif // defined(OS_CHROMEOS)
59 tri_view_->SetContainerVisible(TriView::Container::END, false); 54 tri_view_->SetContainerVisible(TriView::Container::END, false);
60 55
61 if (TrayPopupUtils::CanOpenWebUISettings(login)) 56 if (TrayPopupUtils::CanOpenWebUISettings(login))
62 date_view_->SetAction(tray::DateView::DateAction::SHOW_DATE_SETTINGS); 57 date_view_->SetAction(tray::DateView::DateAction::SHOW_DATE_SETTINGS);
63 } 58 }
64 59
65 SystemInfoDefaultView::~SystemInfoDefaultView() {} 60 SystemInfoDefaultView::~SystemInfoDefaultView() {}
66 61
67 tray::DateView* SystemInfoDefaultView::GetDateView() { 62 tray::DateView* SystemInfoDefaultView::GetDateView() {
68 return date_view_; 63 return date_view_;
(...skipping 21 matching lines...) Expand all
90 num_extra_tile_widths = std::ceil(preferred_width_ratio); 85 num_extra_tile_widths = std::ceil(preferred_width_ratio);
91 } 86 }
92 num_extra_tile_widths = 87 num_extra_tile_widths =
93 std::max(kMinNumTileWidths - 1, 88 std::max(kMinNumTileWidths - 1,
94 std::min(num_extra_tile_widths, kMaxNumTileWidths - 1)); 89 std::min(num_extra_tile_widths, kMaxNumTileWidths - 1));
95 90
96 return kMenuButtonSize + num_extra_tile_widths * snap_to_width; 91 return kMenuButtonSize + num_extra_tile_widths * snap_to_width;
97 } 92 }
98 93
99 } // namespace ash 94 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698