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/dbus/dbus_thread_manager.h" | 8 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.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" |
11 #include "chrome/browser/chromeos/status/clock_menu_button.h" | 11 #include "chrome/browser/chromeos/status/clock_menu_button.h" |
12 #include "chrome/browser/chromeos/status/input_method_menu_button.h" | 12 #include "chrome/browser/chromeos/status/input_method_menu_button.h" |
13 #include "chrome/browser/chromeos/status/memory_menu_button.h" | 13 #include "chrome/browser/chromeos/status/memory_menu_button.h" |
14 #include "chrome/browser/chromeos/status/network_menu_button.h" | 14 #include "chrome/browser/chromeos/status/network_menu_button.h" |
15 #include "chrome/browser/chromeos/status/power_menu_button.h" | 15 #include "chrome/browser/chromeos/status/power_menu_button.h" |
16 #include "chrome/browser/chromeos/view_ids.h" | 16 #include "chrome/browser/chromeos/view_ids.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
20 | 20 |
| 21 // static |
| 22 StatusAreaViewChromeos::ScreenMode |
| 23 StatusAreaViewChromeos::screen_mode_ = BROWSER_MODE; |
| 24 |
| 25 // static |
| 26 bool StatusAreaViewChromeos::IsBrowserMode() { |
| 27 return screen_mode_ == BROWSER_MODE; |
| 28 } |
| 29 |
| 30 // static |
| 31 bool StatusAreaViewChromeos::IsLoginMode() { |
| 32 return screen_mode_ == LOGIN_MODE_WEBUI; |
| 33 } |
| 34 |
| 35 // static |
| 36 bool StatusAreaViewChromeos::IsScreenLockMode() { |
| 37 return screen_mode_ == SCREEN_LOCKER_MODE; |
| 38 } |
| 39 |
| 40 // static |
| 41 void StatusAreaViewChromeos::SetScreenMode(ScreenMode mode) { |
| 42 screen_mode_ = mode; |
| 43 } |
| 44 |
21 StatusAreaViewChromeos::StatusAreaViewChromeos() { | 45 StatusAreaViewChromeos::StatusAreaViewChromeos() { |
22 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 46 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
23 system::TimezoneSettings::GetInstance()->AddObserver(this); | 47 system::TimezoneSettings::GetInstance()->AddObserver(this); |
24 } | 48 } |
25 | 49 |
26 StatusAreaViewChromeos::~StatusAreaViewChromeos() { | 50 StatusAreaViewChromeos::~StatusAreaViewChromeos() { |
27 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 51 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
28 system::TimezoneSettings::GetInstance()->RemoveObserver(this); | 52 system::TimezoneSettings::GetInstance()->RemoveObserver(this); |
29 } | 53 } |
30 | 54 |
31 void StatusAreaViewChromeos::Init(StatusAreaButton::Delegate* delegate, | 55 void StatusAreaViewChromeos::Init(StatusAreaButton::Delegate* delegate) { |
32 ScreenMode screen_mode) { | 56 AddChromeosButtons(this, delegate, NULL); |
33 AddChromeosButtons(this, delegate, screen_mode, NULL); | |
34 } | 57 } |
35 | 58 |
36 void StatusAreaViewChromeos::SystemResumed() { | 59 void StatusAreaViewChromeos::SystemResumed() { |
37 UpdateClockText(); | 60 UpdateClockText(); |
38 } | 61 } |
39 | 62 |
40 void StatusAreaViewChromeos::TimezoneChanged(const icu::TimeZone& timezone) { | 63 void StatusAreaViewChromeos::TimezoneChanged(const icu::TimeZone& timezone) { |
41 UpdateClockText(); | 64 UpdateClockText(); |
42 } | 65 } |
43 | 66 |
44 void StatusAreaViewChromeos::UpdateClockText() { | 67 void StatusAreaViewChromeos::UpdateClockText() { |
45 ClockMenuButton* clock_button = | 68 ClockMenuButton* clock_button = |
46 static_cast<ClockMenuButton*>(GetViewByID(VIEW_ID_STATUS_BUTTON_CLOCK)); | 69 static_cast<ClockMenuButton*>(GetViewByID(VIEW_ID_STATUS_BUTTON_CLOCK)); |
47 if (clock_button) | 70 if (clock_button) |
48 clock_button->UpdateText(); | 71 clock_button->UpdateText(); |
49 } | 72 } |
50 | 73 |
51 void StatusAreaViewChromeos::SetDefaultUse24HourClock(bool use_24hour_clock) { | 74 void StatusAreaViewChromeos::SetDefaultUse24HourClock(bool use_24hour_clock) { |
52 ClockMenuButton* clock_button = | 75 ClockMenuButton* clock_button = |
53 static_cast<ClockMenuButton*>(GetViewByID(VIEW_ID_STATUS_BUTTON_CLOCK)); | 76 static_cast<ClockMenuButton*>(GetViewByID(VIEW_ID_STATUS_BUTTON_CLOCK)); |
54 if (clock_button) | 77 if (clock_button) |
55 clock_button->SetDefaultUse24HourClock(use_24hour_clock); | 78 clock_button->SetDefaultUse24HourClock(use_24hour_clock); |
56 } | 79 } |
57 | 80 |
58 // static | 81 // static |
59 void StatusAreaViewChromeos::AddChromeosButtons( | 82 void StatusAreaViewChromeos::AddChromeosButtons( |
60 StatusAreaView* status_area, | 83 StatusAreaView* status_area, |
61 StatusAreaButton::Delegate* delegate, | 84 StatusAreaButton::Delegate* delegate, |
62 ScreenMode screen_mode, | |
63 ClockMenuButton** clock_button) { | 85 ClockMenuButton** clock_button) { |
64 const bool border = true; | 86 const bool border = true; |
65 const bool no_border = false; | 87 const bool no_border = false; |
66 | 88 |
67 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMemoryWidget)) | 89 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMemoryWidget)) |
68 status_area->AddButton(new MemoryMenuButton(delegate), no_border); | 90 status_area->AddButton(new MemoryMenuButton(delegate), no_border); |
69 | 91 |
70 status_area->AddButton( | 92 status_area->AddButton(new AccessibilityMenuButton(delegate), border); |
71 new AccessibilityMenuButton(delegate, screen_mode), border); | |
72 status_area->AddButton(new CapsLockMenuButton(delegate), border); | 93 status_area->AddButton(new CapsLockMenuButton(delegate), border); |
73 ClockMenuButton* clock = new ClockMenuButton(delegate); | 94 ClockMenuButton* clock = new ClockMenuButton(delegate); |
74 status_area->AddButton(clock, border); | 95 status_area->AddButton(clock, border); |
75 if (clock_button) | 96 if (clock_button) |
76 *clock_button = clock; | 97 *clock_button = clock; |
77 | 98 |
78 status_area->AddButton( | 99 status_area->AddButton(new InputMethodMenuButton(delegate), no_border); |
79 new InputMethodMenuButton(delegate, screen_mode), no_border); | 100 status_area->AddButton(new NetworkMenuButton(delegate), no_border); |
80 status_area->AddButton( | |
81 new NetworkMenuButton(delegate, screen_mode), no_border); | |
82 status_area->AddButton(new PowerMenuButton(delegate), no_border); | 101 status_area->AddButton(new PowerMenuButton(delegate), no_border); |
83 } | 102 } |
84 | 103 |
85 } // namespace chromeos | 104 } // namespace chromeos |
OLD | NEW |