| 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 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // The clock menu button in the status area. | 26 // The clock menu button in the status area. |
| 27 // This button shows the current time. | 27 // This button shows the current time. |
| 28 class ClockMenuButton : public StatusAreaButton, | 28 class ClockMenuButton : public StatusAreaButton, |
| 29 public views::MenuDelegate, | 29 public views::MenuDelegate, |
| 30 public views::ViewMenuDelegate, | 30 public views::ViewMenuDelegate, |
| 31 public content::NotificationObserver { | 31 public content::NotificationObserver { |
| 32 public: | 32 public: |
| 33 explicit ClockMenuButton(StatusAreaButton::Delegate* delegate); | 33 explicit ClockMenuButton(StatusAreaButton::Delegate* delegate); |
| 34 virtual ~ClockMenuButton(); | 34 virtual ~ClockMenuButton(); |
| 35 | 35 |
| 36 // content::NotificationObserver implementation. |
| 37 virtual void Observe(int type, |
| 38 const content::NotificationSource& source, |
| 39 const content::NotificationDetails& details) OVERRIDE; |
| 40 |
| 36 // views::MenuDelegate implementation | 41 // views::MenuDelegate implementation |
| 37 virtual string16 GetLabel(int id) const OVERRIDE; | 42 virtual string16 GetLabel(int id) const OVERRIDE; |
| 38 virtual bool IsCommandEnabled(int id) const OVERRIDE; | 43 virtual bool IsCommandEnabled(int id) const OVERRIDE; |
| 39 virtual void ExecuteCommand(int id) OVERRIDE; | 44 virtual void ExecuteCommand(int id) OVERRIDE; |
| 40 | 45 |
| 41 // views::View | 46 // Initialize PrefChangeRegistrar with the current default profile. |
| 42 virtual void OnLocaleChanged() OVERRIDE; | 47 void UpdateProfile(); |
| 43 | 48 |
| 44 // Updates the time on the menu button. | 49 // Updates the time on the menu button. |
| 45 void UpdateText(); | 50 void UpdateText(); |
| 46 | 51 |
| 47 // Sets default use 24hour clock mode. | |
| 48 void SetDefaultUse24HourClock(bool use_24hour_clock); | |
| 49 | |
| 50 // content::NotificationObserver implementation. | |
| 51 virtual void Observe(int type, | |
| 52 const content::NotificationSource& source, | |
| 53 const content::NotificationDetails& details) OVERRIDE; | |
| 54 | |
| 55 protected: | 52 protected: |
| 53 // StatusAreaButton implementation |
| 54 virtual void SetMenuActive(bool active) OVERRIDE; |
| 56 virtual int horizontal_padding() OVERRIDE; | 55 virtual int horizontal_padding() OVERRIDE; |
| 57 | 56 |
| 58 private: | 57 // views::View implementation |
| 58 virtual void OnLocaleChanged() OVERRIDE; |
| 59 |
| 59 // views::ViewMenuDelegate implementation. | 60 // views::ViewMenuDelegate implementation. |
| 60 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; | 61 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; |
| 61 | 62 |
| 63 private: |
| 64 // Sets default use 24hour clock mode. |
| 65 void SetUse24HourClock(bool use_24hour_clock); |
| 66 |
| 62 // Create and initialize menu if not already present. | 67 // Create and initialize menu if not already present. |
| 63 void EnsureMenu(); | 68 void EnsureMenu(); |
| 64 | 69 |
| 65 // Updates text and schedules the timer to fire at the next minute interval. | 70 // Updates text and schedules the timer to fire at the next minute interval. |
| 66 void UpdateTextAndSetNextTimer(); | 71 void UpdateTextAndSetNextTimer(); |
| 67 | 72 |
| 68 base::OneShotTimer<ClockMenuButton> timer_; | 73 base::OneShotTimer<ClockMenuButton> timer_; |
| 69 | 74 |
| 70 // The clock menu. | 75 // The clock menu. |
| 71 scoped_ptr<views::MenuRunner> menu_runner_; | 76 scoped_ptr<views::MenuRunner> menu_runner_; |
| 72 | 77 |
| 73 PrefChangeRegistrar registrar_; | 78 PrefService* pref_service_; |
| 79 scoped_ptr<PrefChangeRegistrar> registrar_; |
| 74 | 80 |
| 75 // Default value for use_24hour_clock. | 81 // Cached value for use_24hour_clock. |
| 76 bool default_use_24hour_clock_; | 82 bool use_24hour_clock_; |
| 77 | 83 |
| 78 DISALLOW_COPY_AND_ASSIGN(ClockMenuButton); | 84 DISALLOW_COPY_AND_ASSIGN(ClockMenuButton); |
| 79 }; | 85 }; |
| 80 | 86 |
| 81 #endif // CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ | 87 #endif // CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ |
| OLD | NEW |