| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/power/idle_action_warning_dialog_view.h" | 5 #include "chrome/browser/chromeos/power/idle_action_warning_dialog_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 const int kIdleActionWarningContentWidth = 300; | 29 const int kIdleActionWarningContentWidth = 300; |
| 30 | 30 |
| 31 const int kCountdownUpdateIntervalMs = 1000; // 1 second. | 31 const int kCountdownUpdateIntervalMs = 1000; // 1 second. |
| 32 | 32 |
| 33 class FixedWidthLabel : public views::Label { | 33 class FixedWidthLabel : public views::Label { |
| 34 public: | 34 public: |
| 35 explicit FixedWidthLabel(int width); | 35 explicit FixedWidthLabel(int width); |
| 36 virtual ~FixedWidthLabel(); | 36 virtual ~FixedWidthLabel(); |
| 37 | 37 |
| 38 virtual gfx::Size GetPreferredSize() OVERRIDE; | 38 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 int width_; | 41 int width_; |
| 42 | 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(FixedWidthLabel); | 43 DISALLOW_COPY_AND_ASSIGN(FixedWidthLabel); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 FixedWidthLabel::FixedWidthLabel(int width) : width_(width) { | 46 FixedWidthLabel::FixedWidthLabel(int width) : width_(width) { |
| 47 SetHorizontalAlignment(gfx::ALIGN_LEFT); | 47 SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 48 SetMultiLine(true); | 48 SetMultiLine(true); |
| 49 } | 49 } |
| 50 | 50 |
| 51 FixedWidthLabel::~FixedWidthLabel() { | 51 FixedWidthLabel::~FixedWidthLabel() { |
| 52 } | 52 } |
| 53 | 53 |
| 54 gfx::Size FixedWidthLabel::GetPreferredSize() { | 54 gfx::Size FixedWidthLabel::GetPreferredSize() const { |
| 55 return gfx::Size(width_, GetHeightForWidth(width_)); | 55 return gfx::Size(width_, GetHeightForWidth(width_)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| 59 | 59 |
| 60 IdleActionWarningDialogView::IdleActionWarningDialogView( | 60 IdleActionWarningDialogView::IdleActionWarningDialogView( |
| 61 base::TimeTicks idle_action_time) | 61 base::TimeTicks idle_action_time) |
| 62 : idle_action_time_(idle_action_time), | 62 : idle_action_time_(idle_action_time), |
| 63 label_(NULL) { | 63 label_(NULL) { |
| 64 label_ = new FixedWidthLabel(kIdleActionWarningContentWidth); | 64 label_ = new FixedWidthLabel(kIdleActionWarningContentWidth); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 base::TimeDelta()); | 117 base::TimeDelta()); |
| 118 label_->SetText(l10n_util::GetStringFUTF16( | 118 label_->SetText(l10n_util::GetStringFUTF16( |
| 119 IDS_IDLE_WARNING_LOGOUT_WARNING, | 119 IDS_IDLE_WARNING_LOGOUT_WARNING, |
| 120 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, | 120 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, |
| 121 ui::TimeFormat::LENGTH_LONG, | 121 ui::TimeFormat::LENGTH_LONG, |
| 122 10, | 122 10, |
| 123 time_until_idle_action))); | 123 time_until_idle_action))); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace chromeos | 126 } // namespace chromeos |
| OLD | NEW |