summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--athena/athena.gyp16
-rw-r--r--athena/common/container_priorities.h2
-rw-r--r--athena/main/athena_launcher.cc6
-rw-r--r--athena/main/athena_main.gyp8
-rw-r--r--athena/main/debug/DEPS9
-rw-r--r--athena/main/debug/debug_window.cc346
-rw-r--r--athena/main/debug/debug_window.h10
-rw-r--r--athena/main/placeholder.cc4
-rw-r--r--athena/screen/DEPS8
-rw-r--r--athena/screen/public/screen_manager.h8
-rw-r--r--athena/screen/screen_manager_impl.cc18
-rw-r--r--athena/system/DEPS10
-rw-r--r--athena/system/background_controller.cc (renamed from athena/screen/background_controller.cc)72
-rw-r--r--athena/system/background_controller.h (renamed from athena/screen/background_controller.h)11
-rw-r--r--athena/system/network_selector.cc (renamed from athena/main/debug/network_selector.cc)6
-rw-r--r--athena/system/network_selector.h (renamed from athena/main/debug/network_selector.h)10
-rw-r--r--athena/system/public/system_ui.h18
-rw-r--r--athena/system/status_icon_container_view.cc242
-rw-r--r--athena/system/status_icon_container_view.h47
-rw-r--r--athena/system/system_ui_impl.cc55
-rw-r--r--athena/system/time_view.cc69
-rw-r--r--athena/system/time_view.h35
-rw-r--r--athena/test/DEPS2
-rw-r--r--athena/test/athena_test_helper.cc3
24 files changed, 537 insertions, 478 deletions
diff --git a/athena/athena.gyp b/athena/athena.gyp
index dee4e51..1b634f0 100644
--- a/athena/athena.gyp
+++ b/athena/athena.gyp
@@ -11,7 +11,11 @@
'target_name': 'athena_lib',
'type': '<(component)',
'dependencies': [
+ # status_icon_container_view.cc depends on this. Remove this once there
+ # are athena specific assets.
+ '../ash/ash_resources.gyp:ash_resources',
'../base/base.gyp:test_support_base',
+ '../chromeos/chromeos.gyp:power_manager_proto',
'../extensions/shell/app_shell.gyp:app_shell_version_header',
'../ipc/ipc.gyp:ipc',
'../skia/skia.gyp:skia',
@@ -71,19 +75,25 @@
'input/input_manager_impl.cc',
'input/public/accelerator_manager.h',
'input/public/input_manager.h',
- 'screen/background_controller.cc',
- 'screen/background_controller.h',
'screen/public/screen_manager.h',
'screen/screen_accelerator_handler.cc',
'screen/screen_accelerator_handler.h',
'screen/screen_manager_impl.cc',
+ 'system/background_controller.cc',
+ 'system/background_controller.h',
'system/device_socket_listener.cc',
'system/device_socket_listener.h',
+ 'system/network_selector.cc',
+ 'system/network_selector.h',
'system/orientation_controller.cc',
'system/orientation_controller.h',
'system/power_button_controller.cc',
'system/power_button_controller.h',
- 'system/public/system_ui.h',
+ 'system/status_icon_container_view.cc',
+ 'system/status_icon_container_view.h',
+ 'system/time_view.cc',
+ 'system/time_view.h',
+ 'system/public/system_ui.h',
'system/system_ui_impl.cc',
'wm/bezel_controller.cc',
'wm/bezel_controller.h',
diff --git a/athena/common/container_priorities.h b/athena/common/container_priorities.h
index 549d1e6..5d42c3a 100644
--- a/athena/common/container_priorities.h
+++ b/athena/common/container_priorities.h
@@ -11,7 +11,7 @@ enum ContainerPriorities {
CP_BACKGROUND = 0,
CP_DEFAULT,
CP_HOME_CARD,
- CP_DEBUG,
+ CP_SYSTEM_MODAL,
CP_VIRTUAL_KEYBOARD,
};
diff --git a/athena/main/athena_launcher.cc b/athena/main/athena_launcher.cc
index e3470bf..50e9df2 100644
--- a/athena/main/athena_launcher.cc
+++ b/athena/main/athena_launcher.cc
@@ -13,7 +13,6 @@
#include "athena/extensions/public/extensions_delegate.h"
#include "athena/home/public/home_card.h"
#include "athena/input/public/input_manager.h"
-#include "athena/main/debug/debug_window.h"
#include "athena/main/placeholder.h"
#include "athena/main/placeholder.h"
#include "athena/main/url_search_provider.h"
@@ -119,9 +118,9 @@ void StartAthenaEnv(scoped_refptr<base::TaskRunner> file_runner) {
aura::client::SetVisibilityClient(root_window,
env_state->visibility_client.get());
- athena::SystemUI::Create(file_runner);
athena::InputManager::Create()->OnRootWindowCreated(root_window);
athena::ScreenManager::Create(root_window);
+ athena::SystemUI::Create(file_runner);
athena::WindowManager::Create();
athena::AppRegistry::Create();
SetupBackgroundImage();
@@ -142,7 +141,6 @@ void StartAthenaSessionWithContext(content::BrowserContext* context) {
env_state->virtual_keyboard_observer.reset(new VirtualKeyboardObserver);
CreateTestPages(context);
- CreateDebugWindow();
}
void StartAthenaSession(athena::ActivityFactory* activity_factory,
@@ -160,9 +158,9 @@ void ShutdownAthena() {
athena::HomeCard::Shutdown();
athena::AppRegistry::ShutDown();
athena::WindowManager::Shutdown();
+ athena::SystemUI::Shutdown();
athena::ScreenManager::Shutdown();
athena::InputManager::Shutdown();
- athena::SystemUI::Shutdown();
athena::ExtensionsDelegate::Shutdown();
athena::AthenaEnv::Shutdown();
diff --git a/athena/main/athena_main.gyp b/athena/main/athena_main.gyp
index 4e8c3766..d2cecdc 100644
--- a/athena/main/athena_main.gyp
+++ b/athena/main/athena_main.gyp
@@ -14,10 +14,6 @@
'../athena.gyp:athena_lib',
'../athena.gyp:athena_content_lib',
'../resources/athena_resources.gyp:athena_resources',
- # debug_widow.cc depends on this. Remove this once debug_window
- # is removed.
- '../../ash/ash_resources.gyp:ash_resources',
- '../../chromeos/chromeos.gyp:power_manager_proto',
'../../components/components.gyp:component_metrics_proto',
'../../components/components.gyp:history_core_browser',
# infobars_test_support is required to declare some symbols used in the
@@ -45,10 +41,6 @@
'athena_launcher.h',
'athena_renderer_pdf_helper.cc',
'athena_renderer_pdf_helper.h',
- 'debug/debug_window.cc',
- 'debug/debug_window.h',
- 'debug/network_selector.cc',
- 'debug/network_selector.h',
'url_search_provider.cc',
'url_search_provider.h',
'placeholder.cc',
diff --git a/athena/main/debug/DEPS b/athena/main/debug/DEPS
deleted file mode 100644
index 0776021..0000000
--- a/athena/main/debug/DEPS
+++ /dev/null
@@ -1,9 +0,0 @@
-include_rules = [
- "+athena/resources",
- "+chromeos",
- "+third_party/cros_system_api/dbus/service_constants.h",
- "+ui/aura",
- "+ui/chromeos",
- "+ui/gfx",
- "+ui/views",
-]
diff --git a/athena/main/debug/debug_window.cc b/athena/main/debug/debug_window.cc
deleted file mode 100644
index 30f2565..0000000
--- a/athena/main/debug/debug_window.cc
+++ /dev/null
@@ -1,346 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "athena/main/debug/debug_window.h"
-
-#include "athena/common/container_priorities.h"
-#include "athena/main/debug/network_selector.h"
-#include "athena/resources/athena_resources.h"
-#include "athena/screen/public/screen_manager.h"
-#include "base/bind.h"
-#include "base/macros.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
-#include "chromeos/dbus/power_manager_client.h"
-#include "chromeos/dbus/update_engine_client.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
-#include "chromeos/network/network_state_handler_observer.h"
-#include "chromeos/network/network_type_pattern.h"
-#include "ui/aura/window.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/image/image.h"
-#include "ui/gfx/image/image_skia.h"
-#include "ui/gfx/image/image_skia_operations.h"
-#include "ui/views/background.h"
-#include "ui/views/border.h"
-#include "ui/views/controls/image_view.h"
-#include "ui/views/controls/label.h"
-#include "ui/views/layout/box_layout.h"
-#include "ui/views/view.h"
-#include "ui/views/widget/widget.h"
-
-namespace {
-
-views::Label* CreateDebugLabel(const std::string& text) {
- views::Label* label = new views::Label(base::UTF8ToUTF16(text));
- label->SetEnabledColor(SK_ColorWHITE);
- label->SetBackgroundColor(SK_ColorTRANSPARENT);
- label->SetFontList(gfx::FontList().Derive(-2, gfx::Font::BOLD));
- return label;
-}
-
-class PowerStatus : public chromeos::PowerManagerClient::Observer {
- public:
- PowerStatus(views::ImageView* icon, const base::Closure& closure)
- : icon_(icon), closure_(closure) {
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
- this);
- chromeos::DBusThreadManager::Get()
- ->GetPowerManagerClient()
- ->RequestStatusUpdate();
- }
-
- virtual ~PowerStatus() {
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(
- this);
- }
-
- private:
- const gfx::ImageSkia GetPowerIcon(
- const power_manager::PowerSupplyProperties& proto) const {
- // Width and height of battery images.
- const int kBatteryImageHeight = 25;
- const int kBatteryImageWidth = 25;
-
- // Number of different power states.
- const int kNumPowerImages = 15;
-
- gfx::Image all = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- IDR_AURA_UBER_TRAY_POWER_SMALL);
- int horiz_offset = IsCharging(proto) ? 1 : 0;
- int vert_offset = -1;
- if (proto.battery_percent() >= 100) {
- vert_offset = kNumPowerImages - 1;
- } else {
- vert_offset = static_cast<int>((kNumPowerImages - 1) *
- proto.battery_percent() / 100);
- vert_offset = std::max(std::min(vert_offset, kNumPowerImages - 2), 0);
- }
- gfx::Rect region(horiz_offset * kBatteryImageWidth,
- vert_offset * kBatteryImageHeight,
- kBatteryImageWidth,
- kBatteryImageHeight);
- return gfx::ImageSkiaOperations::ExtractSubset(*all.ToImageSkia(), region);
- }
-
- bool IsCharging(const power_manager::PowerSupplyProperties& proto) const {
- return proto.external_power() !=
- power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED;
- }
-
- // chromeos::PowerManagerClient::Observer:
- virtual void PowerChanged(
- const power_manager::PowerSupplyProperties& proto) OVERRIDE {
- icon_->SetImage(GetPowerIcon(proto));
- if (!closure_.is_null())
- closure_.Run();
- }
-
- views::ImageView* icon_;
- base::Closure closure_;
-
- DISALLOW_COPY_AND_ASSIGN(PowerStatus);
-};
-
-class NetworkStatus : public chromeos::NetworkStateHandlerObserver {
- public:
- NetworkStatus(views::Label* label, const base::Closure& closure)
- : label_(label), closure_(closure) {
- chromeos::NetworkStateHandler* handler =
- chromeos::NetworkHandler::Get()->network_state_handler();
- handler->AddObserver(this, FROM_HERE);
- }
-
- virtual ~NetworkStatus() {
- chromeos::NetworkStateHandler* handler =
- chromeos::NetworkHandler::Get()->network_state_handler();
- handler->RemoveObserver(this, FROM_HERE);
- }
-
- private:
- void Update() {
- std::string status = "<unknown>";
- chromeos::NetworkStateHandler* handler =
- chromeos::NetworkHandler::Get()->network_state_handler();
- const chromeos::NetworkState* network = handler->DefaultNetwork();
- if (!network) {
- network = handler->ConnectedNetworkByType(
- chromeos::NetworkTypePattern::NonVirtual());
- }
- if (network) {
- status = base::StringPrintf(
- "%s (%s)", network->ip_address().c_str(), network->name().c_str());
- }
- label_->SetText(base::UTF8ToUTF16(status));
- if (!closure_.is_null())
- closure_.Run();
- }
-
- // chromeos::NetworkStateHandlerObserver:
- virtual void DefaultNetworkChanged(
- const chromeos::NetworkState* network) OVERRIDE {
- Update();
- }
-
- virtual void NetworkConnectionStateChanged(
- const chromeos::NetworkState* network) OVERRIDE {
- Update();
- }
-
- virtual void NetworkPropertiesUpdated(
- const chromeos::NetworkState* network) OVERRIDE {
- Update();
- }
-
- views::Label* label_;
- base::Closure closure_;
-};
-
-void StartUpdateCallback(
- chromeos::UpdateEngineClient::UpdateCheckResult result) {
- VLOG(1) << "Callback from RequestUpdateCheck, result " << result;
-}
-
-class UpdateStatus : public chromeos::UpdateEngineClient::Observer {
- public:
- UpdateStatus(views::ImageView* icon, const base::Closure& closure)
- : icon_(icon), closure_(closure) {
- chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(
- this);
- chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->
- RequestUpdateCheck(base::Bind(StartUpdateCallback));
- }
-
- virtual ~UpdateStatus() {
- chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(
- this);
- }
-
- // chromeos::UpdateEngineClient::Observer:
- virtual void UpdateStatusChanged(
- const chromeos::UpdateEngineClient::Status& status) OVERRIDE {
- if (status.status !=
- chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
- return;
- }
- icon_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
- IDR_AURA_UBER_TRAY_UPDATE));
- if (!closure_.is_null())
- closure_.Run();
- }
-
- private:
- views::ImageView* icon_;
- base::Closure closure_;
-
- DISALLOW_COPY_AND_ASSIGN(UpdateStatus);
-};
-
-// Processes user input to show the detailed network-list.
-class DetailViewHandler : public ui::EventHandler {
- public:
- explicit DetailViewHandler(aura::Window* container) : container_(container) {}
- virtual ~DetailViewHandler() {}
-
- private:
- // ui::EventHandler:
- virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
- if (event->type() == ui::ET_MOUSE_PRESSED) {
- debug::CreateNetworkSelector(container_);
- event->SetHandled();
- }
- }
-
- virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
- if (event->type() == ui::ET_GESTURE_TAP) {
- debug::CreateNetworkSelector(container_);
- event->SetHandled();
- }
- }
-
- aura::Window* container_;
-
- DISALLOW_COPY_AND_ASSIGN(DetailViewHandler);
-};
-
-class DebugWidget {
- public:
- DebugWidget() : container_(NULL), widget_(NULL) {
- CreateContainer();
- CreateWidget();
-
- CreateBatteryView();
- CreateUpdateView();
- CreateNetworkView();
-
- UpdateSize();
- }
-
- virtual ~DebugWidget() {}
-
- private:
- void CreateContainer() {
- athena::ScreenManager::ContainerParams params("DebugContainer",
- athena::CP_DEBUG);
- params.can_activate_children = true;
- container_ = athena::ScreenManager::Get()->CreateContainer(params);
- }
-
- void CreateWidget() {
- views::Widget::InitParams params;
- params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
- params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
- params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
- params.accept_events = true;
- params.bounds = gfx::Rect(200, 0, 100, 105);
- params.parent = container_;
- widget_ = new views::Widget();
- widget_->Init(params);
-
- event_handler_.reset(new DetailViewHandler(container_));
-
- const int kHorizontalSpacing = 10;
- const int kBorderVerticalSpacing = 3;
- const int kBetweenChildSpacing = 10;
- const int kBackgroundColor = SkColorSetARGB(0x7f, 0, 0, 0);
- views::View* container = new views::View;
- container->SetLayoutManager(
- new views::BoxLayout(views::BoxLayout::kHorizontal,
- kHorizontalSpacing,
- kBorderVerticalSpacing,
- kBetweenChildSpacing));
- container->set_background(
- views::Background::CreateSolidBackground(kBackgroundColor));
- container->SetBorder(views::Border::CreateSolidBorder(1, kBackgroundColor));
- container->set_target_handler(event_handler_.get());
- widget_->SetContentsView(container);
- widget_->StackAtTop();
- widget_->Show();
-
- widget_->SetBounds(gfx::Rect(600, 0, 300, 25));
- }
-
- void CreateBatteryView() {
- views::View* container = widget_->GetContentsView();
- views::ImageView* icon = new views::ImageView();
- container->AddChildView(icon);
- container->Layout();
-
- power_status_.reset(new PowerStatus(
- icon, base::Bind(&DebugWidget::UpdateSize, base::Unretained(this))));
- }
-
- void CreateNetworkView() {
- views::View* container = widget_->GetContentsView();
- container->AddChildView(CreateDebugLabel("Network:"));
-
- views::Label* label = CreateDebugLabel(std::string());
- container->AddChildView(label);
- container->Layout();
-
- network_status_.reset(new NetworkStatus(
- label, base::Bind(&DebugWidget::UpdateSize, base::Unretained(this))));
- }
-
- void CreateUpdateView() {
- views::View* container = widget_->GetContentsView();
- views::ImageView* icon = new views::ImageView();
- container->AddChildView(icon);
- container->Layout();
-
- update_status_.reset(new UpdateStatus(
- icon, base::Bind(&DebugWidget::UpdateSize, base::Unretained(this))));
- }
-
- const gfx::Rect GetPositionForSize(const gfx::Size& size) {
- int right = container_->bounds().right();
- int x = right - size.width();
- return gfx::Rect(x, 0, size.width(), size.height());
- }
-
- void UpdateSize() {
- views::View* container = widget_->GetContentsView();
- container->Layout();
- gfx::Size size = container->GetPreferredSize();
- widget_->SetBounds(GetPositionForSize(size));
- }
-
- aura::Window* container_;
- views::Widget* widget_;
- scoped_ptr<PowerStatus> power_status_;
- scoped_ptr<NetworkStatus> network_status_;
- scoped_ptr<UpdateStatus> update_status_;
- scoped_ptr<ui::EventHandler> event_handler_;
-
- DISALLOW_COPY_AND_ASSIGN(DebugWidget);
-};
-
-} // namespace
-
-void CreateDebugWindow() {
- new DebugWidget();
-}
diff --git a/athena/main/debug/debug_window.h b/athena/main/debug/debug_window.h
deleted file mode 100644
index 68c17ce..0000000
--- a/athena/main/debug/debug_window.h
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ATHENA_MAIN_DEBUG_DEBUG_WINDOW_H_
-#define ATHENA_MAIN_DEBUG_DEBUG_WINDOW_H_
-
-void CreateDebugWindow();
-
-#endif // ATHENA_MAIN_DEBUG_DEBUG_WINDOW_H_
diff --git a/athena/main/placeholder.cc b/athena/main/placeholder.cc
index f14cb62..7bdc086 100644
--- a/athena/main/placeholder.cc
+++ b/athena/main/placeholder.cc
@@ -7,7 +7,7 @@
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h"
#include "athena/resources/grit/athena_resources.h"
-#include "athena/screen/public/screen_manager.h"
+#include "athena/system/public/system_ui.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
@@ -26,5 +26,5 @@ void CreateTestPages(content::BrowserContext* browser_context) {
void SetupBackgroundImage() {
const gfx::ImageSkia wallpaper = *ui::ResourceBundle::GetSharedInstance()
.GetImageSkiaNamed(IDR_ATHENA_BACKGROUND);
- athena::ScreenManager::Get()->SetBackgroundImage(wallpaper);
+ athena::SystemUI::Get()->SetBackgroundImage(wallpaper);
}
diff --git a/athena/screen/DEPS b/athena/screen/DEPS
index df60728..1809145 100644
--- a/athena/screen/DEPS
+++ b/athena/screen/DEPS
@@ -1,16 +1,8 @@
include_rules = [
"+athena/input/public",
- "+third_party/skia/include/core/SkColor.h",
"+ui/aura",
"+ui/compositor",
"+ui/events",
"+ui/gfx",
- "+ui/views",
"+ui/wm",
]
-
-specific_include_rules = {
- "background_controller.cc": [
- "+extensions/shell/common/version.h",
- ],
-}
diff --git a/athena/screen/public/screen_manager.h b/athena/screen/public/screen_manager.h
index 52dd805..df1dfe3 100644
--- a/athena/screen/public/screen_manager.h
+++ b/athena/screen/public/screen_manager.h
@@ -14,11 +14,6 @@ namespace aura {
class Window;
}
-namespace gfx {
-class ImageSkia;
-class Insets;
-}
-
namespace ui {
class LayerAnimator;
}
@@ -68,9 +63,6 @@ class ATHENA_EXPORT ScreenManager {
// Return the context object to be used for widget creation.
virtual aura::Window* GetContext() = 0;
- // Sets the background image.
- virtual void SetBackgroundImage(const gfx::ImageSkia& image) = 0;
-
// Set screen rotation.
// TODO(flackr): Extract and use ash DisplayManager to set rotation
// instead: http://crbug.com/401044.
diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc
index a154d52..f37d99b 100644
--- a/athena/screen/screen_manager_impl.cc
+++ b/athena/screen/screen_manager_impl.cc
@@ -7,7 +7,6 @@
#include "athena/common/container_priorities.h"
#include "athena/common/fill_layout_manager.h"
#include "athena/input/public/accelerator_manager.h"
-#include "athena/screen/background_controller.h"
#include "athena/screen/screen_accelerator_handler.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -192,7 +191,7 @@ class AthenaEventTargeter : public aura::WindowTargeter,
class ScreenManagerImpl : public ScreenManager {
public:
- ScreenManagerImpl(aura::Window* root_window);
+ explicit ScreenManagerImpl(aura::Window* root_window);
virtual ~ScreenManagerImpl();
void Init();
@@ -203,16 +202,13 @@ class ScreenManagerImpl : public ScreenManager {
const ContainerParams& params) OVERRIDE;
virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE;
virtual aura::Window* GetContext() OVERRIDE { return root_window_; }
- virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE;
virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE;
virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE;
// Not owned.
aura::Window* root_window_;
- aura::Window* background_window_;
scoped_ptr<aura::client::FocusClient> focus_client_;
- scoped_ptr<BackgroundController> background_controller_;
scoped_ptr<aura::client::WindowTreeClient> window_tree_client_;
scoped_ptr<AcceleratorHandler> accelerator_handler_;
scoped_ptr< ::wm::ScopedCaptureClient> capture_client_;
@@ -248,15 +244,7 @@ void ScreenManagerImpl::Init() {
aura::client::SetActivationClient(root_window_, focus_controller);
focus_client_.reset(focus_controller);
- // TODO(oshima): Move the background out from ScreenManager.
root_window_->SetLayoutManager(new FillLayoutManager(root_window_));
- background_window_ =
- CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND));
-
- background_window_->SetLayoutManager(
- new FillLayoutManager(background_window_));
- background_controller_.reset(new BackgroundController(background_window_));
-
capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_));
accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_));
}
@@ -340,10 +328,6 @@ aura::Window* ScreenManagerImpl::CreateContainer(
return container;
}
-void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) {
- background_controller_->SetImage(image);
-}
-
void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) {
if (rotation ==
gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()) {
diff --git a/athena/system/DEPS b/athena/system/DEPS
index c3952d8..9e96017 100644
--- a/athena/system/DEPS
+++ b/athena/system/DEPS
@@ -1,7 +1,15 @@
include_rules = [
+ "+athena/resources",
"+athena/screen/public",
"+athena/system/public",
- "+chromeos/dbus",
+ "+chromeos",
+ "+third_party/cros_system_api/dbus/service_constants.h",
+ "+third_party/skia/include",
"+ui",
]
+specific_include_rules = {
+ "status_icon_container_view.cc": [
+ "+extensions/shell/common/version.h",
+ ],
+}
diff --git a/athena/screen/background_controller.cc b/athena/system/background_controller.cc
index bcdf40f..f4d346a 100644
--- a/athena/screen/background_controller.cc
+++ b/athena/system/background_controller.cc
@@ -2,55 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "athena/screen/background_controller.h"
+#include "athena/system/background_controller.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
-#include "extensions/shell/common/version.h"
-#include "third_party/skia/include/core/SkColor.h"
+#include "athena/system/public/system_ui.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia.h"
-#include "ui/views/controls/label.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
namespace athena {
-namespace {
-
-const SkColor kVersionColor = SK_ColorWHITE;
-const SkColor kVersionBackground = SK_ColorTRANSPARENT;
-const SkColor kVersionShadow = 0xB0000000;
-const int kVersionShadowBlur = 10;
-
-class VersionView : public views::Label {
- public:
- VersionView() {
- SetEnabledColor(kVersionColor);
- SetBackgroundColor(kVersionBackground);
- SetShadows(gfx::ShadowValues(1, gfx::ShadowValue(gfx::Point(0, 1),
- kVersionShadowBlur,
- kVersionShadow)));
- SetText(base::UTF8ToUTF16(base::StringPrintf("%s (Build %s)",
- PRODUCT_VERSION,
- LAST_CHANGE)));
- SetBoundsRect(gfx::Rect(gfx::Point(), GetPreferredSize()));
- }
- virtual ~VersionView() {
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VersionView);
-};
-
-} // namespace
-
class BackgroundView : public views::View {
public:
- BackgroundView() {
- AddChildView(new VersionView);
+ BackgroundView()
+ : time_view_(SystemUI::Get()->CreateTimeView()),
+ status_icon_view_(SystemUI::Get()->CreateStatusIconView()) {
+ AddChildView(time_view_);
+ AddChildView(status_icon_view_);
}
virtual ~BackgroundView() {}
@@ -59,7 +29,22 @@ class BackgroundView : public views::View {
SchedulePaint();
}
- // views::View
+ // views::View:
+ virtual void Layout() OVERRIDE {
+ time_view_->SetBoundsRect(gfx::Rect(time_view_->GetPreferredSize()));
+ gfx::Size status_icon_preferred_size =
+ status_icon_view_->GetPreferredSize();
+ status_icon_view_->SetBounds(width() - status_icon_preferred_size.width(),
+ 0,
+ status_icon_preferred_size.width(),
+ status_icon_preferred_size.height());
+ }
+
+ virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE {
+ // Relayout when |status_icon_view_| changes its preferred size.
+ Layout();
+ }
+
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
canvas->DrawImageInt(image_,
0,
@@ -75,20 +60,17 @@ class BackgroundView : public views::View {
private:
gfx::ImageSkia image_;
+ views::View* time_view_;
+ views::View* status_icon_view_;
DISALLOW_COPY_AND_ASSIGN(BackgroundView);
};
-BackgroundController::BackgroundController(aura::Window* container) {
- // TODO(oshima): Using widget to just draw an image is probably
- // overkill. Just use WindowDelegate to draw the background and
- // remove dependency to ui/views.
-
+BackgroundController::BackgroundController(aura::Window* background_container) {
views::Widget* background_widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- params.accept_events = false;
- params.parent = container;
+ params.parent = background_container;
background_widget->Init(params);
background_widget->GetNativeWindow()->layer()->SetMasksToBounds(true);
background_view_ = new BackgroundView;
diff --git a/athena/screen/background_controller.h b/athena/system/background_controller.h
index cdc0d35..0ddda7c 100644
--- a/athena/screen/background_controller.h
+++ b/athena/system/background_controller.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ATHENA_SCREEN_BACKGROUND_CONTROLLER_H_
-#define ATHENA_SCREEN_BACKGROUND_CONTROLLER_H_
+#ifndef ATHENA_SYSTEM_BACKGROUND_CONTROLLER_H_
+#define ATHENA_SYSTEM_BACKGROUND_CONTROLLER_H_
#include "base/macros.h"
@@ -21,7 +21,7 @@ class BackgroundView;
// Controls background image switching.
class BackgroundController {
public:
- explicit BackgroundController(aura::Window* container);
+ explicit BackgroundController(aura::Window* background_container);
~BackgroundController();
void SetImage(const gfx::ImageSkia& image);
@@ -31,6 +31,7 @@ class BackgroundController {
DISALLOW_COPY_AND_ASSIGN(BackgroundController);
};
-}
-#endif // ATHENA_SCREEN_BACKGROUND_CONTROLLER_H_
+} // namespace athena
+
+#endif // ATHENA_SYSTEM_BACKGROUND_CONTROLLER_H_
diff --git a/athena/main/debug/network_selector.cc b/athena/system/network_selector.cc
index 9102e10..d6e4f01 100644
--- a/athena/main/debug/network_selector.cc
+++ b/athena/system/network_selector.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "athena/main/debug/network_selector.h"
+#include "athena/system/network_selector.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/utf_string_conversions.h"
@@ -460,10 +460,10 @@ class NetworkSelector : public ui::NetworkListDelegate,
} // namespace
-namespace debug {
+namespace athena {
void CreateNetworkSelector(aura::Window* container) {
new NetworkSelector(container);
}
-} // namespace debug
+} // namespace athena
diff --git a/athena/main/debug/network_selector.h b/athena/system/network_selector.h
index b839129..90aaf7f 100644
--- a/athena/main/debug/network_selector.h
+++ b/athena/system/network_selector.h
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ATHENA_MAIN_DEBUG_NETWORK_SELECTOR_H_
-#define ATHENA_MAIN_DEBUG_NETWORK_SELECTOR_H_
+#ifndef ATHENA_SYSTEM_NETWORK_SELECTOR_H_
+#define ATHENA_SYSTEM_NETWORK_SELECTOR_H_
namespace aura {
class Window;
}
-namespace debug {
+namespace athena {
void CreateNetworkSelector(aura::Window* window);
-} // namespace debug
+} // namespace athena
-#endif // ATHENA_MAIN_DEBUG_NETWORK_SELECTOR_H_
+#endif // ATHENA_SYSTEM_NETWORK_SELECTOR_H_
diff --git a/athena/system/public/system_ui.h b/athena/system/public/system_ui.h
index 0032c54..4cd04d0 100644
--- a/athena/system/public/system_ui.h
+++ b/athena/system/public/system_ui.h
@@ -12,15 +12,33 @@ namespace base {
class TaskRunner;
}
+namespace gfx {
+class ImageSkia;
+}
+
+namespace views {
+class View;
+}
+
namespace athena {
class ATHENA_EXPORT SystemUI {
public:
// Creates and deletes the singleton object of the SystemUI implementation.
static SystemUI* Create(scoped_refptr<base::TaskRunner> io_task_runner);
+ static SystemUI* Get();
static void Shutdown();
virtual ~SystemUI() {}
+
+ // Sets the background image.
+ virtual void SetBackgroundImage(const gfx::ImageSkia& image) = 0;
+
+ // Creates a view which displays the time.
+ virtual views::View* CreateTimeView() = 0;
+
+ // Creates a view which displays status icons and debug information.
+ virtual views::View* CreateStatusIconView() = 0;
};
} // namespace athena
diff --git a/athena/system/status_icon_container_view.cc b/athena/system/status_icon_container_view.cc
new file mode 100644
index 0000000..afb3895
--- /dev/null
+++ b/athena/system/status_icon_container_view.cc
@@ -0,0 +1,242 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/system/status_icon_container_view.h"
+
+#include "athena/resources/athena_resources.h"
+#include "athena/system/network_selector.h"
+#include "base/bind.h"
+#include "base/macros.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
+#include "chromeos/dbus/power_manager_client.h"
+#include "chromeos/dbus/update_engine_client.h"
+#include "chromeos/network/network_state.h"
+#include "chromeos/network/network_state_handler.h"
+#include "chromeos/network/network_state_handler_observer.h"
+#include "chromeos/network/network_type_pattern.h"
+#include "extensions/shell/common/version.h"
+#include "ui/aura/window.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/image/image_skia_operations.h"
+#include "ui/views/controls/image_view.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/box_layout.h"
+
+namespace athena {
+namespace {
+
+views::Label* CreateLabel(const std::string& text) {
+ views::Label* label = new views::Label(base::UTF8ToUTF16(text));
+ label->SetEnabledColor(SK_ColorWHITE);
+ label->SetAutoColorReadabilityEnabled(false);
+ label->SetFontList(gfx::FontList().DeriveWithStyle(gfx::Font::BOLD));
+ return label;
+}
+
+} // namespace
+
+class StatusIconContainerView::PowerStatus
+ : public chromeos::PowerManagerClient::Observer {
+ public:
+ explicit PowerStatus(views::ImageView* icon) : icon_(icon) {
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
+ this);
+ chromeos::DBusThreadManager::Get()
+ ->GetPowerManagerClient()
+ ->RequestStatusUpdate();
+ }
+
+ virtual ~PowerStatus() {
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(
+ this);
+ }
+
+ private:
+ const gfx::ImageSkia GetPowerIcon(
+ const power_manager::PowerSupplyProperties& proto) const {
+ // Width and height of battery images.
+ const int kBatteryImageHeight = 25;
+ const int kBatteryImageWidth = 25;
+
+ // Number of different power states.
+ const int kNumPowerImages = 15;
+
+ gfx::Image all = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_AURA_UBER_TRAY_POWER_SMALL);
+ int horiz_offset = IsCharging(proto) ? 1 : 0;
+ int vert_offset = -1;
+ if (proto.battery_percent() >= 100) {
+ vert_offset = kNumPowerImages - 1;
+ } else {
+ vert_offset = static_cast<int>((kNumPowerImages - 1) *
+ proto.battery_percent() / 100);
+ vert_offset = std::max(std::min(vert_offset, kNumPowerImages - 2), 0);
+ }
+ gfx::Rect region(horiz_offset * kBatteryImageWidth,
+ vert_offset * kBatteryImageHeight,
+ kBatteryImageWidth,
+ kBatteryImageHeight);
+ return gfx::ImageSkiaOperations::ExtractSubset(*all.ToImageSkia(), region);
+ }
+
+ bool IsCharging(const power_manager::PowerSupplyProperties& proto) const {
+ return proto.external_power() !=
+ power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED;
+ }
+
+ // chromeos::PowerManagerClient::Observer:
+ virtual void PowerChanged(
+ const power_manager::PowerSupplyProperties& proto) OVERRIDE {
+ icon_->SetImage(GetPowerIcon(proto));
+ }
+
+ views::ImageView* icon_;
+
+ DISALLOW_COPY_AND_ASSIGN(PowerStatus);
+};
+
+class StatusIconContainerView::NetworkStatus
+ : public chromeos::NetworkStateHandlerObserver {
+ public:
+ explicit NetworkStatus(views::Label* label) : label_(label) {
+ chromeos::NetworkStateHandler* handler =
+ chromeos::NetworkHandler::Get()->network_state_handler();
+ handler->AddObserver(this, FROM_HERE);
+ }
+
+ virtual ~NetworkStatus() {
+ chromeos::NetworkStateHandler* handler =
+ chromeos::NetworkHandler::Get()->network_state_handler();
+ handler->RemoveObserver(this, FROM_HERE);
+ }
+
+ private:
+ void Update() {
+ std::string status = "<unknown>";
+ chromeos::NetworkStateHandler* handler =
+ chromeos::NetworkHandler::Get()->network_state_handler();
+ const chromeos::NetworkState* network = handler->DefaultNetwork();
+ if (!network) {
+ network = handler->ConnectedNetworkByType(
+ chromeos::NetworkTypePattern::NonVirtual());
+ }
+ if (network) {
+ status = base::StringPrintf(
+ "%s (%s)", network->ip_address().c_str(), network->name().c_str());
+ }
+ label_->SetText(base::UTF8ToUTF16(status));
+ }
+
+ // chromeos::NetworkStateHandlerObserver:
+ virtual void DefaultNetworkChanged(
+ const chromeos::NetworkState* network) OVERRIDE {
+ Update();
+ }
+
+ virtual void NetworkConnectionStateChanged(
+ const chromeos::NetworkState* network) OVERRIDE {
+ Update();
+ }
+
+ virtual void NetworkPropertiesUpdated(
+ const chromeos::NetworkState* network) OVERRIDE {
+ Update();
+ }
+
+ views::Label* label_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkStatus);
+};
+
+void StartUpdateCallback(
+ chromeos::UpdateEngineClient::UpdateCheckResult result) {
+ VLOG(1) << "Callback from RequestUpdateCheck, result " << result;
+}
+
+class StatusIconContainerView::UpdateStatus
+ : public chromeos::UpdateEngineClient::Observer {
+ public:
+ explicit UpdateStatus(views::ImageView* icon) : icon_(icon) {
+ chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(
+ this);
+ chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->
+ RequestUpdateCheck(base::Bind(StartUpdateCallback));
+ }
+
+ virtual ~UpdateStatus() {
+ chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(
+ this);
+ }
+
+ // chromeos::UpdateEngineClient::Observer:
+ virtual void UpdateStatusChanged(
+ const chromeos::UpdateEngineClient::Status& status) OVERRIDE {
+ if (status.status !=
+ chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
+ return;
+ }
+ icon_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
+ IDR_AURA_UBER_TRAY_UPDATE));
+ }
+
+ private:
+ views::ImageView* icon_;
+
+ DISALLOW_COPY_AND_ASSIGN(UpdateStatus);
+};
+
+StatusIconContainerView::StatusIconContainerView(
+ aura::Window* system_modal_container)
+ : system_modal_container_(system_modal_container) {
+ const int kHorizontalSpacing = 10;
+ const int kVerticalSpacing = 3;
+ const int kBetweenChildSpacing = 10;
+ SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
+ kHorizontalSpacing,
+ kVerticalSpacing,
+ kBetweenChildSpacing));
+
+ std::string version_text =
+ base::StringPrintf("%s (Build %s)", PRODUCT_VERSION, LAST_CHANGE);
+ AddChildView(CreateLabel(version_text));
+
+ AddChildView(CreateLabel("Network:"));
+ views::Label* network_label = CreateLabel(std::string());
+ AddChildView(network_label);
+ network_status_.reset(new NetworkStatus(network_label));
+
+ views::ImageView* battery_view = new views::ImageView();
+ AddChildView(battery_view);
+ power_status_.reset(new PowerStatus(battery_view));
+
+ views::ImageView* update_view = new views::ImageView();
+ AddChildView(update_view);
+ update_status_.reset(new UpdateStatus(update_view));
+}
+
+StatusIconContainerView::~StatusIconContainerView() {
+}
+
+bool StatusIconContainerView::OnMousePressed(const ui::MouseEvent& event) {
+ CreateNetworkSelector(system_modal_container_);
+ return true;
+}
+
+void StatusIconContainerView::OnGestureEvent(ui::GestureEvent* event) {
+ if (event->type() == ui::ET_GESTURE_TAP) {
+ CreateNetworkSelector(system_modal_container_);
+ event->SetHandled();
+ }
+}
+
+void StatusIconContainerView::ChildPreferredSizeChanged(views::View* child) {
+ PreferredSizeChanged();
+}
+
+} // namespace athena
diff --git a/athena/system/status_icon_container_view.h b/athena/system/status_icon_container_view.h
new file mode 100644
index 0000000..e011ba3
--- /dev/null
+++ b/athena/system/status_icon_container_view.h
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATHENA_SYSTEM_STATUS_ICON_CONTAINER_VIEW_H_
+#define ATHENA_SYSTEM_STATUS_ICON_CONTAINER_VIEW_H_
+
+#include "athena/system/public/system_ui.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/views/view.h"
+
+namespace aura {
+class Window;
+}
+
+namespace athena {
+
+// View which displays the system tray icons.
+class StatusIconContainerView : public views::View {
+ public:
+ explicit StatusIconContainerView(aura::Window* system_modal_container);
+ virtual ~StatusIconContainerView();
+
+ private:
+ // views::View:
+ virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
+ virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
+ virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
+
+ // Parent container that the "select network" dialog should use.
+ aura::Window* system_modal_container_;
+
+ class PowerStatus;
+ scoped_ptr<PowerStatus> power_status_;
+
+ class NetworkStatus;
+ scoped_ptr<NetworkStatus> network_status_;
+
+ class UpdateStatus;
+ scoped_ptr<UpdateStatus> update_status_;
+
+ DISALLOW_COPY_AND_ASSIGN(StatusIconContainerView);
+};
+
+} // namespace athena
+
+#endif // ATHENA_SYSTEM_STATUS_ICON_CONTAINER_VIEW_H_
diff --git a/athena/system/system_ui_impl.cc b/athena/system/system_ui_impl.cc
index b3bacb5..7e4ee5b 100644
--- a/athena/system/system_ui_impl.cc
+++ b/athena/system/system_ui_impl.cc
@@ -4,12 +4,19 @@
#include "athena/system/public/system_ui.h"
+#include "athena/common/container_priorities.h"
+#include "athena/common/fill_layout_manager.h"
+#include "athena/screen/public/screen_manager.h"
+#include "athena/system/background_controller.h"
#include "athena/system/device_socket_listener.h"
#include "athena/system/orientation_controller.h"
#include "athena/system/power_button_controller.h"
+#include "athena/system/status_icon_container_view.h"
+#include "athena/system/time_view.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "ui/aura/window.h"
namespace athena {
namespace {
@@ -20,7 +27,9 @@ class SystemUIImpl : public SystemUI {
public:
SystemUIImpl(scoped_refptr<base::TaskRunner> file_task_runner)
: orientation_controller_(new OrientationController()),
- power_button_controller_(new PowerButtonController) {
+ power_button_controller_(new PowerButtonController),
+ background_container_(NULL),
+ system_modal_container_(NULL) {
orientation_controller_->InitWith(file_task_runner);
}
@@ -30,9 +39,43 @@ class SystemUIImpl : public SystemUI {
orientation_controller_->Shutdown();
}
+ void Init() {
+ background_container_ = ScreenManager::Get()->CreateContainer(
+ ScreenManager::ContainerParams("AthenaBackground", CP_BACKGROUND));
+ background_container_->SetLayoutManager(
+ new FillLayoutManager(background_container_));
+ ScreenManager::ContainerParams system_modal_params(
+ "AthenaSystemModalContainer", CP_SYSTEM_MODAL);
+ system_modal_params.can_activate_children = true;
+ system_modal_container_ =
+ ScreenManager::Get()->CreateContainer(system_modal_params);
+
+ background_controller_.reset(
+ new BackgroundController(background_container_));
+ }
+
+ virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE {
+ background_controller_->SetImage(image);
+ }
+
+ virtual views::View* CreateTimeView() OVERRIDE {
+ return new TimeView;
+ }
+
+ virtual views::View* CreateStatusIconView() OVERRIDE {
+ return new StatusIconContainerView(system_modal_container_);
+ }
+
private:
scoped_refptr<OrientationController> orientation_controller_;
scoped_ptr<PowerButtonController> power_button_controller_;
+ scoped_ptr<BackgroundController> background_controller_;
+
+ // The parent container for the background.
+ aura::Window* background_container_;
+
+ // The parent container used by the "select network" dialog.
+ aura::Window* system_modal_container_;
DISALLOW_COPY_AND_ASSIGN(SystemUIImpl);
};
@@ -42,7 +85,15 @@ class SystemUIImpl : public SystemUI {
// static
SystemUI* SystemUI::Create(scoped_refptr<base::TaskRunner> file_task_runner) {
DeviceSocketListener::CreateSocketManager(file_task_runner);
- instance = new SystemUIImpl(file_task_runner);
+ SystemUIImpl* system_ui = new SystemUIImpl(file_task_runner);
+ instance = system_ui;
+ system_ui->Init();
+ return instance;
+}
+
+// static
+SystemUI* SystemUI::Get() {
+ DCHECK(instance);
return instance;
}
diff --git a/athena/system/time_view.cc b/athena/system/time_view.cc
new file mode 100644
index 0000000..e32cb26
--- /dev/null
+++ b/athena/system/time_view.cc
@@ -0,0 +1,69 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/system/time_view.h"
+
+#include "base/i18n/time_formatting.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/views/border.h"
+
+namespace athena {
+namespace {
+
+// Amount of slop to add into the timer to make sure we're into the next minute
+// when the timer goes off.
+const int kTimerSlopSeconds = 1;
+
+} // namespace
+
+TimeView::TimeView() {
+ SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ SetEnabledColor(SK_ColorWHITE);
+ SetAutoColorReadabilityEnabled(false);
+ SetFontList(gfx::FontList().DeriveWithStyle(gfx::Font::BOLD));
+
+ const int kHorizontalSpacing = 10;
+ const int kVerticalSpacing = 3;
+ SetBorder(views::Border::CreateEmptyBorder(kVerticalSpacing,
+ kHorizontalSpacing,
+ kVerticalSpacing,
+ kHorizontalSpacing));
+
+ UpdateText();
+}
+
+TimeView::~TimeView() {
+}
+
+void TimeView::SetTimer(base::Time now) {
+ // Try to set the timer to go off at the next change of the minute. We don't
+ // want to have the timer go off more than necessary since that will cause
+ // the CPU to wake up and consume power.
+ base::Time::Exploded exploded;
+ now.LocalExplode(&exploded);
+
+ // Often this will be called at minute boundaries, and we'll actually want
+ // 60 seconds from now.
+ int seconds_left = 60 - exploded.second;
+ if (seconds_left == 0)
+ seconds_left = 60;
+
+ // Make sure that the timer fires on the next minute. Without this, if it is
+ // called just a teeny bit early, then it will skip the next minute.
+ seconds_left += kTimerSlopSeconds;
+
+ timer_.Stop();
+ timer_.Start(
+ FROM_HERE, base::TimeDelta::FromSeconds(seconds_left),
+ this, &TimeView::UpdateText);
+}
+
+void TimeView::UpdateText() {
+ base::Time now = base::Time::Now();
+ SetText(base::TimeFormatTimeOfDayWithHourClockType(
+ now, base::k12HourClock, base::kKeepAmPm));
+ SetTimer(now);
+}
+
+} // namespace athena
diff --git a/athena/system/time_view.h b/athena/system/time_view.h
new file mode 100644
index 0000000..7dc0bd4
--- /dev/null
+++ b/athena/system/time_view.h
@@ -0,0 +1,35 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATHENA_SYSTEM_TIME_VIEW_H_
+#define ATHENA_SYSTEM_TIME_VIEW_H_
+
+#include "athena/system/public/system_ui.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "ui/views/controls/label.h"
+
+namespace athena {
+
+// View which displays the current time.
+class TimeView : public views::Label {
+ public:
+ TimeView();
+ virtual ~TimeView();
+
+ private:
+ // Starts |timer_| to schedule the next update.
+ void SetTimer(base::Time now);
+
+ // Updates the current time.
+ void UpdateText();
+
+ base::OneShotTimer<TimeView> timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(TimeView);
+};
+
+} // namespace athena
+
+#endif // ATHENA_SYSTEM_TIME_VIEW_H_
diff --git a/athena/test/DEPS b/athena/test/DEPS
index 17f2f02..b5f666b 100644
--- a/athena/test/DEPS
+++ b/athena/test/DEPS
@@ -7,7 +7,7 @@ include_rules = [
"+athena/screen/public",
"+athena/main",
"+athena/resource_manager/public",
- "+chromeos/dbus",
+ "+chromeos",
"+third_party/skia/include",
"+ui/app_list",
"+ui/aura",
diff --git a/athena/test/athena_test_helper.cc b/athena/test/athena_test_helper.cc
index 251311b..b2e7f94 100644
--- a/athena/test/athena_test_helper.cc
+++ b/athena/test/athena_test_helper.cc
@@ -13,6 +13,7 @@
#include "base/run_loop.h"
#include "base/threading/thread.h"
#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/network/network_handler.h"
#include "ui/aura/env.h"
#include "ui/aura/input_state_lookup.h"
#include "ui/aura/test/env_test_helper.h"
@@ -49,6 +50,7 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
file_thread_->StartWithOptions(options);
chromeos::DBusThreadManager::Initialize();
+ chromeos::NetworkHandler::Initialize();
ui::InitializeInputMethodForTesting();
aura::Env::CreateInstance(true);
aura::Env::GetInstance()->set_context_factory(context_factory);
@@ -75,6 +77,7 @@ void AthenaTestHelper::TearDown() {
#endif
ui::ShutdownInputMethodForTesting();
+ chromeos::NetworkHandler::Shutdown();
chromeos::DBusThreadManager::Shutdown();
}