summaryrefslogtreecommitdiffstats
path: root/ui/message_center
diff options
context:
space:
mode:
authorerikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-28 16:16:25 +0000
committererikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-28 16:16:25 +0000
commit7921fcf63ebb1d9d569fb617712a6c6da1b95aca (patch)
tree902f5a82c46991636b240a594f06dba0b5371548 /ui/message_center
parent75b74f64f76ba942ade90cfa63356b30150d734c (diff)
downloadchromium_src-7921fcf63ebb1d9d569fb617712a6c6da1b95aca.zip
chromium_src-7921fcf63ebb1d9d569fb617712a6c6da1b95aca.tar.gz
chromium_src-7921fcf63ebb1d9d569fb617712a6c6da1b95aca.tar.bz2
Revert of Converts MessagePopupCollection into a long-lived object. (https://codereview.chromium.org/180513002/)
Reason for revert: Possible cause of build breakage: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%281%29/builds/40180 http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%281%29/builds/40180/steps/message_center_unittests/logs/LeftPositioningWithLeftTaskbar MessagePopupCollectionTest.LeftPositioningWithLeftTaskbar (run #1): [ RUN ] MessagePopupCollectionTest.LeftPositioningWithLeftTaskbar Xlib: extension "RANDR" missing on display ":9". ../../ui/message_center/views/message_popup_collection_unittest.cc:341: Failure Expected: (r1.x()) \u003C (GetWorkArea().CenterPoint().x()), actual: 433 vs 400 [ FAILED ] MessagePopupCollectionTest.LeftPositioningWithLeftTaskbar (430 ms) Original issue's description: > Converts MessagePopupCollection into a long-lived object. > > This improves the behavior since there were several scenarios where > observer methods would cause re-entrancy into the destructor of > MessagePopupCollection. Since it observes MessageCenter, it knows when > it should show popups and when it shouldn't. > > This CL is based on dewittj's crrev.com/114553002 with a fix > for some tests in linux-aura and win because of screen_aura. > > BUG=327363 > R=dewittj@chromium.org, stevenjb@chromium.org > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=254101 TBR=dewittj@chromium.org,stevenjb@chromium.org,mukai@chromium.org NOTREECHECKS=true NOTRY=true BUG=327363 Review URL: https://codereview.chromium.org/183883006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254145 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/message_center')
-rw-r--r--ui/message_center/views/message_popup_collection.cc46
-rw-r--r--ui/message_center/views/message_popup_collection.h5
2 files changed, 23 insertions, 28 deletions
diff --git a/ui/message_center/views/message_popup_collection.cc b/ui/message_center/views/message_popup_collection.cc
index 2039d49..bc2da0c 100644
--- a/ui/message_center/views/message_popup_collection.cc
+++ b/ui/message_center/views/message_popup_collection.cc
@@ -65,8 +65,6 @@ MessagePopupCollection::MessagePopupCollection(gfx::NativeView parent,
: parent_(parent),
message_center_(message_center),
tray_(tray),
- display_id_(gfx::Display::kInvalidDisplayID),
- screen_(NULL),
defer_counter_(0),
latest_toast_entered_(NULL),
user_is_closing_toasts_by_clicking_(false),
@@ -76,13 +74,34 @@ MessagePopupCollection::MessagePopupCollection(gfx::NativeView parent,
DCHECK(message_center_);
defer_timer_.reset(new base::OneShotTimer<MessagePopupCollection>);
message_center_->AddObserver(this);
+ gfx::Screen* screen = NULL;
+ gfx::Display display;
+ if (!parent_) {
+ // On Win+Aura, we don't have a parent since the popups currently show up
+ // on the Windows desktop, not in the Aura/Ash desktop. This code will
+ // display the popups on the primary display.
+ screen = gfx::Screen::GetNativeScreen();
+ display = screen->GetPrimaryDisplay();
+ } else {
+ screen = gfx::Screen::GetScreenFor(parent_);
+ display = screen->GetDisplayNearestWindow(parent_);
+ }
+ screen->AddObserver(this);
+
+ display_id_ = display.id();
+ work_area_ = display.work_area();
+ ComputePopupAlignment(work_area_, display.bounds());
+
+ // We should not update before work area and popup alignment are computed.
+ DoUpdateIfPossible();
}
MessagePopupCollection::~MessagePopupCollection() {
weak_factory_.InvalidateWeakPtrs();
- if (screen_)
- screen_->RemoveObserver(this);
+ gfx::Screen* screen = parent_ ?
+ gfx::Screen::GetScreenFor(parent_) : gfx::Screen::GetNativeScreen();
+ screen->RemoveObserver(this);
message_center_->RemoveObserver(this);
CloseAllWidgets();
@@ -506,25 +525,6 @@ void MessagePopupCollection::DecrementDeferCounter() {
// deferred tasks are even able to run)
// Then, see if there is vacant space for new toasts.
void MessagePopupCollection::DoUpdateIfPossible() {
- if (!screen_) {
- gfx::Display display;
- if (!parent_) {
- // On Win+Aura, we don't have a parent since the popups currently show up
- // on the Windows desktop, not in the Aura/Ash desktop. This code will
- // display the popups on the primary display.
- screen_ = gfx::Screen::GetNativeScreen();
- display = screen_->GetPrimaryDisplay();
- } else {
- screen_ = gfx::Screen::GetScreenFor(parent_);
- display = screen_->GetDisplayNearestWindow(parent_);
- }
- screen_->AddObserver(this);
-
- display_id_ = display.id();
- work_area_ = display.work_area();
- ComputePopupAlignment(work_area_, display.bounds());
- }
-
if (defer_counter_ > 0)
return;
diff --git a/ui/message_center/views/message_popup_collection.h b/ui/message_center/views/message_popup_collection.h
index 907274e..6586b41 100644
--- a/ui/message_center/views/message_popup_collection.h
+++ b/ui/message_center/views/message_popup_collection.h
@@ -35,10 +35,6 @@ class WebNotificationTrayTest;
FORWARD_DECLARE_TEST(WebNotificationTrayTest, ManyPopupNotifications);
}
-namespace gfx {
-class Screen;
-}
-
namespace message_center {
namespace test {
class MessagePopupCollectionTest;
@@ -188,7 +184,6 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
Toasts toasts_;
gfx::Rect work_area_;
int64 display_id_;
- gfx::Screen* screen_;
// Specifies which corner of the screen popups should show up. This should
// ideally be the same corner the notification area (systray) is at.