Commit ba897e44 authored by stevenjb@google.com's avatar stevenjb@google.com

Prepare SystemTray to support notifications

The following cleanup was done in preparation for notifications which may require multiple SystemTrayBubble instances:

* Separate out SystemTrayBubbleView from SystemTrayBubble
* Move SystemTray.popup_ -> SystemTrayBubble.bubble_widget_
* Remove scoped_ptr for views (views are owned by the view hierarchy)
* Changed behavior to not close when focus is lost so that the default view can be reused.

BUG=124269
TEST=All tests should pass; system tray behavior should be unchanged.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134612 0039d316-1c4b-4281-b951-d872f2087c98
parent 4878e3da
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/widget/widget.h"
namespace ash { namespace ash {
namespace internal { namespace internal {
......
This diff is collapsed.
...@@ -12,10 +12,9 @@ ...@@ -12,10 +12,9 @@
#include "ash/system/user/login_status.h" #include "ash/system/user/login_status.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/message_pump_observer.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include <vector> #include <vector>
...@@ -42,9 +41,7 @@ class SystemTrayBubble; ...@@ -42,9 +41,7 @@ class SystemTrayBubble;
class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
public internal::ActionableView), public internal::ActionableView),
public views::Widget::Observer, public internal::BackgroundAnimatorDelegate {
public internal::BackgroundAnimatorDelegate,
public base::MessagePumpObserver {
public: public:
SystemTray(); SystemTray();
virtual ~SystemTray(); virtual ~SystemTray();
...@@ -77,8 +74,6 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -77,8 +74,6 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
// Updates the items when the login status of the system changes. // Updates the items when the login status of the system changes.
void UpdateAfterLoginStatusChange(user::LoginStatus login_status); void UpdateAfterLoginStatusChange(user::LoginStatus login_status);
const ScopedVector<SystemTrayItem>& items() const { return items_; }
// Sets whether the tray paints a background. Default is true, but is set to // Sets whether the tray paints a background. Default is true, but is set to
// false if a window overlaps the shelf. // false if a window overlaps the shelf.
void SetPaintsBackground( void SetPaintsBackground(
...@@ -86,7 +81,9 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -86,7 +81,9 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
internal::BackgroundAnimator::ChangeType change_type); internal::BackgroundAnimator::ChangeType change_type);
// 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 bubble_.get() && should_show_launcher_;
}
views::Widget* widget() const { return widget_; } views::Widget* widget() const { return widget_; }
...@@ -125,6 +122,15 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -125,6 +122,15 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
} }
private: private:
friend class internal::SystemTrayBubble;
// Called when the widget associated with |bubble| closes. |bubble| should
// always == |bubble_|. This triggers destroying |bubble_| and hiding the
// launcher if necessary.
void RemoveBubble(internal::SystemTrayBubble* bubble);
const ScopedVector<SystemTrayItem>& items() const { return items_; }
void ShowItems(const std::vector<SystemTrayItem*>& items, void ShowItems(const std::vector<SystemTrayItem*>& items,
bool details, bool details,
bool activate); bool activate);
...@@ -139,19 +145,9 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -139,19 +145,9 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
// Overridden from views::Widget::Observer.
virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
virtual void OnWidgetVisibilityChanged(views::Widget* widget,
bool visible) OVERRIDE;
// Overridden from internal::BackgroundAnimatorDelegate. // Overridden from internal::BackgroundAnimatorDelegate.
virtual void UpdateBackground(int alpha) OVERRIDE; virtual void UpdateBackground(int alpha) OVERRIDE;
// Overidden from base::MessagePumpObserver
virtual base::EventStatus WillProcessEvent(
const base::NativeEvent& event) OVERRIDE;
virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
ScopedVector<SystemTrayItem> items_; ScopedVector<SystemTrayItem> items_;
// The container for all the tray views of the items. // The container for all the tray views of the items.
...@@ -174,8 +170,7 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -174,8 +170,7 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
views::Widget* widget_; views::Widget* widget_;
// The popup widget and the delegate. // The popup widget and the delegate.
internal::SystemTrayBubble* bubble_; scoped_ptr<internal::SystemTrayBubble> bubble_;
views::Widget* popup_;
// Owned by the view it's installed on. // Owned by the view it's installed on.
internal::SystemTrayBackground* background_; internal::SystemTrayBackground* background_;
......
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