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