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 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" | 5 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
9 #include "chrome/browser/chromeos/status/accessibility_menu_button.h" | 9 #include "chrome/browser/chromeos/status/accessibility_menu_button.h" |
10 #include "chrome/browser/chromeos/status/caps_lock_menu_button.h" | 10 #include "chrome/browser/chromeos/status/caps_lock_menu_button.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 system::TimezoneSettings::GetInstance()->AddObserver(this); | 23 system::TimezoneSettings::GetInstance()->AddObserver(this); |
24 } | 24 } |
25 | 25 |
26 StatusAreaViewChromeos::~StatusAreaViewChromeos() { | 26 StatusAreaViewChromeos::~StatusAreaViewChromeos() { |
27 CrosLibrary::Get()->GetPowerLibrary()->RemoveObserver(this); | 27 CrosLibrary::Get()->GetPowerLibrary()->RemoveObserver(this); |
28 system::TimezoneSettings::GetInstance()->RemoveObserver(this); | 28 system::TimezoneSettings::GetInstance()->RemoveObserver(this); |
29 } | 29 } |
30 | 30 |
31 void StatusAreaViewChromeos::Init(StatusAreaButton::Delegate* delegate, | 31 void StatusAreaViewChromeos::Init(StatusAreaButton::Delegate* delegate, |
32 ScreenMode screen_mode) { | 32 ScreenMode screen_mode) { |
33 AddChromeosButtons(this, delegate, screen_mode, NULL); | 33 AddChromeosButtons(this, delegate, screen_mode); |
34 } | 34 } |
35 | 35 |
36 void StatusAreaViewChromeos::SystemResumed() { | 36 void StatusAreaViewChromeos::SystemResumed() { |
37 UpdateClockText(); | 37 UpdateClockText(); |
38 } | 38 } |
39 | 39 |
40 void StatusAreaViewChromeos::TimezoneChanged(const icu::TimeZone& timezone) { | 40 void StatusAreaViewChromeos::TimezoneChanged(const icu::TimeZone& timezone) { |
41 UpdateClockText(); | 41 UpdateClockText(); |
42 } | 42 } |
43 | 43 |
44 void StatusAreaViewChromeos::UpdateClockText() { | 44 void StatusAreaViewChromeos::UpdateClockText() { |
45 ClockMenuButton* clock_button = | 45 ClockMenuButton* clock_button = |
46 static_cast<ClockMenuButton*>(GetViewByID(VIEW_ID_STATUS_BUTTON_CLOCK)); | 46 static_cast<ClockMenuButton*>(GetViewByID(VIEW_ID_STATUS_BUTTON_CLOCK)); |
47 if (clock_button) | 47 if (clock_button) |
48 clock_button->UpdateText(); | 48 clock_button->UpdateText(); |
49 } | 49 } |
50 | 50 |
51 void StatusAreaViewChromeos::SetDefaultUse24HourClock(bool use_24hour_clock) { | 51 void StatusAreaViewChromeos::SetDefaultUse24HourClock(bool use_24hour_clock) { |
52 ClockMenuButton* clock_button = | 52 ClockMenuButton* clock_button = |
53 static_cast<ClockMenuButton*>(GetViewByID(VIEW_ID_STATUS_BUTTON_CLOCK)); | 53 static_cast<ClockMenuButton*>(GetViewByID(VIEW_ID_STATUS_BUTTON_CLOCK)); |
54 if (clock_button) | 54 if (clock_button) |
55 clock_button->SetDefaultUse24HourClock(use_24hour_clock); | 55 clock_button->SetDefaultUse24HourClock(use_24hour_clock); |
56 } | 56 } |
57 | 57 |
58 // static | 58 // static |
59 void StatusAreaViewChromeos::AddChromeosButtons( | 59 void StatusAreaViewChromeos::AddChromeosButtons( |
60 StatusAreaView* status_area, | 60 StatusAreaView* status_area, |
61 StatusAreaButton::Delegate* delegate, | 61 StatusAreaButton::Delegate* delegate, |
62 ScreenMode screen_mode, | 62 ScreenMode screen_mode) { |
63 ClockMenuButton** clock_button) { | |
64 const bool border = true; | 63 const bool border = true; |
65 const bool no_border = false; | 64 const bool no_border = false; |
66 | 65 |
67 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMemoryWidget)) | 66 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMemoryWidget)) |
68 status_area->AddButton(new MemoryMenuButton(delegate), no_border); | 67 status_area->AddButton(new MemoryMenuButton(delegate), no_border); |
69 | 68 |
70 status_area->AddButton( | 69 status_area->AddButton( |
71 new AccessibilityMenuButton(delegate, screen_mode), border); | 70 new AccessibilityMenuButton(delegate, screen_mode), border); |
72 status_area->AddButton(new CapsLockMenuButton(delegate), border); | 71 status_area->AddButton(new CapsLockMenuButton(delegate), border); |
73 ClockMenuButton* clock = new ClockMenuButton(delegate); | 72 status_area->AddButton(new ClockMenuButton(delegate), border); |
74 status_area->AddButton(clock, border); | |
75 if (clock_button) | |
76 *clock_button = clock; | |
77 | 73 |
78 status_area->AddButton( | 74 status_area->AddButton( |
79 new InputMethodMenuButton(delegate, screen_mode), no_border); | 75 new InputMethodMenuButton(delegate, screen_mode), no_border); |
80 status_area->AddButton( | 76 status_area->AddButton( |
81 new NetworkMenuButton(delegate, screen_mode), no_border); | 77 new NetworkMenuButton(delegate, screen_mode), no_border); |
82 status_area->AddButton(new PowerMenuButton(delegate), no_border); | 78 status_area->AddButton(new PowerMenuButton(delegate), no_border); |
83 } | 79 } |
84 | 80 |
85 } // namespace chromeos | 81 } // namespace chromeos |
OLD | NEW |