diff options
author | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-27 00:16:16 +0000 |
---|---|---|
committer | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-27 00:16:16 +0000 |
commit | c97392324c949f2860d4427e9e6bf7eed529845f (patch) | |
tree | d7a2be81b4b3f9698986fdb48762c662275be1fb | |
parent | f2b9cf39716c8f7955fae1d119750703908dc540 (diff) | |
download | chromium_src-c97392324c949f2860d4427e9e6bf7eed529845f.zip chromium_src-c97392324c949f2860d4427e9e6bf7eed529845f.tar.gz chromium_src-c97392324c949f2860d4427e9e6bf7eed529845f.tar.bz2 |
Fix the bluetooth status notification issue on systemtray.
BUG=132208
TEST=System tray panel should refresh to show bluetooth adapter status when it is plugged in for the case described in the bug.
Review URL: http://codereview.chromium.org/10214005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134181 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/system/bluetooth/tray_bluetooth.cc | 17 | ||||
-rw-r--r-- | ash/system/tray/system_tray.cc | 37 | ||||
-rw-r--r-- | ash/system/tray/system_tray.h | 2 | ||||
-rw-r--r-- | ui/views/bubble/bubble_border.h | 5 | ||||
-rw-r--r-- | ui/views/bubble/bubble_frame_view.cc | 8 | ||||
-rw-r--r-- | ui/views/bubble/bubble_frame_view.h | 4 |
6 files changed, 49 insertions, 24 deletions
diff --git a/ash/system/bluetooth/tray_bluetooth.cc b/ash/system/bluetooth/tray_bluetooth.cc index 8352457..2520324 100644 --- a/ash/system/bluetooth/tray_bluetooth.cc +++ b/ash/system/bluetooth/tray_bluetooth.cc @@ -41,10 +41,15 @@ class BluetoothDefaultView : public TrayItemMore { void UpdateLabel() { ash::SystemTrayDelegate* delegate = ash::Shell::GetInstance()->tray_delegate(); - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - SetLabel(rb.GetLocalizedString(delegate->GetBluetoothEnabled() ? - IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTED : - IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED)); + if (delegate->GetBluetoothAvailable()) { + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); + SetLabel(rb.GetLocalizedString(delegate->GetBluetoothEnabled() ? + IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTED : + IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED)); + SetVisible(true); + } else { + SetVisible(false); + } } private: @@ -226,8 +231,6 @@ views::View* TrayBluetooth::CreateTrayView(user::LoginStatus status) { } views::View* TrayBluetooth::CreateDefaultView(user::LoginStatus status) { - if (!Shell::GetInstance()->tray_delegate()->GetBluetoothAvailable()) - return NULL; default_.reset(new tray::BluetoothDefaultView(this)); return default_.get(); } @@ -258,7 +261,7 @@ void TrayBluetooth::OnBluetoothRefresh() { Shell::GetInstance()->tray_delegate()->GetAvailableBluetoothDevices(&list); if (default_.get()) default_->UpdateLabel(); - if (detailed_.get()) + else if (detailed_.get()) detailed_->Update(list); } diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index 90b1cbc..7400e0f 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -48,7 +48,9 @@ #include "ui/gfx/screen.h" #include "ui/gfx/skia_util.h" #include "ui/views/border.h" +#include "ui/views/bubble/bubble_border.h" #include "ui/views/bubble/bubble_delegate.h" +#include "ui/views/bubble/bubble_frame_view.h" #include "ui/views/controls/label.h" #include "ui/views/layout/fill_layout.h" #include "ui/views/layout/box_layout.h" @@ -89,12 +91,20 @@ class TrayPopupItemContainer : public views::View { NULL); SetLayoutManager(new views::FillLayout); AddChildView(view); + SetVisible(view->visible()); } virtual ~TrayPopupItemContainer() {} private: // Overridden from views::View. + virtual void ChildVisibilityChanged(View* child) OVERRIDE { + if (visible() == child->visible()) + return; + SetVisible(child->visible()); + PreferredSizeChanged(); + } + virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE { hover_ = true; SchedulePaint(); @@ -166,10 +176,13 @@ class SystemTrayBubbleBackground : public views::Background { DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleBackground); }; -class SystemTrayBubbleBorder : public views::Border { +class SystemTrayBubbleBorder : public views::BubbleBorder { public: explicit SystemTrayBubbleBorder(views::View* owner) - : owner_(owner) { + : views::BubbleBorder(views::BubbleBorder::BOTTOM_RIGHT, + views::BubbleBorder::NO_SHADOW), + owner_(owner) { + set_alignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); } virtual ~SystemTrayBubbleBorder() {} @@ -213,11 +226,6 @@ class SystemTrayBubbleBorder : public views::Border { canvas->DrawPath(path, paint); } } - - virtual void GetInsets(gfx::Insets* insets) const OVERRIDE { - insets->Set(0, 0, kArrowHeight, 0); - } - views::View* owner_; DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleBorder); @@ -257,7 +265,7 @@ class SystemTrayBubble : public views::BubbleDelegateView { public: SystemTrayBubble(ash::SystemTray* tray, views::View* anchor, - std::vector<ash::SystemTrayItem*>& items, + const std::vector<ash::SystemTrayItem*>& items, bool detailed) : views::BubbleDelegateView(anchor, views::BubbleBorder::BOTTOM_RIGHT), tray_(tray), @@ -285,6 +293,10 @@ class SystemTrayBubble : public views::BubbleDelegateView { bool detailed() const { return detailed_; } void set_can_activate(bool activate) { can_activate_ = activate; } + void SetBubbleBorder(views::BubbleBorder* border) { + GetBubbleFrameView()->SetBubbleBorder(border); + } + void StartAutoCloseTimer(int seconds) { autoclose_.Stop(); autoclose_delay_ = seconds; @@ -337,6 +349,10 @@ class SystemTrayBubble : public views::BubbleDelegateView { } // Overridden from views::View. + virtual void ChildPreferredSizeChanged(View* child) OVERRIDE { + SizeToContents(); + } + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE { if (can_activate_) { state->role = ui::AccessibilityTypes::ROLE_WINDOW; @@ -592,7 +608,7 @@ void SystemTray::SetPaintsBackground( hide_background_animator_.SetPaintsBackground(value, change_type); } -void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, +void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, bool detailed, bool activate) { CHECK(!popup_); @@ -606,8 +622,7 @@ void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, should_show_launcher_ = true; 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_)); + bubble_->SetBubbleBorder(new SystemTrayBubbleBorder(bubble_)); MessageLoopForUI::current()->AddObserver(this); popup_->AddObserver(this); diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h index b9dbab2..8bb6559 100644 --- a/ash/system/tray/system_tray.h +++ b/ash/system/tray/system_tray.h @@ -125,7 +125,7 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( } private: - void ShowItems(std::vector<SystemTrayItem*>& items, + void ShowItems(const std::vector<SystemTrayItem*>& items, bool details, bool activate); diff --git a/ui/views/bubble/bubble_border.h b/ui/views/bubble/bubble_border.h index 288485e..ec38f95 100644 --- a/ui/views/bubble/bubble_border.h +++ b/ui/views/bubble/bubble_border.h @@ -118,14 +118,15 @@ class VIEWS_EXPORT BubbleBorder : public views::Border { // How many pixels the bubble border is from the edge of the images. int border_thickness() const; + protected: + virtual ~BubbleBorder(); + private: struct BorderImages; // Loads images if necessary. static BorderImages* GetBorderImages(Shadow shadow); - virtual ~BubbleBorder(); - // Overridden from views::Border: virtual void Paint(const views::View& view, gfx::Canvas* canvas) const OVERRIDE; diff --git a/ui/views/bubble/bubble_frame_view.cc b/ui/views/bubble/bubble_frame_view.cc index ab88cba..660f9f1 100644 --- a/ui/views/bubble/bubble_frame_view.cc +++ b/ui/views/bubble/bubble_frame_view.cc @@ -48,8 +48,7 @@ BubbleFrameView::BubbleFrameView(BubbleBorder::ArrowLocation arrow_location, arrow_location = BubbleBorder::horizontal_mirror(arrow_location); // TODO(alicet): Expose the shadow option in BorderContentsView when we make // the fullscreen exit bubble use the new bubble code. - bubble_border_ = new BubbleBorder(arrow_location, BubbleBorder::NO_SHADOW); - set_border(bubble_border_); + SetBubbleBorder(new BubbleBorder(arrow_location, BubbleBorder::NO_SHADOW)); set_background(new BubbleBackground(bubble_border_)); bubble_border()->set_background_color(color); } @@ -96,6 +95,11 @@ gfx::Rect BubbleFrameView::GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, return bubble_border_->GetBounds(anchor_rect, client_size); } +void BubbleFrameView::SetBubbleBorder(BubbleBorder* border) { + bubble_border_ = border; + set_border(bubble_border_); +} + gfx::Rect BubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { return gfx::Screen::GetMonitorNearestPoint(rect.CenterPoint()).work_area(); } diff --git a/ui/views/bubble/bubble_frame_view.h b/ui/views/bubble/bubble_frame_view.h index 1c21787..0d6fa21 100644 --- a/ui/views/bubble/bubble_frame_view.h +++ b/ui/views/bubble/bubble_frame_view.h @@ -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. @@ -49,6 +49,8 @@ class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView { gfx::Size client_size, bool try_mirroring_arrow); + void SetBubbleBorder(BubbleBorder* border); + protected: // Returns the bounds for the monitor showing the specified |rect|. // This function is virtual to support testing environments. |