| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/session/tray_session_length_limit.h" | 5 #include "ash/common/system/chromeos/session/tray_session_length_limit.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "ash/common/system/system_notifier.h" | 11 #include "ash/common/system/system_notifier.h" |
| 12 #include "ash/common/system/tray/label_tray_view.h" | 12 #include "ash/common/system/tray/label_tray_view.h" |
| 13 #include "ash/common/system/tray/system_tray.h" | 13 #include "ash/common/system/tray/system_tray.h" |
| 14 #include "ash/common/system/tray/system_tray_delegate.h" | 14 #include "ash/common/system/tray/system_tray_delegate.h" |
| 15 #include "ash/common/system/tray/system_tray_notifier.h" | 15 #include "ash/common/system/tray/system_tray_notifier.h" |
| 16 #include "ash/common/wm_shell.h" | |
| 17 #include "ash/resources/grit/ash_resources.h" | 16 #include "ash/resources/grit/ash_resources.h" |
| 18 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 19 #include "ash/strings/grit/ash_strings.h" | 18 #include "ash/strings/grit/ash_strings.h" |
| 20 #include "base/logging.h" | 19 #include "base/logging.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/l10n/time_format.h" | 22 #include "ui/base/l10n/time_format.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/message_center/message_center.h" | 24 #include "ui/message_center/message_center.h" |
| 26 #include "ui/message_center/notification.h" | 25 #include "ui/message_center/notification.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 | 41 |
| 43 // static | 42 // static |
| 44 const char TraySessionLengthLimit::kNotificationId[] = | 43 const char TraySessionLengthLimit::kNotificationId[] = |
| 45 "chrome://session/timeout"; | 44 "chrome://session/timeout"; |
| 46 | 45 |
| 47 TraySessionLengthLimit::TraySessionLengthLimit(SystemTray* system_tray) | 46 TraySessionLengthLimit::TraySessionLengthLimit(SystemTray* system_tray) |
| 48 : SystemTrayItem(system_tray, UMA_SESSION_LENGTH_LIMIT), | 47 : SystemTrayItem(system_tray, UMA_SESSION_LENGTH_LIMIT), |
| 49 limit_state_(LIMIT_NONE), | 48 limit_state_(LIMIT_NONE), |
| 50 last_limit_state_(LIMIT_NONE), | 49 last_limit_state_(LIMIT_NONE), |
| 51 tray_bubble_view_(NULL) { | 50 tray_bubble_view_(NULL) { |
| 52 WmShell::Get()->system_tray_notifier()->AddSessionLengthLimitObserver(this); | 51 Shell::Get()->system_tray_notifier()->AddSessionLengthLimitObserver(this); |
| 53 Update(); | 52 Update(); |
| 54 } | 53 } |
| 55 | 54 |
| 56 TraySessionLengthLimit::~TraySessionLengthLimit() { | 55 TraySessionLengthLimit::~TraySessionLengthLimit() { |
| 57 WmShell::Get()->system_tray_notifier()->RemoveSessionLengthLimitObserver( | 56 Shell::Get()->system_tray_notifier()->RemoveSessionLengthLimitObserver(this); |
| 58 this); | |
| 59 } | 57 } |
| 60 | 58 |
| 61 // Add view to tray bubble. | 59 // Add view to tray bubble. |
| 62 views::View* TraySessionLengthLimit::CreateDefaultView(LoginStatus status) { | 60 views::View* TraySessionLengthLimit::CreateDefaultView(LoginStatus status) { |
| 63 CHECK(!tray_bubble_view_); | 61 CHECK(!tray_bubble_view_); |
| 64 UpdateState(); | 62 UpdateState(); |
| 65 if (limit_state_ == LIMIT_NONE) | 63 if (limit_state_ == LIMIT_NONE) |
| 66 return NULL; | 64 return NULL; |
| 67 tray_bubble_view_ = | 65 tray_bubble_view_ = |
| 68 new LabelTrayView(NULL /* click_listener */, | 66 new LabelTrayView(NULL /* click_listener */, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 186 |
| 189 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const { | 187 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const { |
| 190 return l10n_util::GetStringFUTF16( | 188 return l10n_util::GetStringFUTF16( |
| 191 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT, | 189 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT, |
| 192 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, | 190 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, |
| 193 ui::TimeFormat::LENGTH_LONG, 10, | 191 ui::TimeFormat::LENGTH_LONG, 10, |
| 194 remaining_session_time_)); | 192 remaining_session_time_)); |
| 195 } | 193 } |
| 196 | 194 |
| 197 } // namespace ash | 195 } // namespace ash |
| OLD | NEW |