| OLD | NEW |
| 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/session_length_limit/tray_session_length_limit.h" | 5 #include "ash/system/session_length_limit/tray_session_length_limit.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/shelf/shelf_types.h" | 9 #include "ash/shelf/shelf_types.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 class RemainingSessionTimeTrayView : public views::View { | 115 class RemainingSessionTimeTrayView : public views::View { |
| 116 public: | 116 public: |
| 117 RemainingSessionTimeTrayView(const TraySessionLengthLimit* owner, | 117 RemainingSessionTimeTrayView(const TraySessionLengthLimit* owner, |
| 118 ShelfAlignment shelf_alignment); | 118 ShelfAlignment shelf_alignment); |
| 119 virtual ~RemainingSessionTimeTrayView(); | 119 virtual ~RemainingSessionTimeTrayView(); |
| 120 | 120 |
| 121 void UpdateClockLayout(ShelfAlignment shelf_alignment); | 121 void UpdateClockLayout(ShelfAlignment shelf_alignment); |
| 122 void Update(); | 122 void Update(); |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 void SetBorder(ShelfAlignment shelf_alignment); | 125 void SetBorderFromAlignment(ShelfAlignment shelf_alignment); |
| 126 | 126 |
| 127 const TraySessionLengthLimit* owner_; | 127 const TraySessionLengthLimit* owner_; |
| 128 | 128 |
| 129 views::Label* horizontal_layout_label_; | 129 views::Label* horizontal_layout_label_; |
| 130 views::Label* vertical_layout_label_hours_left_; | 130 views::Label* vertical_layout_label_hours_left_; |
| 131 views::Label* vertical_layout_label_hours_right_; | 131 views::Label* vertical_layout_label_hours_right_; |
| 132 views::Label* vertical_layout_label_minutes_left_; | 132 views::Label* vertical_layout_label_minutes_left_; |
| 133 views::Label* vertical_layout_label_minutes_right_; | 133 views::Label* vertical_layout_label_minutes_right_; |
| 134 views::Label* vertical_layout_label_seconds_left_; | 134 views::Label* vertical_layout_label_seconds_left_; |
| 135 views::Label* vertical_layout_label_seconds_right_; | 135 views::Label* vertical_layout_label_seconds_right_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 149 vertical_layout_label_seconds_left_(NULL), | 149 vertical_layout_label_seconds_left_(NULL), |
| 150 vertical_layout_label_seconds_right_(NULL) { | 150 vertical_layout_label_seconds_right_(NULL) { |
| 151 UpdateClockLayout(shelf_alignment); | 151 UpdateClockLayout(shelf_alignment); |
| 152 } | 152 } |
| 153 | 153 |
| 154 RemainingSessionTimeTrayView::~RemainingSessionTimeTrayView() { | 154 RemainingSessionTimeTrayView::~RemainingSessionTimeTrayView() { |
| 155 } | 155 } |
| 156 | 156 |
| 157 void RemainingSessionTimeTrayView::UpdateClockLayout( | 157 void RemainingSessionTimeTrayView::UpdateClockLayout( |
| 158 ShelfAlignment shelf_alignment) { | 158 ShelfAlignment shelf_alignment) { |
| 159 SetBorder(shelf_alignment); | 159 SetBorderFromAlignment(shelf_alignment); |
| 160 const bool horizontal_layout = (shelf_alignment == SHELF_ALIGNMENT_BOTTOM || | 160 const bool horizontal_layout = (shelf_alignment == SHELF_ALIGNMENT_BOTTOM || |
| 161 shelf_alignment == SHELF_ALIGNMENT_TOP); | 161 shelf_alignment == SHELF_ALIGNMENT_TOP); |
| 162 if (horizontal_layout && !horizontal_layout_label_) { | 162 if (horizontal_layout && !horizontal_layout_label_) { |
| 163 // Remove labels used for vertical layout. | 163 // Remove labels used for vertical layout. |
| 164 RemoveAllChildViews(true); | 164 RemoveAllChildViews(true); |
| 165 vertical_layout_label_hours_left_ = NULL; | 165 vertical_layout_label_hours_left_ = NULL; |
| 166 vertical_layout_label_hours_right_ = NULL; | 166 vertical_layout_label_hours_right_ = NULL; |
| 167 vertical_layout_label_minutes_left_ = NULL; | 167 vertical_layout_label_minutes_left_ = NULL; |
| 168 vertical_layout_label_minutes_right_ = NULL; | 168 vertical_layout_label_minutes_right_ = NULL; |
| 169 vertical_layout_label_seconds_left_ = NULL; | 169 vertical_layout_label_seconds_left_ = NULL; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 vertical_layout_label_minutes_left_->SetEnabledColor(color); | 255 vertical_layout_label_minutes_left_->SetEnabledColor(color); |
| 256 vertical_layout_label_minutes_right_->SetEnabledColor(color); | 256 vertical_layout_label_minutes_right_->SetEnabledColor(color); |
| 257 vertical_layout_label_seconds_left_->SetEnabledColor(color); | 257 vertical_layout_label_seconds_left_->SetEnabledColor(color); |
| 258 vertical_layout_label_seconds_right_->SetEnabledColor(color); | 258 vertical_layout_label_seconds_right_->SetEnabledColor(color); |
| 259 } | 259 } |
| 260 | 260 |
| 261 Layout(); | 261 Layout(); |
| 262 SetVisible(true); | 262 SetVisible(true); |
| 263 } | 263 } |
| 264 | 264 |
| 265 void RemainingSessionTimeTrayView::SetBorder(ShelfAlignment shelf_alignment) { | 265 void RemainingSessionTimeTrayView::SetBorderFromAlignment( |
| 266 ShelfAlignment shelf_alignment) { |
| 266 if (shelf_alignment == SHELF_ALIGNMENT_BOTTOM || | 267 if (shelf_alignment == SHELF_ALIGNMENT_BOTTOM || |
| 267 shelf_alignment == SHELF_ALIGNMENT_TOP) { | 268 shelf_alignment == SHELF_ALIGNMENT_TOP) { |
| 268 set_border(views::Border::CreateEmptyBorder( | 269 SetBorder(views::Border::CreateEmptyBorder( |
| 269 0, kTrayLabelItemHorizontalPaddingBottomAlignment, | 270 0, |
| 270 0, kTrayLabelItemHorizontalPaddingBottomAlignment)); | 271 kTrayLabelItemHorizontalPaddingBottomAlignment, |
| 272 0, |
| 273 kTrayLabelItemHorizontalPaddingBottomAlignment)); |
| 271 } else { | 274 } else { |
| 272 set_border(NULL); | 275 SetBorder(views::Border::NullBorder()); |
| 273 } | 276 } |
| 274 } | 277 } |
| 275 | 278 |
| 276 } // namespace tray | 279 } // namespace tray |
| 277 | 280 |
| 278 // static | 281 // static |
| 279 const char TraySessionLengthLimit::kNotificationId[] = | 282 const char TraySessionLengthLimit::kNotificationId[] = |
| 280 "chrome://session/timeout"; | 283 "chrome://session/timeout"; |
| 281 | 284 |
| 282 TraySessionLengthLimit::TraySessionLengthLimit(SystemTray* system_tray) | 285 TraySessionLengthLimit::TraySessionLengthLimit(SystemTray* system_tray) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 if (tray_view_) | 380 if (tray_view_) |
| 378 tray_view_->Update(); | 381 tray_view_->Update(); |
| 379 } | 382 } |
| 380 | 383 |
| 381 bool TraySessionLengthLimit::IsTrayViewVisibleForTest() { | 384 bool TraySessionLengthLimit::IsTrayViewVisibleForTest() { |
| 382 return tray_view_ && tray_view_->visible(); | 385 return tray_view_ && tray_view_->visible(); |
| 383 } | 386 } |
| 384 | 387 |
| 385 } // namespace internal | 388 } // namespace internal |
| 386 } // namespace ash | 389 } // namespace ash |
| OLD | NEW |