OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/status/clock_menu_button.h" | 5 #include "chrome/browser/chromeos/status/clock_menu_button.h" |
6 | 6 |
7 #include "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // Often this will be called at minute boundaries, and we'll actually want | 73 // Often this will be called at minute boundaries, and we'll actually want |
74 // 60 seconds from now. | 74 // 60 seconds from now. |
75 int seconds_left = 60 - exploded.second; | 75 int seconds_left = 60 - exploded.second; |
76 if (seconds_left == 0) | 76 if (seconds_left == 0) |
77 seconds_left = 60; | 77 seconds_left = 60; |
78 | 78 |
79 // Make sure that the timer fires on the next minute. Without this, if it is | 79 // Make sure that the timer fires on the next minute. Without this, if it is |
80 // called just a teeny bit early, then it will skip the next minute. | 80 // called just a teeny bit early, then it will skip the next minute. |
81 seconds_left += kTimerSlopSeconds; | 81 seconds_left += kTimerSlopSeconds; |
82 | 82 |
83 timer_.Start(base::TimeDelta::FromSeconds(seconds_left), this, | 83 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(seconds_left), this, |
84 &ClockMenuButton::UpdateTextAndSetNextTimer); | 84 &ClockMenuButton::UpdateTextAndSetNextTimer); |
85 } | 85 } |
86 | 86 |
87 void ClockMenuButton::UpdateText() { | 87 void ClockMenuButton::UpdateText() { |
88 base::Time time(base::Time::Now()); | 88 base::Time time(base::Time::Now()); |
89 // If the profie is present, check the use 24-hour clock preference. | 89 // If the profie is present, check the use 24-hour clock preference. |
90 const bool use_24hour_clock = | 90 const bool use_24hour_clock = |
91 host_->GetProfile() && | 91 host_->GetProfile() && |
92 host_->GetProfile()->GetPrefs()->GetBoolean(prefs::kUse24HourClock); | 92 host_->GetProfile()->GetPrefs()->GetBoolean(prefs::kUse24HourClock); |
93 SetText(UTF16ToWide(base::TimeFormatTimeOfDayWithHourClockType( | 93 SetText(UTF16ToWide(base::TimeFormatTimeOfDayWithHourClockType( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 const string16 clock_open_options_label = | 188 const string16 clock_open_options_label = |
189 l10n_util::GetStringUTF16(IDS_STATUSBAR_CLOCK_OPEN_OPTIONS_DIALOG); | 189 l10n_util::GetStringUTF16(IDS_STATUSBAR_CLOCK_OPEN_OPTIONS_DIALOG); |
190 menu->AppendMenuItemWithLabel( | 190 menu->AppendMenuItemWithLabel( |
191 CLOCK_OPEN_OPTIONS_ITEM, | 191 CLOCK_OPEN_OPTIONS_ITEM, |
192 UTF16ToWide(clock_open_options_label)); | 192 UTF16ToWide(clock_open_options_label)); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 } // namespace chromeos | 196 } // namespace chromeos |
OLD | NEW |