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