Skip to content

Commit

Permalink
ash uber tray: Make it work in ash_shell, and a couple more fixes.
Browse files Browse the repository at this point in the history
The fixes: (1) make sure the popup shows up in login screen, (2) align the popup to the edge of the screen.

BUG=110130
TEST=none

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124903 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sadrul@chromium.org committed Mar 4, 2012
1 parent c5968bf commit 1dcddae
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
4 changes: 2 additions & 2 deletions ash/focus_cycler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TEST_F(FocusCyclerTest, CycleFocusForward) {
scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());

// Add the Status area
views::Widget* status_widget = internal::CreateStatusArea();
views::Widget* status_widget = internal::CreateStatusArea(NULL);
ASSERT_TRUE(status_widget);
focus_cycler->AddWidget(status_widget);

Expand Down Expand Up @@ -85,7 +85,7 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) {
scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());

// Add the Status area
views::Widget* status_widget = internal::CreateStatusArea();
views::Widget* status_widget = internal::CreateStatusArea(NULL);
ASSERT_TRUE(status_widget);
focus_cycler->AddWidget(status_widget);

Expand Down
14 changes: 6 additions & 8 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -411,21 +411,17 @@ void Shell::Init() {

if (delegate_.get())
status_widget_ = delegate_->CreateStatusArea();
if (!status_widget_)
status_widget_ = internal::CreateStatusArea();

if (command_line->HasSwitch(switches::kAshUberTray)) {
// TODO(sad): This is rather ugly at the moment. This is because we are
// supporting both the old and the new status bar at the same time. This
// will soon get better once the new one is ready and the old one goes out
// the door.
if (delegate_.get())
status_widget_ = delegate_->CreateStatusArea();
if (!status_widget_)
status_widget_ = internal::CreateStatusArea();
status_widget_->GetContentsView()->RemoveAllChildViews(false);
tray_.reset(new SystemTray());
status_widget_->GetContentsView()->AddChildView(tray_.get());
if (status_widget_) {
status_widget_->GetContentsView()->RemoveAllChildViews(false);
status_widget_->GetContentsView()->AddChildView(tray_.get());
}

if (delegate_.get())
tray_delegate_.reset(delegate_->CreateSystemTrayDelegate(tray_.get()));
Expand All @@ -446,6 +442,8 @@ void Shell::Init() {
tray_->AddTrayItem(tray_brightness);
tray_->AddTrayItem(new internal::TraySettings());
}
if (!status_widget_)
status_widget_ = internal::CreateStatusArea(tray_.get());

aura::Window* default_container =
GetContainer(internal::kShellWindowId_DefaultContainer);
Expand Down
2 changes: 1 addition & 1 deletion ash/shell/shell_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class ShellDelegateImpl : public ash::ShellDelegate {
}

virtual views::Widget* CreateStatusArea() OVERRIDE {
return ash::internal::CreateStatusArea();
return NULL;
}

#if defined(OS_CHROMEOS)
Expand Down
5 changes: 3 additions & 2 deletions ash/shell_factory.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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.

Expand All @@ -9,6 +9,7 @@
#include "ash/ash_export.h"

namespace views {
class View;
class Widget;
}

Expand All @@ -18,7 +19,7 @@ namespace ash {

namespace internal {
views::Widget* CreateDesktopBackground();
ASH_EXPORT views::Widget* CreateStatusArea();
ASH_EXPORT views::Widget* CreateStatusArea(views::View* contents);
} // namespace internal

} // namespace ash
Expand Down
8 changes: 5 additions & 3 deletions ash/status_area/status_area_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@ void StatusAreaView::OnPaint(gfx::Canvas* canvas) {
canvas->DrawBitmapInt(status_mock_, 0, 0);
}

ASH_EXPORT views::Widget* CreateStatusArea() {
ASH_EXPORT views::Widget* CreateStatusArea(views::View* contents) {
StatusAreaView* status_area_view = new StatusAreaView;
if (!contents)
contents = status_area_view;
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
gfx::Size ps = status_area_view->GetPreferredSize();
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);
widget->SetContentsView(status_area_view);
widget->SetContentsView(contents);
widget->Show();
widget->GetNativeView()->SetName("StatusAreaView");
return widget;
Expand Down
4 changes: 4 additions & 0 deletions ash/system/tray/system_tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "ash/shell.h"
#include "ash/shell/panel_window.h"
#include "ash/shell_window_ids.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray_item.h"
#include "ash/system/user/login_status.h"
Expand Down Expand Up @@ -151,6 +152,8 @@ class SystemTrayBubble : public views::BubbleDelegateView {
items_(items),
detailed_(detailed) {
set_margin(0);
set_parent_window(ash::Shell::GetInstance()->GetContainer(
ash::internal::kShellWindowId_SettingBubbleContainer));
}

virtual ~SystemTrayBubble() {
Expand Down Expand Up @@ -264,6 +267,7 @@ void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, bool detailed) {
CHECK(!popup_);
SystemTrayBubble* bubble = new SystemTrayBubble(this, items, detailed);
popup_ = views::BubbleDelegateView::CreateBubble(bubble);
bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
popup_->non_client_view()->frame_view()->set_background(NULL);
popup_->non_client_view()->frame_view()->set_border(
new SystemTrayBubbleBorder(bubble));
Expand Down
1 change: 1 addition & 0 deletions ash/wm/activation_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const int kWindowContainerIds[] = {
kShellWindowId_PanelContainer,
kShellWindowId_LauncherContainer,
kShellWindowId_StatusContainer,
kShellWindowId_SettingBubbleContainer,
};

aura::Window* GetContainer(int id) {
Expand Down

0 comments on commit 1dcddae

Please sign in to comment.