Commit 1d81edd7 authored by sadrul@chromium.org's avatar sadrul@chromium.org

ash: Some code-cleanup in the system-tray code.

Move the remaining status-area code into system-tray.

BUG=none
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10140017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133686 0039d316-1c4b-4281-b951-d872f2087c98
parent 5e042e9c
...@@ -117,8 +117,6 @@ ...@@ -117,8 +117,6 @@
'shell_delegate.h', 'shell_delegate.h',
'shell_factory.h', 'shell_factory.h',
'shell_window_ids.h', 'shell_window_ids.h',
'status_area/status_area_view.cc',
'status_area/status_area_view.h',
'system/audio/audio_observer.h', 'system/audio/audio_observer.h',
'system/audio/tray_volume.cc', 'system/audio/tray_volume.cc',
'system/audio/tray_volume.h', 'system/audio/tray_volume.h',
...@@ -152,6 +150,8 @@ ...@@ -152,6 +150,8 @@
'system/tray/system_tray_delegate.h', 'system/tray/system_tray_delegate.h',
'system/tray/system_tray_item.cc', 'system/tray/system_tray_item.cc',
'system/tray/system_tray_item.h', 'system/tray/system_tray_item.h',
'system/tray/system_tray_widget_delegate.cc',
'system/tray/system_tray_widget_delegate.h',
'system/tray/tray_constants.cc', 'system/tray/tray_constants.cc',
'system/tray/tray_constants.h', 'system/tray/tray_constants.h',
'system/tray/tray_empty.cc', 'system/tray/tray_empty.cc',
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include "ash/launcher/launcher.h" #include "ash/launcher/launcher.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
#include "ash/status_area/status_area_view.h" #include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_widget_delegate.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/shell_factory.h" #include "ash/shell_factory.h"
...@@ -30,6 +31,12 @@ internal::StatusAreaView* GetStatusAreaView(views::Widget* widget) { ...@@ -30,6 +31,12 @@ internal::StatusAreaView* GetStatusAreaView(views::Widget* widget) {
widget->GetContentsView()); widget->GetContentsView());
} }
SystemTray* CreateSystemTray() {
SystemTray* tray = new SystemTray;
tray->CreateWidget();
return tray;
}
} // namespace } // namespace
typedef AshTestBase FocusCyclerTest; typedef AshTestBase FocusCyclerTest;
...@@ -54,10 +61,10 @@ TEST_F(FocusCyclerTest, CycleFocusForward) { ...@@ -54,10 +61,10 @@ TEST_F(FocusCyclerTest, CycleFocusForward) {
scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
// Add the Status area // Add the Status area
views::Widget* status_widget = internal::CreateStatusArea(NULL); scoped_ptr<SystemTray> tray(CreateSystemTray());
ASSERT_TRUE(status_widget); ASSERT_TRUE(tray->widget());
focus_cycler->AddWidget(status_widget); focus_cycler->AddWidget(tray->widget());
GetStatusAreaView(status_widget)->SetFocusCyclerForTesting( GetStatusAreaView(tray->widget())->SetFocusCyclerForTesting(
focus_cycler.get()); focus_cycler.get());
// Add the launcher // Add the launcher
...@@ -77,7 +84,7 @@ TEST_F(FocusCyclerTest, CycleFocusForward) { ...@@ -77,7 +84,7 @@ TEST_F(FocusCyclerTest, CycleFocusForward) {
// Cycle focus to the status area // Cycle focus to the status area
focus_cycler->RotateFocus(FocusCycler::FORWARD); focus_cycler->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(status_widget->IsActive()); EXPECT_TRUE(tray->widget()->IsActive());
// Cycle focus to the launcher // Cycle focus to the launcher
focus_cycler->RotateFocus(FocusCycler::FORWARD); focus_cycler->RotateFocus(FocusCycler::FORWARD);
...@@ -92,10 +99,10 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) { ...@@ -92,10 +99,10 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) {
scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
// Add the Status area // Add the Status area
views::Widget* status_widget = internal::CreateStatusArea(NULL); scoped_ptr<SystemTray> tray(CreateSystemTray());
ASSERT_TRUE(status_widget); ASSERT_TRUE(tray->widget());
focus_cycler->AddWidget(status_widget); focus_cycler->AddWidget(tray->widget());
GetStatusAreaView(status_widget)->SetFocusCyclerForTesting( GetStatusAreaView(tray->widget())->SetFocusCyclerForTesting(
focus_cycler.get()); focus_cycler.get());
// Add the launcher // Add the launcher
...@@ -119,7 +126,7 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) { ...@@ -119,7 +126,7 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) {
// Cycle focus to the status area // Cycle focus to the status area
focus_cycler->RotateFocus(FocusCycler::BACKWARD); focus_cycler->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(status_widget->IsActive()); EXPECT_TRUE(tray->widget()->IsActive());
// Cycle focus to the browser // Cycle focus to the browser
focus_cycler->RotateFocus(FocusCycler::BACKWARD); focus_cycler->RotateFocus(FocusCycler::BACKWARD);
...@@ -161,10 +168,10 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) { ...@@ -161,10 +168,10 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) {
scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
// Add the Status area // Add the Status area
views::Widget* status_widget = internal::CreateStatusArea(NULL); scoped_ptr<SystemTray> tray(CreateSystemTray());
ASSERT_TRUE(status_widget); ASSERT_TRUE(tray->widget());
focus_cycler->AddWidget(status_widget); focus_cycler->AddWidget(tray->widget());
GetStatusAreaView(status_widget)->SetFocusCyclerForTesting( GetStatusAreaView(tray->widget())->SetFocusCyclerForTesting(
focus_cycler.get()); focus_cycler.get());
// Add the launcher // Add the launcher
...@@ -184,7 +191,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) { ...@@ -184,7 +191,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) {
// Cycle focus to the status area // Cycle focus to the status area
focus_cycler->RotateFocus(FocusCycler::FORWARD); focus_cycler->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(status_widget->IsActive()); EXPECT_TRUE(tray->widget()->IsActive());
// Cycle focus to the browser // Cycle focus to the browser
focus_cycler->RotateFocus(FocusCycler::FORWARD); focus_cycler->RotateFocus(FocusCycler::FORWARD);
...@@ -195,10 +202,10 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) { ...@@ -195,10 +202,10 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) {
scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
// Add the Status area // Add the Status area
views::Widget* status_widget = internal::CreateStatusArea(NULL); scoped_ptr<SystemTray> tray(CreateSystemTray());
ASSERT_TRUE(status_widget); ASSERT_TRUE(tray->widget());
focus_cycler->AddWidget(status_widget); focus_cycler->AddWidget(tray->widget());
GetStatusAreaView(status_widget)->SetFocusCyclerForTesting( GetStatusAreaView(tray->widget())->SetFocusCyclerForTesting(
focus_cycler.get()); focus_cycler.get());
// Add the launcher // Add the launcher
...@@ -218,7 +225,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) { ...@@ -218,7 +225,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) {
// Cycle focus to the status area // Cycle focus to the status area
focus_cycler->RotateFocus(FocusCycler::BACKWARD); focus_cycler->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(status_widget->IsActive()); EXPECT_TRUE(tray->widget()->IsActive());
// Cycle focus to the browser // Cycle focus to the browser
focus_cycler->RotateFocus(FocusCycler::BACKWARD); focus_cycler->RotateFocus(FocusCycler::BACKWARD);
......
...@@ -22,23 +22,10 @@ ...@@ -22,23 +22,10 @@
#include "ash/shell_delegate.h" #include "ash/shell_delegate.h"
#include "ash/shell_factory.h" #include "ash/shell_factory.h"
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
#include "ash/system/audio/tray_volume.h" #include "ash/system/bluetooth/bluetooth_observer.h"
#include "ash/system/bluetooth/tray_bluetooth.h" #include "ash/system/network/network_observer.h"
#include "ash/system/brightness/tray_brightness.h"
#include "ash/system/date/tray_date.h"
#include "ash/system/ime/tray_ime.h"
#include "ash/system/network/tray_network.h"
#include "ash/system/power/power_status_observer.h"
#include "ash/system/power/power_supply_status.h"
#include "ash/system/power/tray_power.h"
#include "ash/system/settings/tray_settings.h"
#include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/tray_empty.h"
#include "ash/system/tray_accessibility.h"
#include "ash/system/tray_caps_lock.h"
#include "ash/system/tray_update.h"
#include "ash/system/user/tray_user.h"
#include "ash/tooltips/tooltip_controller.h" #include "ash/tooltips/tooltip_controller.h"
#include "ash/wm/activation_controller.h" #include "ash/wm/activation_controller.h"
#include "ash/wm/base_layout_manager.h" #include "ash/wm/base_layout_manager.h"
...@@ -530,8 +517,7 @@ Shell::Shell(ShellDelegate* delegate) ...@@ -530,8 +517,7 @@ Shell::Shell(ShellDelegate* delegate)
delegate_(delegate), delegate_(delegate),
shelf_(NULL), shelf_(NULL),
panel_layout_manager_(NULL), panel_layout_manager_(NULL),
root_window_layout_(NULL), root_window_layout_(NULL) {
status_widget_(NULL) {
gfx::Screen::SetInstance(screen_); gfx::Screen::SetInstance(screen_);
ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get()));
} }
...@@ -681,55 +667,13 @@ void Shell::Init() { ...@@ -681,55 +667,13 @@ void Shell::Init() {
CommandLine* command_line = CommandLine::ForCurrentProcess(); CommandLine* command_line = CommandLine::ForCurrentProcess();
// TODO(sad): All of these initialization should happen in SystemTray.
tray_.reset(new SystemTray()); tray_.reset(new SystemTray());
if (delegate_.get()) if (delegate_.get())
tray_delegate_.reset(delegate_->CreateSystemTrayDelegate(tray_.get())); tray_delegate_.reset(delegate_->CreateSystemTrayDelegate(tray_.get()));
if (!tray_delegate_.get()) if (!tray_delegate_.get())
tray_delegate_.reset(new DummySystemTrayDelegate()); tray_delegate_.reset(new DummySystemTrayDelegate());
tray_->CreateItems();
internal::TrayVolume* tray_volume = new internal::TrayVolume(); tray_->CreateWidget();
internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth();
internal::TrayBrightness* tray_brightness = new internal::TrayBrightness();
internal::TrayDate* tray_date = new internal::TrayDate();
internal::TrayPower* tray_power = new internal::TrayPower();
internal::TrayNetwork* tray_network = new internal::TrayNetwork;
internal::TrayUser* tray_user = new internal::TrayUser;
internal::TrayAccessibility* tray_accessibility =
new internal::TrayAccessibility;
internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock;
internal::TrayIME* tray_ime = new internal::TrayIME;
internal::TrayUpdate* tray_update = new internal::TrayUpdate;
tray_->accessibility_observer_ = tray_accessibility;
tray_->audio_observer_ = tray_volume;
tray_->bluetooth_observer_ = tray_bluetooth;
tray_->brightness_observer_ = tray_brightness;
tray_->caps_lock_observer_ = tray_caps_lock;
tray_->clock_observer_ = tray_date;
tray_->ime_observer_ = tray_ime;
tray_->network_observer_ = tray_network;
tray_->power_status_observer_ = tray_power;
tray_->update_observer_ = tray_update;
tray_->user_observer_ = tray_user;
tray_->AddTrayItem(tray_user);
tray_->AddTrayItem(new internal::TrayEmpty());
tray_->AddTrayItem(tray_power);
tray_->AddTrayItem(tray_network);
tray_->AddTrayItem(tray_bluetooth);
tray_->AddTrayItem(tray_ime);
tray_->AddTrayItem(tray_volume);
tray_->AddTrayItem(tray_brightness);
tray_->AddTrayItem(tray_update);
tray_->AddTrayItem(new internal::TraySettings());
tray_->AddTrayItem(tray_accessibility);
tray_->AddTrayItem(tray_caps_lock);
tray_->AddTrayItem(tray_date);
tray_->SetVisible(tray_delegate_->GetTrayVisibilityOnStartup());
// TODO(sad): Replace uses of status_widget_ with tray_->GetWidget().
status_widget_ = internal::CreateStatusArea(tray_.get());
// This controller needs to be set before SetupManagedWindowMode. // This controller needs to be set before SetupManagedWindowMode.
desktop_background_controller_.reset(new DesktopBackgroundController); desktop_background_controller_.reset(new DesktopBackgroundController);
...@@ -746,7 +690,7 @@ void Shell::Init() { ...@@ -746,7 +690,7 @@ void Shell::Init() {
} }
focus_cycler_.reset(new internal::FocusCycler()); focus_cycler_.reset(new internal::FocusCycler());
focus_cycler_->AddWidget(status_widget_); focus_cycler_->AddWidget(tray_->widget());
if (!delegate_.get() || delegate_->IsUserLoggedIn()) if (!delegate_.get() || delegate_->IsUserLoggedIn())
CreateLauncher(); CreateLauncher();
...@@ -914,10 +858,10 @@ bool Shell::IsInMaximizedMode() const { ...@@ -914,10 +858,10 @@ bool Shell::IsInMaximizedMode() const {
void Shell::InitLayoutManagers() { void Shell::InitLayoutManagers() {
DCHECK(root_window_layout_); DCHECK(root_window_layout_);
DCHECK(status_widget_); DCHECK(tray_->widget());
internal::ShelfLayoutManager* shelf_layout_manager = internal::ShelfLayoutManager* shelf_layout_manager =
new internal::ShelfLayoutManager(status_widget_); new internal::ShelfLayoutManager(tray_->widget());
GetContainer(internal::kShellWindowId_LauncherContainer)-> GetContainer(internal::kShellWindowId_LauncherContainer)->
SetLayoutManager(shelf_layout_manager); SetLayoutManager(shelf_layout_manager);
shelf_ = shelf_layout_manager; shelf_ = shelf_layout_manager;
......
...@@ -365,11 +365,7 @@ class ASH_EXPORT Shell { ...@@ -365,11 +365,7 @@ class ASH_EXPORT Shell {
// Owned by aura::RootWindow, cached here for type safety. // Owned by aura::RootWindow, cached here for type safety.
internal::RootWindowLayoutManager* root_window_layout_; internal::RootWindowLayoutManager* root_window_layout_;
// Status area with clock, Wi-Fi signal, etc. // System tray with clock, Wi-Fi signal, etc.
views::Widget* status_widget_;
// System tray with clock, Wi-Fi signal, etc. (a replacement in progress for
// |status_widget_|).
scoped_ptr<SystemTray> tray_; scoped_ptr<SystemTray> tray_;
// Used by ash/shell. // Used by ash/shell.
......
...@@ -7,9 +7,25 @@ ...@@ -7,9 +7,25 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell/panel_window.h" #include "ash/shell/panel_window.h"
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
#include "ash/system/audio/tray_volume.h"
#include "ash/system/bluetooth/tray_bluetooth.h"
#include "ash/system/brightness/tray_brightness.h"
#include "ash/system/date/tray_date.h"
#include "ash/system/ime/tray_ime.h"
#include "ash/system/network/tray_network.h"
#include "ash/system/power/power_status_observer.h"
#include "ash/system/power/power_supply_status.h"
#include "ash/system/power/tray_power.h"
#include "ash/system/settings/tray_settings.h"
#include "ash/system/tray/tray_empty.h"
#include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray_item.h" #include "ash/system/tray/system_tray_item.h"
#include "ash/system/tray/system_tray_widget_delegate.h"
#include "ash/system/tray_accessibility.h"
#include "ash/system/tray_caps_lock.h"
#include "ash/system/tray_update.h"
#include "ash/system/user/tray_user.h"
#include "ash/system/user/login_status.h" #include "ash/system/user/login_status.h"
#include "ash/wm/shadow_types.h" #include "ash/wm/shadow_types.h"
#include "ash/wm/shelf_layout_manager.h" #include "ash/wm/shelf_layout_manager.h"
...@@ -406,6 +422,7 @@ SystemTray::SystemTray() ...@@ -406,6 +422,7 @@ SystemTray::SystemTray()
power_status_observer_(NULL), power_status_observer_(NULL),
update_observer_(NULL), update_observer_(NULL),
user_observer_(NULL), user_observer_(NULL),
widget_(NULL),
bubble_(NULL), bubble_(NULL),
popup_(NULL), popup_(NULL),
background_(new internal::SystemTrayBackground), background_(new internal::SystemTrayBackground),
...@@ -442,6 +459,70 @@ SystemTray::~SystemTray() { ...@@ -442,6 +459,70 @@ SystemTray::~SystemTray() {
popup_->CloseNow(); popup_->CloseNow();
} }
void SystemTray::CreateItems() {
internal::TrayVolume* tray_volume = new internal::TrayVolume();
internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth();
internal::TrayBrightness* tray_brightness = new internal::TrayBrightness();
internal::TrayDate* tray_date = new internal::TrayDate();
internal::TrayPower* tray_power = new internal::TrayPower();
internal::TrayNetwork* tray_network = new internal::TrayNetwork;
internal::TrayUser* tray_user = new internal::TrayUser;
internal::TrayAccessibility* tray_accessibility =
new internal::TrayAccessibility;
internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock;
internal::TrayIME* tray_ime = new internal::TrayIME;
internal::TrayUpdate* tray_update = new internal::TrayUpdate;
accessibility_observer_ = tray_accessibility;
audio_observer_ = tray_volume;
bluetooth_observer_ = tray_bluetooth;
brightness_observer_ = tray_brightness;
caps_lock_observer_ = tray_caps_lock;
clock_observer_ = tray_date;
ime_observer_ = tray_ime;
network_observer_ = tray_network;
power_status_observer_ = tray_power;
update_observer_ = tray_update;
user_observer_ = tray_user;
AddTrayItem(tray_user);
AddTrayItem(new internal::TrayEmpty());
AddTrayItem(tray_power);
AddTrayItem(tray_network);
AddTrayItem(tray_bluetooth);
AddTrayItem(tray_ime);
AddTrayItem(tray_volume);
AddTrayItem(tray_brightness);
AddTrayItem(tray_update);
AddTrayItem(new internal::TraySettings());
AddTrayItem(tray_accessibility);
AddTrayItem(tray_caps_lock);
AddTrayItem(tray_date);
SetVisible(ash::Shell::GetInstance()->tray_delegate()->
GetTrayVisibilityOnStartup());
}
void SystemTray::CreateWidget() {
if (widget_)
widget_->Close();
widget_ = new views::Widget;
internal::StatusAreaView* status_area_view = new internal::StatusAreaView;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
gfx::Size ps = GetPreferredSize();
params.bounds = gfx::Rect(0, 0, ps.width(), ps.height());
params.delegate = status_area_view;
params.parent = Shell::GetInstance()->GetContainer(
ash::internal::kShellWindowId_StatusContainer);
params.transparent = true;
widget_->Init(params);
widget_->set_focus_on_creation(false);
status_area_view->AddChildView(this);
widget_->SetContentsView(status_area_view);
widget_->Show();
widget_->GetNativeView()->SetName("StatusTrayWidget");
}
void SystemTray::AddTrayItem(SystemTrayItem* item) { void SystemTray::AddTrayItem(SystemTrayItem* item) {
items_.push_back(item); items_.push_back(item);
......
...@@ -49,6 +49,12 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -49,6 +49,12 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
SystemTray(); SystemTray();
virtual ~SystemTray(); virtual ~SystemTray();
// Creates the default set of items for the sytem tray.
void CreateItems();
// Creates the widget for the tray.
void CreateWidget();
// Adds a new item in the tray. // Adds a new item in the tray.
void AddTrayItem(SystemTrayItem* item); void AddTrayItem(SystemTrayItem* item);
...@@ -82,6 +88,8 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -82,6 +88,8 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
// Returns true if the launcher should show. // Returns true if the launcher should show.
bool should_show_launcher() const { return popup_ && should_show_launcher_; } bool should_show_launcher() const { return popup_ && should_show_launcher_; }
views::Widget* widget() const { return widget_; }
AccessibilityObserver* accessibility_observer() const { AccessibilityObserver* accessibility_observer() const {
return accessibility_observer_; return accessibility_observer_;
} }
...@@ -117,8 +125,6 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -117,8 +125,6 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
} }
private: private:
friend class Shell;
void ShowItems(std::vector<SystemTrayItem*>& items, void ShowItems(std::vector<SystemTrayItem*>& items,
bool details, bool details,
bool activate); bool activate);
...@@ -164,6 +170,9 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -164,6 +170,9 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
UpdateObserver* update_observer_; UpdateObserver* update_observer_;
UserObserver* user_observer_; UserObserver* user_observer_;
// The widget hosting the tray.
views::Widget* widget_;
// The popup widget and the delegate. // The popup widget and the delegate.
internal::SystemTrayBubble* bubble_; internal::SystemTrayBubble* bubble_;
views::Widget* popup_; views::Widget* popup_;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/status_area/status_area_view.h" #include "ash/system/tray/system_tray_widget_delegate.h"
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/focus_cycler.h" #include "ash/focus_cycler.h"
...@@ -65,29 +65,5 @@ bool StatusAreaView::CanActivate() const { ...@@ -65,29 +65,5 @@ bool StatusAreaView::CanActivate() const {
void StatusAreaView::DeleteDelegate() { void StatusAreaView::DeleteDelegate() {
} }
ASH_EXPORT views::Widget* CreateStatusArea(views::View* contents) {
if (!contents) {
contents = new views::View;
contents->set_focusable(true);
}
StatusAreaView* status_area_view = new StatusAreaView;
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
gfx::Size ps = contents->GetPreferredSize();
params.bounds = gfx::Rect(0, 0, ps.width(), ps.height());
params.delegate = status_area_view;
params.parent = Shell::GetInstance()->GetContainer(
ash::internal::kShellWindowId_StatusContainer);
params.transparent = true;
widget->Init(params);
widget->set_focus_on_creation(false);
status_area_view->AddChildView(contents);
widget->SetContentsView(status_area_view);
widget->Show();
widget->GetNativeView()->SetName("StatusAreaView");
return widget;
}
} // namespace internal } // namespace internal
} // namespace ash } // namespace ash
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_STATUS_AREA_STATUS_AREA_VIEW_H_ #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_WIDGET_DELEGATE_H_
#define ASH_STATUS_AREA_STATUS_AREA_VIEW_H_ #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_WIDGET_DELEGATE_H_
#pragma once #pragma once
#include "ash/ash_export.h" #include "ash/ash_export.h"
...@@ -46,4 +46,4 @@ class ASH_EXPORT StatusAreaView : public views::WidgetDelegate, ...@@ -46,4 +46,4 @@ class ASH_EXPORT StatusAreaView : public views::WidgetDelegate,
} // namespace internal } // namespace internal
} // namespace ash } // namespace ash
#endif // ASH_STATUS_AREA_STATUS_AREA_VIEW_H_ #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_WIDGET_DELEGATE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment