| 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" |
| 11 #include "chrome/browser/chromeos/cros/cros_library.h" | 11 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 12 #include "chrome/browser/chromeos/status/status_area_host.h" | 12 #include "chrome/browser/chromeos/status/status_area_host.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "content/common/notification_details.h" | 17 #include "content/common/notification_details.h" |
| 17 #include "content/common/notification_source.h" | 18 #include "content/common/notification_source.h" |
| 18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/font.h" | 22 #include "ui/gfx/font.h" |
| 22 #include "views/widget/widget.h" | 23 #include "views/widget/widget.h" |
| 23 #include "unicode/datefmt.h" | 24 #include "unicode/datefmt.h" |
| 24 | 25 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 time, | 92 time, |
| 92 use_24hour_clock ? base::k24HourClock : base::k12HourClock, | 93 use_24hour_clock ? base::k24HourClock : base::k12HourClock, |
| 93 base::kDropAmPm))); | 94 base::kDropAmPm))); |
| 94 SetTooltipText(UTF16ToWide(base::TimeFormatFriendlyDateAndTime(time))); | 95 SetTooltipText(UTF16ToWide(base::TimeFormatFriendlyDateAndTime(time))); |
| 95 SetAccessibleName(base::TimeFormatFriendlyDateAndTime(time)); | 96 SetAccessibleName(base::TimeFormatFriendlyDateAndTime(time)); |
| 96 SchedulePaint(); | 97 SchedulePaint(); |
| 97 } | 98 } |
| 98 | 99 |
| 99 // ClockMenuButton, NotificationObserver implementation: | 100 // ClockMenuButton, NotificationObserver implementation: |
| 100 | 101 |
| 101 void ClockMenuButton::Observe(NotificationType type, | 102 void ClockMenuButton::Observe(int type, |
| 102 const NotificationSource& source, | 103 const NotificationSource& source, |
| 103 const NotificationDetails& details) { | 104 const NotificationDetails& details) { |
| 104 if (type == NotificationType::PREF_CHANGED) { | 105 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 105 std::string* pref_name = Details<std::string>(details).ptr(); | 106 std::string* pref_name = Details<std::string>(details).ptr(); |
| 106 if (*pref_name == prefs::kUse24HourClock) { | 107 if (*pref_name == prefs::kUse24HourClock) { |
| 107 UpdateText(); | 108 UpdateText(); |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 } | 111 } |
| 111 | 112 |
| 112 // ClockMenuButton, views::MenuDelegate implementation: | 113 // ClockMenuButton, views::MenuDelegate implementation: |
| 113 std::wstring ClockMenuButton::GetLabel(int id) const { | 114 std::wstring ClockMenuButton::GetLabel(int id) const { |
| 114 DCHECK_EQ(CLOCK_DISPLAY_ITEM, id); | 115 DCHECK_EQ(CLOCK_DISPLAY_ITEM, id); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 const string16 clock_open_options_label = | 192 const string16 clock_open_options_label = |
| 192 l10n_util::GetStringUTF16(IDS_STATUSBAR_CLOCK_OPEN_OPTIONS_DIALOG); | 193 l10n_util::GetStringUTF16(IDS_STATUSBAR_CLOCK_OPEN_OPTIONS_DIALOG); |
| 193 menu_->AppendMenuItemWithLabel( | 194 menu_->AppendMenuItemWithLabel( |
| 194 CLOCK_OPEN_OPTIONS_ITEM, | 195 CLOCK_OPEN_OPTIONS_ITEM, |
| 195 UTF16ToWide(clock_open_options_label)); | 196 UTF16ToWide(clock_open_options_label)); |
| 196 } | 197 } |
| 197 } | 198 } |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace chromeos | 201 } // namespace chromeos |
| OLD | NEW |