| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 base::Time time(base::Time::Now()); | 85 base::Time time(base::Time::Now()); |
| 86 // If the profie is present, check the use 24-hour clock preference. | 86 // If the profie is present, check the use 24-hour clock preference. |
| 87 const bool use_24hour_clock = | 87 const bool use_24hour_clock = |
| 88 host_->GetProfile() && | 88 host_->GetProfile() && |
| 89 host_->GetProfile()->GetPrefs()->GetBoolean(prefs::kUse24HourClock); | 89 host_->GetProfile()->GetPrefs()->GetBoolean(prefs::kUse24HourClock); |
| 90 SetText(UTF16ToWide(base::TimeFormatTimeOfDayWithHourClockType( | 90 SetText(UTF16ToWide(base::TimeFormatTimeOfDayWithHourClockType( |
| 91 time, | 91 time, |
| 92 use_24hour_clock ? base::k24HourClock : base::k12HourClock, | 92 use_24hour_clock ? base::k24HourClock : base::k12HourClock, |
| 93 base::kDropAmPm))); | 93 base::kDropAmPm))); |
| 94 SetTooltipText(UTF16ToWide(base::TimeFormatShortDate(time))); | 94 SetTooltipText(UTF16ToWide(base::TimeFormatShortDate(time))); |
| 95 SetAccessibleName(base::TimeFormatFriendlyDateAndTime(time)); |
| 95 SchedulePaint(); | 96 SchedulePaint(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 // ClockMenuButton, NotificationObserver implementation: | 99 // ClockMenuButton, NotificationObserver implementation: |
| 99 | 100 |
| 100 void ClockMenuButton::Observe(NotificationType type, | 101 void ClockMenuButton::Observe(NotificationType type, |
| 101 const NotificationSource& source, | 102 const NotificationSource& source, |
| 102 const NotificationDetails& details) { | 103 const NotificationDetails& details) { |
| 103 if (type == NotificationType::PREF_CHANGED) { | 104 if (type == NotificationType::PREF_CHANGED) { |
| 104 std::string* pref_name = Details<std::string>(details).ptr(); | 105 std::string* pref_name = Details<std::string>(details).ptr(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 const string16 clock_open_options_label = | 191 const string16 clock_open_options_label = |
| 191 l10n_util::GetStringUTF16(IDS_STATUSBAR_CLOCK_OPEN_OPTIONS_DIALOG); | 192 l10n_util::GetStringUTF16(IDS_STATUSBAR_CLOCK_OPEN_OPTIONS_DIALOG); |
| 192 menu_->AppendMenuItemWithLabel( | 193 menu_->AppendMenuItemWithLabel( |
| 193 CLOCK_OPEN_OPTIONS_ITEM, | 194 CLOCK_OPEN_OPTIONS_ITEM, |
| 194 UTF16ToWide(clock_open_options_label)); | 195 UTF16ToWide(clock_open_options_label)); |
| 195 } | 196 } |
| 196 } | 197 } |
| 197 } | 198 } |
| 198 | 199 |
| 199 } // namespace chromeos | 200 } // namespace chromeos |
| OLD | NEW |