| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/date/date_view.h" | 5 #include "ash/system/date/date_view.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/system_tray_delegate.h" | 8 #include "ash/system/tray/system_tray_delegate.h" |
| 9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 TimeView::~TimeView() { | 175 TimeView::~TimeView() { |
| 176 } | 176 } |
| 177 | 177 |
| 178 void TimeView::UpdateTimeFormat() { | 178 void TimeView::UpdateTimeFormat() { |
| 179 hour_type_ = ash::Shell::GetInstance()->tray_delegate()->GetHourClockType(); | 179 hour_type_ = ash::Shell::GetInstance()->tray_delegate()->GetHourClockType(); |
| 180 UpdateText(); | 180 UpdateText(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void TimeView::UpdateTextInternal(const base::Time& now) { | 183 void TimeView::UpdateTextInternal(const base::Time& now) { |
| 184 // Just in case |now| is null, do NOT update time; otherwise, it will |
| 185 // crash icu code by calling into base::TimeFormatTimeOfDayWithHourClockType, |
| 186 // see details in crbug.com/147570. |
| 187 if (now.is_null()) { |
| 188 LOG(ERROR) << "Received null value from base::Time |now| in argument"; |
| 189 return; |
| 190 } |
| 191 |
| 184 string16 current_time = base::TimeFormatTimeOfDayWithHourClockType( | 192 string16 current_time = base::TimeFormatTimeOfDayWithHourClockType( |
| 185 now, hour_type_, base::kDropAmPm); | 193 now, hour_type_, base::kDropAmPm); |
| 186 label_->SetText(current_time); | 194 label_->SetText(current_time); |
| 187 label_->SetTooltipText(base::TimeFormatFriendlyDate(now)); | 195 label_->SetTooltipText(base::TimeFormatFriendlyDate(now)); |
| 188 | 196 |
| 189 // Calculate vertical clock layout labels. | 197 // Calculate vertical clock layout labels. |
| 190 size_t colon_pos = current_time.find(ASCIIToUTF16(":")); | 198 size_t colon_pos = current_time.find(ASCIIToUTF16(":")); |
| 191 string16 hour = current_time.substr(0, colon_pos); | 199 string16 hour = current_time.substr(0, colon_pos); |
| 192 string16 minute = current_time.substr(colon_pos + 1); | 200 string16 minute = current_time.substr(colon_pos + 1); |
| 193 label_hour_left_->SetText(hour.substr(0, 1)); | 201 label_hour_left_->SetText(hour.substr(0, 1)); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 void TimeView::SetupLabel(views::Label* label) { | 275 void TimeView::SetupLabel(views::Label* label) { |
| 268 label->set_owned_by_client(); | 276 label->set_owned_by_client(); |
| 269 SetupLabelForTray(label); | 277 SetupLabelForTray(label); |
| 270 gfx::Font font = label->font(); | 278 gfx::Font font = label->font(); |
| 271 label->SetFont(font.DeriveFont(0, font.GetStyle() & ~gfx::Font::BOLD)); | 279 label->SetFont(font.DeriveFont(0, font.GetStyle() & ~gfx::Font::BOLD)); |
| 272 } | 280 } |
| 273 | 281 |
| 274 } // namespace tray | 282 } // namespace tray |
| 275 } // namespace internal | 283 } // namespace internal |
| 276 } // namespace ash | 284 } // namespace ash |
| OLD | NEW |