| 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/tray_date.h" | 5 #include "ash/system/date/tray_date.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/date/date_view.h" | 8 #include "ash/system/date/date_view.h" |
| 9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
| 10 #include "ash/system/tray/tray_constants.h" | 10 #include "ash/system/tray/tray_constants.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "ui/views/layout/box_layout.h" | 28 #include "ui/views/layout/box_layout.h" |
| 29 #include "ui/views/view.h" | 29 #include "ui/views/view.h" |
| 30 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| 31 #include "unicode/datefmt.h" | 31 #include "unicode/datefmt.h" |
| 32 #include "unicode/fieldpos.h" | 32 #include "unicode/fieldpos.h" |
| 33 #include "unicode/fmtable.h" | 33 #include "unicode/fmtable.h" |
| 34 | 34 |
| 35 namespace ash { | 35 namespace ash { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 TrayDate::TrayDate() { | 38 TrayDate::TrayDate() |
| 39 : time_tray_(NULL) { |
| 39 } | 40 } |
| 40 | 41 |
| 41 TrayDate::~TrayDate() { | 42 TrayDate::~TrayDate() { |
| 42 } | 43 } |
| 43 | 44 |
| 44 views::View* TrayDate::CreateTrayView(user::LoginStatus status) { | 45 views::View* TrayDate::CreateTrayView(user::LoginStatus status) { |
| 45 time_tray_.reset(new tray::TimeView()); | 46 CHECK(time_tray_ == NULL); |
| 47 time_tray_ = new tray::TimeView(); |
| 46 time_tray_->set_border( | 48 time_tray_->set_border( |
| 47 views::Border::CreateEmptyBorder(0, 10, 0, 7)); | 49 views::Border::CreateEmptyBorder(0, 10, 0, 7)); |
| 48 SetupLabelForTray(time_tray_->label()); | 50 SetupLabelForTray(time_tray_->label()); |
| 49 gfx::Font font = time_tray_->label()->font(); | 51 gfx::Font font = time_tray_->label()->font(); |
| 50 time_tray_->label()->SetFont( | 52 time_tray_->label()->SetFont( |
| 51 font.DeriveFont(0, font.GetStyle() & ~gfx::Font::BOLD)); | 53 font.DeriveFont(0, font.GetStyle() & ~gfx::Font::BOLD)); |
| 52 | 54 |
| 53 views::View* view = new TrayItemView; | 55 views::View* view = new TrayItemView; |
| 54 view->AddChildView(time_tray_.get()); | 56 view->AddChildView(time_tray_); |
| 55 return view; | 57 return view; |
| 56 } | 58 } |
| 57 | 59 |
| 58 views::View* TrayDate::CreateDefaultView(user::LoginStatus status) { | 60 views::View* TrayDate::CreateDefaultView(user::LoginStatus status) { |
| 59 return NULL; | 61 return NULL; |
| 60 } | 62 } |
| 61 | 63 |
| 62 views::View* TrayDate::CreateDetailedView(user::LoginStatus status) { | 64 views::View* TrayDate::CreateDetailedView(user::LoginStatus status) { |
| 63 return NULL; | 65 return NULL; |
| 64 } | 66 } |
| 65 | 67 |
| 66 void TrayDate::DestroyTrayView() { | 68 void TrayDate::DestroyTrayView() { |
| 67 time_tray_.reset(); | 69 time_tray_ = NULL; |
| 68 } | 70 } |
| 69 | 71 |
| 70 void TrayDate::DestroyDefaultView() { | 72 void TrayDate::DestroyDefaultView() { |
| 71 } | 73 } |
| 72 | 74 |
| 73 void TrayDate::DestroyDetailedView() { | 75 void TrayDate::DestroyDetailedView() { |
| 74 } | 76 } |
| 75 | 77 |
| 76 void TrayDate::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 78 void TrayDate::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
| 77 } | 79 } |
| 78 | 80 |
| 79 void TrayDate::OnDateFormatChanged() { | 81 void TrayDate::OnDateFormatChanged() { |
| 80 time_tray_->UpdateTimeFormat(); | 82 if (time_tray_) |
| 83 time_tray_->UpdateTimeFormat(); |
| 81 } | 84 } |
| 82 | 85 |
| 83 void TrayDate::Refresh() { | 86 void TrayDate::Refresh() { |
| 84 time_tray_->UpdateText(); | 87 if (time_tray_) |
| 88 time_tray_->UpdateText(); |
| 85 } | 89 } |
| 86 | 90 |
| 87 } // namespace internal | 91 } // namespace internal |
| 88 } // namespace ash | 92 } // namespace ash |
| OLD | NEW |