OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/notifications/balloon_collection.h" |
| 6 |
| 7 #include "base/gfx/rect.h" |
| 8 #include "base/logging.h" |
| 9 #include "base/stl_util-inl.h" |
| 10 #include "chrome/browser/notifications/balloon.h" |
| 11 #include "chrome/browser/views/notifications/balloon_view.h" |
| 12 |
| 13 namespace { |
| 14 |
| 15 void GetMainScreenWorkArea(gfx::Rect* bounds) { |
| 16 DCHECK(bounds); |
| 17 RECT work_area = {0}; |
| 18 if (::SystemParametersInfo(SPI_GETWORKAREA, 0, &work_area, 0)) { |
| 19 bounds->SetRect(work_area.left, work_area.top, |
| 20 work_area.right, work_area.bottom); |
| 21 } else { |
| 22 // If call to ::SystemParametersInfo fails for some reason, we simply get |
| 23 // the full screen size as an alternative. |
| 24 bounds->SetRect(0, 0, |
| 25 ::GetSystemMetrics(SM_CXSCREEN) - 1, |
| 26 ::GetSystemMetrics(SM_CYSCREEN) - 1); |
| 27 } |
| 28 } |
| 29 |
| 30 } // namespace |
| 31 |
| 32 Balloon* BalloonCollectionImpl::MakeBalloon(const Notification& notification, |
| 33 Profile* profile) { |
| 34 Balloon* balloon = new Balloon(notification, profile, this); |
| 35 balloon->set_view(new BalloonViewImpl()); |
| 36 gfx::Size size(layout_.min_balloon_width(), layout_.min_balloon_height()); |
| 37 balloon->set_size(size); |
| 38 return balloon; |
| 39 } |
| 40 |
| 41 bool BalloonCollectionImpl::Layout::RefreshSystemMetrics() { |
| 42 bool changed = false; |
| 43 |
| 44 gfx::Rect new_work_area(work_area_.x(), work_area_.y(), |
| 45 work_area_.width(), work_area_.height()); |
| 46 GetMainScreenWorkArea(&new_work_area); |
| 47 if (!work_area_.Equals(new_work_area)) { |
| 48 work_area_.SetRect(new_work_area.x(), new_work_area.y(), |
| 49 new_work_area.width(), new_work_area.height()); |
| 50 changed = true; |
| 51 } |
| 52 |
| 53 return changed; |
| 54 } |
OLD | NEW |