| 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" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/chromeos/cros/cros_library.h" | 13 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 14 #include "chrome/browser/chromeos/status/status_area_host.h" | 14 #include "chrome/browser/chromeos/status/status_area_host.h" |
| 15 #include "chrome/browser/profiles/profile.h" | |
| 16 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 18 #include "gfx/canvas.h" | 17 #include "gfx/canvas.h" |
| 19 #include "gfx/font.h" | 18 #include "gfx/font.h" |
| 20 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 21 | 20 |
| 22 namespace chromeos { | 21 namespace chromeos { |
| 23 | 22 |
| 24 // Amount of slop to add into the timer to make sure we're into the next minute | 23 // Amount of slop to add into the timer to make sure we're into the next minute |
| 25 // when the timer goes off. | 24 // when the timer goes off. |
| 26 const int kTimerSlopSeconds = 1; | 25 const int kTimerSlopSeconds = 1; |
| 27 | 26 |
| 28 #if defined(CROS_FONTS_USING_BCI) | 27 #if defined(CROS_FONTS_USING_BCI) |
| 29 const int kFontSizeDelta = 0; | 28 const int kFontSizeDelta = 0; |
| 30 #else | 29 #else |
| 31 const int kFontSizeDelta = 1; | 30 const int kFontSizeDelta = 1; |
| 32 #endif | 31 #endif |
| 33 | 32 |
| 34 ClockMenuButton::ClockMenuButton(StatusAreaHost* host) | 33 ClockMenuButton::ClockMenuButton(StatusAreaHost* host) |
| 35 : StatusAreaButton(this), | 34 : StatusAreaButton(this), |
| 36 host_(host) { | 35 host_(host) { |
| 37 // Add as SystemLibrary observer. We update the clock if timezone changes. | 36 // Add as SystemLibrary observer. We update the clock if timezone changes. |
| 38 CrosLibrary::Get()->GetSystemLibrary()->AddObserver(this); | 37 CrosLibrary::Get()->GetSystemLibrary()->AddObserver(this); |
| 39 | 38 |
| 40 set_border(NULL); | 39 set_border(NULL); |
| 41 set_use_menu_button_paint(true); | 40 set_use_menu_button_paint(true); |
| 42 SetFont(ResourceBundle::GetSharedInstance().GetFont( | 41 SetFont(ResourceBundle::GetSharedInstance().GetFont( |
| 43 ResourceBundle::BaseFont).DeriveFont(kFontSizeDelta)); | 42 ResourceBundle::BaseFont).DeriveFont(kFontSizeDelta)); |
| 44 SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha | 43 SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha |
| 45 SetShowMultipleIconStates(false); | 44 SetShowMultipleIconStates(false); |
| 46 set_alignment(TextButton::ALIGN_CENTER); | 45 set_alignment(TextButton::ALIGN_CENTER); |
| 47 UpdateTextAndSetNextTimer(); | 46 UpdateTextAndSetNextTimer(); |
| 48 } | 47 } |
| 49 | 48 |
| 50 ClockMenuButton::~ClockMenuButton() { | 49 ClockMenuButton::~ClockMenuButton() { |
| 51 CrosLibrary::Get()->GetSystemLibrary()->RemoveObserver(this); | 50 CrosLibrary::Get()->GetSystemLibrary()->RemoveObserver(this); |
| 52 } | 51 } |
| 53 | 52 |
| 54 void ClockMenuButton::UpdateTextAndSetNextTimer() { | 53 void ClockMenuButton::UpdateTextAndSetNextTimer() { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 void ClockMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { | 125 void ClockMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { |
| 127 if (!clock_menu_.get()) | 126 if (!clock_menu_.get()) |
| 128 clock_menu_.reset(new views::Menu2(this)); | 127 clock_menu_.reset(new views::Menu2(this)); |
| 129 else | 128 else |
| 130 clock_menu_->Rebuild(); | 129 clock_menu_->Rebuild(); |
| 131 clock_menu_->UpdateStates(); | 130 clock_menu_->UpdateStates(); |
| 132 clock_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 131 clock_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
| 133 } | 132 } |
| 134 | 133 |
| 135 } // namespace chromeos | 134 } // namespace chromeos |
| OLD | NEW |