Skip to content

Commit

Permalink
notification balloons: Remove views and cocoa implementations of Ball…
Browse files Browse the repository at this point in the history
…oonCollection.

In both aura/views and mac, notifications are done through the message-center. So
the implementations of BalloonCollection are never used. So remove these. Only the
GTK version of the implementation remains.

BUG=354062, 361784
R=mukai@chromium.org, rsesek@chromium.org, sky@chromium.org

Review URL: https://codereview.chromium.org/231213003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262988 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sadrul@chromium.org committed Apr 10, 2014
1 parent 0ee1d0f commit 41a9d29
Show file tree
Hide file tree
Showing 27 changed files with 39 additions and 2,392 deletions.
555 changes: 0 additions & 555 deletions chrome/app/nibs/Notification.xib

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class MAYBE_ExtensionCrashRecoveryTest
it++;
std::string id = (*it)->id();
message_center->ClickOnNotification(id);
#if !defined(OS_CHROMEOS)
#if defined(TOOLKIT_GTK)
} else {
Balloon* balloon = GetNotificationDelegate(index);
ASSERT_TRUE(balloon);
Expand All @@ -167,7 +167,7 @@ class MAYBE_ExtensionCrashRecoveryTest
for (size_t i=0; i < index; i++) { it++; }
ASSERT_TRUE(g_browser_process->notification_ui_manager()->
CancelById((*it)->id()));
#if !defined(OS_CHROMEOS)
#if defined(TOOLKIT_GTK)
} else {
Balloon* balloon = GetNotificationDelegate(index);
ASSERT_TRUE(balloon);
Expand All @@ -181,17 +181,17 @@ class MAYBE_ExtensionCrashRecoveryTest
if (message_center::IsRichNotificationEnabled())
return message_center::MessageCenter::Get()->NotificationCount();

#if defined(OS_CHROMEOS)
CHECK(false);
return 0;
#else
#if defined(TOOLKIT_GTK)
return BalloonNotificationUIManager::GetInstanceForTesting()->
balloon_collection()->GetActiveBalloons().size();
#else
CHECK(false);
return 0;
#endif
}

private:
#if !defined(OS_CHROMEOS)
#if defined(TOOLKIT_GTK)
Balloon* GetNotificationDelegate(size_t index) {
BalloonNotificationUIManager* manager =
BalloonNotificationUIManager::GetInstanceForTesting();
Expand Down
26 changes: 1 addition & 25 deletions chrome/browser/notifications/balloon_collection_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,14 @@ const int kMinAllowedBalloonCount = 2;
// The spacing between the balloon and the panel.
const int kVerticalSpacingBetweenBalloonAndPanel = 5;

#if USE_OFFSETS
// Delay from the mouse leaving the balloon collection before
// there is a relayout, in milliseconds.
const int kRepositionDelayMs = 300;
#endif // USE_OFFSETS


BalloonCollectionImpl::BalloonCollectionImpl()
#if USE_OFFSETS
: reposition_factory_(this),
added_as_message_loop_observer_(false)
#endif
{
added_as_message_loop_observer_(false) {
registrar_.Add(this, chrome::NOTIFICATION_PANEL_COLLECTION_UPDATED,
content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE,
Expand All @@ -53,9 +48,7 @@ BalloonCollectionImpl::BalloonCollectionImpl()
}

BalloonCollectionImpl::~BalloonCollectionImpl() {
#if USE_OFFSETS
RemoveMessageLoopObserver();
#endif
}

void BalloonCollectionImpl::AddImpl(const Notification& notification,
Expand All @@ -69,11 +62,9 @@ void BalloonCollectionImpl::AddImpl(const Notification& notification,
layout_.max_balloon_height()));
new_balloon->SetPosition(layout_.OffScreenLocation(), false);
new_balloon->Show();
#if USE_OFFSETS
int count = base_.count();
if (count > 0 && layout_.RequiresOffsets())
new_balloon->set_offset(base_.balloons()[count - 1]->offset());
#endif
base_.Add(new_balloon, add_to_front);
PositionBalloons(false);

Expand Down Expand Up @@ -139,7 +130,6 @@ void BalloonCollectionImpl::DisplayChanged() {
}

void BalloonCollectionImpl::OnBalloonClosed(Balloon* source) {
#if USE_OFFSETS
// We want to free the balloon when finished.
const Balloons& balloons = base_.balloons();

Expand All @@ -166,7 +156,6 @@ void BalloonCollectionImpl::OnBalloonClosed(Balloon* source) {
if (apply_offset)
AddMessageLoopObserver();
}
#endif

base_.Remove(source);
PositionBalloons(true);
Expand Down Expand Up @@ -232,7 +221,6 @@ gfx::Rect BalloonCollectionImpl::GetBalloonsBoundingBox() const {
return bounds;
}

#if USE_OFFSETS
void BalloonCollectionImpl::AddMessageLoopObserver() {
if (!added_as_message_loop_observer_) {
base::MessageLoopForUI::current()->AddObserver(this);
Expand Down Expand Up @@ -278,7 +266,6 @@ void BalloonCollectionImpl::HandleMouseMoveEvent() {
reposition_factory_.InvalidateWeakPtrs();
}
}
#endif

BalloonCollectionImpl::Layout::Layout()
: placement_(INVALID),
Expand Down Expand Up @@ -392,13 +379,6 @@ bool BalloonCollectionImpl::Layout::RequiresOffsets() const {
// schemes that grow down do not require offsets.
bool offsets = (placement_ == VERTICALLY_FROM_BOTTOM_LEFT ||
placement_ == VERTICALLY_FROM_BOTTOM_RIGHT);

#if defined(OS_MACOSX)
// These schemes are in screen-coordinates, and top and bottom
// are inverted on Mac.
offsets = !offsets;
#endif

return offsets;
}

Expand Down Expand Up @@ -470,13 +450,9 @@ bool BalloonCollectionImpl::Layout::ComputeOffsetToMoveAbovePanels() {
bool BalloonCollectionImpl::Layout::RefreshSystemMetrics() {
bool changed = false;

#if defined(OS_MACOSX)
gfx::Rect new_work_area = GetMacWorkArea();
#else
// TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312
gfx::Rect new_work_area =
gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area();
#endif
if (work_area_ != new_work_area) {
work_area_.SetRect(new_work_area.x(), new_work_area.y(),
new_work_area.width(), new_work_area.height());
Expand Down
28 changes: 2 additions & 26 deletions chrome/browser/notifications/balloon_collection_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,13 @@
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"

// Mac balloons grow from the top down and have close buttons on top, so
// offsetting is not necessary for easy multiple-closing. Other platforms grow
// from the bottom up and have close buttons on top, so it is necessary.
#if defined(OS_MACOSX)
#define USE_OFFSETS 0
#else
#define USE_OFFSETS 1
#endif

// A balloon collection represents a set of notification balloons being
// shown on the screen. It positions new notifications according to
// a layout, and monitors for balloons being closed, which it reports
// up to its parent, the notification UI manager.
class BalloonCollectionImpl : public BalloonCollection,
public content::NotificationObserver
#if USE_OFFSETS
, public base::MessageLoopForUI::Observer
#endif
{
public content::NotificationObserver,
public base::MessageLoopForUI::Observer {
public:
BalloonCollectionImpl();
virtual ~BalloonCollectionImpl();
Expand All @@ -64,13 +52,8 @@ class BalloonCollectionImpl : public BalloonCollection,
const content::NotificationDetails& details) OVERRIDE;

// MessageLoopForUI::Observer interface.
#if defined(OS_WIN) || defined(USE_AURA)
virtual void WillProcessEvent(const base::NativeEvent& event) OVERRIDE;
virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
#elif defined(TOOLKIT_GTK)
virtual void WillProcessEvent(GdkEvent* event) OVERRIDE;
virtual void DidProcessEvent(GdkEvent* event) OVERRIDE;
#endif

// base_ is embedded, so this is a simple accessor for the number of
// balloons in the collection.
Expand Down Expand Up @@ -207,11 +190,6 @@ class BalloonCollectionImpl : public BalloonCollection,
// Cross-platform internal implementation for PositionBalloons.
void PositionBalloonsInternal(bool is_reposition);

#if defined(OS_MACOSX)
// Get the work area on Mac OS, without inverting the coordinates.
static gfx::Rect GetMacWorkArea();
#endif

// Base implementation for the collection of active balloons.
BalloonCollectionBase base_;

Expand All @@ -220,7 +198,6 @@ class BalloonCollectionImpl : public BalloonCollection,

content::NotificationRegistrar registrar_;

#if USE_OFFSETS
// Start and stop observing all UI events.
void AddMessageLoopObserver();
void RemoveMessageLoopObserver();
Expand All @@ -239,7 +216,6 @@ class BalloonCollectionImpl : public BalloonCollection,

// Is the balloon collection currently listening for UI events?
bool added_as_message_loop_observer_;
#endif

DISALLOW_COPY_AND_ASSIGN(BalloonCollectionImpl);
};
Expand Down
14 changes: 4 additions & 10 deletions chrome/browser/notifications/notification_ui_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,13 @@ NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) {
settings_provider.Pass());
}

#if defined(OS_CHROMEOS)
// Since we can't reach here for CrOS (see above), no point compiling all
// the dependent classes there.
CHECK(false);
return NULL;
#elif defined(OS_MACOSX) || defined(USE_AURA)
// IsRichNotificationEnabled() always returns true in this case.
CHECK(false);
return NULL;
#else
#if defined(TOOLKIT_GTK)
BalloonNotificationUIManager* balloon_manager =
new BalloonNotificationUIManager(local_state);
balloon_manager->SetBalloonCollection(BalloonCollection::Create());
return balloon_manager;
#else
CHECK(false);
return NULL;
#endif
}
4 changes: 2 additions & 2 deletions chrome/browser/task_manager/task_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "ui/base/text/bytes_formatting.h"
#include "ui/gfx/image/image_skia.h"

#if !defined(OS_CHROMEOS)
#if defined(TOOLKIT_GTK)
#include "chrome/browser/task_manager/notification_resource_provider.h"
#endif

Expand Down Expand Up @@ -276,7 +276,7 @@ TaskManagerModel::TaskManagerModel(TaskManager* task_manager)
scoped_ptr<WebContentsInformation>(
new task_manager::GuestInformation())));

#if !defined(OS_CHROMEOS) && defined(ENABLE_NOTIFICATIONS)
#if defined(TOOLKIT_GTK) && defined(ENABLE_NOTIFICATIONS)
ResourceProvider* provider =
task_manager::NotificationResourceProvider::Create(task_manager);
if (provider)
Expand Down
79 changes: 0 additions & 79 deletions chrome/browser/ui/cocoa/notifications/balloon_collection_cocoa.mm

This file was deleted.

Loading

0 comments on commit 41a9d29

Please sign in to comment.