| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 // Make sure that the timer fires on the next minute. Without this, if it is | 64 // Make sure that the timer fires on the next minute. Without this, if it is |
| 65 // called just a teeny bit early, then it will skip the next minute. | 65 // called just a teeny bit early, then it will skip the next minute. |
| 66 seconds_left += kTimerSlopSeconds; | 66 seconds_left += kTimerSlopSeconds; |
| 67 | 67 |
| 68 timer_.Start(base::TimeDelta::FromSeconds(seconds_left), this, | 68 timer_.Start(base::TimeDelta::FromSeconds(seconds_left), this, |
| 69 &ClockMenuButton::UpdateTextAndSetNextTimer); | 69 &ClockMenuButton::UpdateTextAndSetNextTimer); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ClockMenuButton::UpdateText() { | 72 void ClockMenuButton::UpdateText() { |
| 73 SetText(base::TimeFormatTimeOfDay(base::Time::Now())); | 73 base::Time time(base::Time::Now()); |
| 74 SetText(base::TimeFormatTimeOfDay(time)); |
| 75 SetTooltipText(base::TimeFormatShortDate(time)); |
| 74 SchedulePaint(); | 76 SchedulePaint(); |
| 75 } | 77 } |
| 76 | 78 |
| 77 //////////////////////////////////////////////////////////////////////////////// | 79 //////////////////////////////////////////////////////////////////////////////// |
| 78 // ClockMenuButton, menus::MenuModel implementation: | 80 // ClockMenuButton, menus::MenuModel implementation: |
| 79 | 81 |
| 80 int ClockMenuButton::GetItemCount() const { | 82 int ClockMenuButton::GetItemCount() const { |
| 81 // If options dialog is unavailable, don't count a separator and configure | 83 // If options dialog is unavailable, don't count a separator and configure |
| 82 // menu item. | 84 // menu item. |
| 83 return host_->ShouldOpenButtonOptions(this) ? 3 : 1; | 85 return host_->ShouldOpenButtonOptions(this) ? 3 : 1; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 void ClockMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { | 120 void ClockMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { |
| 119 if (!clock_menu_.get()) | 121 if (!clock_menu_.get()) |
| 120 clock_menu_.reset(new views::Menu2(this)); | 122 clock_menu_.reset(new views::Menu2(this)); |
| 121 else | 123 else |
| 122 clock_menu_->Rebuild(); | 124 clock_menu_->Rebuild(); |
| 123 clock_menu_->UpdateStates(); | 125 clock_menu_->UpdateStates(); |
| 124 clock_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 126 clock_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
| 125 } | 127 } |
| 126 | 128 |
| 127 } // namespace chromeos | 129 } // namespace chromeos |
| OLD | NEW |