Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Side by Side Diff: chrome/browser/notifications/balloon.cc

Issue 5361006: For OSX, make it so that notifications only start resizing after the first paint is done. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser
Patch Set: Fix ifdef. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/notifications/balloon_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/notifications/balloon.h" 5 #include "chrome/browser/notifications/balloon.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/notifications/balloon_collection.h" 8 #include "chrome/browser/notifications/balloon_collection.h"
9 #include "chrome/browser/notifications/notification.h" 9 #include "chrome/browser/notifications/notification.h"
10 #include "chrome/browser/renderer_host/site_instance.h" 10 #include "chrome/browser/renderer_host/site_instance.h"
11 #include "gfx/rect.h" 11 #include "gfx/rect.h"
12 #include "gfx/size.h"
12 13
13 Balloon::Balloon(const Notification& notification, Profile* profile, 14 Balloon::Balloon(const Notification& notification, Profile* profile,
14 BalloonCollection* collection) 15 BalloonCollection* collection)
15 : profile_(profile), 16 : profile_(profile),
16 notification_(new Notification(notification)), 17 notification_(new Notification(notification)),
17 collection_(collection) { 18 collection_(collection) {
18 } 19 }
19 20
20 Balloon::~Balloon() { 21 Balloon::~Balloon() {
21 } 22 }
22 23
23 void Balloon::SetPosition(const gfx::Point& upper_left, bool reposition) { 24 void Balloon::SetPosition(const gfx::Point& upper_left, bool reposition) {
24 position_ = upper_left; 25 position_ = upper_left;
25 if (reposition && balloon_view_.get()) 26 if (reposition && balloon_view_.get())
26 balloon_view_->RepositionToBalloon(); 27 balloon_view_->RepositionToBalloon();
27 } 28 }
28 29
29 void Balloon::SetContentPreferredSize(const gfx::Size& size) { 30 void Balloon::SetContentPreferredSize(const gfx::Size& size) {
30 collection_->ResizeBalloon(this, size); 31 gfx::Size new_size(size);
32 #if defined(OS_MACOSX)
John Gregg 2010/11/30 00:25:22 add comment with a TODO and bug # about making thi
33 // Only allow the size of notifications to grow. This stops the balloon
34 // from jumping between sizes due to dynamic content. For example, the
35 // balloon's contents may adjust due to changes in
36 // document.body.clientHeight.
37 new_size.set_height(std::max(new_size.height(), content_size_.height()));
38
39 if (content_size_ == new_size)
40 return;
41 #endif
42 collection_->ResizeBalloon(this, new_size);
31 } 43 }
32 44
33 void Balloon::set_view(BalloonView* balloon_view) { 45 void Balloon::set_view(BalloonView* balloon_view) {
34 balloon_view_.reset(balloon_view); 46 balloon_view_.reset(balloon_view);
35 } 47 }
36 48
37 void Balloon::Show() { 49 void Balloon::Show() {
38 notification_->Display(); 50 notification_->Display();
39 if (balloon_view_.get()) { 51 if (balloon_view_.get()) {
40 balloon_view_->Show(this); 52 balloon_view_->Show(this);
(...skipping 18 matching lines...) Expand all
59 notification_->Close(by_user); 71 notification_->Close(by_user);
60 collection_->OnBalloonClosed(this); 72 collection_->OnBalloonClosed(this);
61 } 73 }
62 74
63 void Balloon::CloseByScript() { 75 void Balloon::CloseByScript() {
64 // A user-initiated close begins with the view and then closes this object; 76 // A user-initiated close begins with the view and then closes this object;
65 // we simulate that with a script-initiated close but pass |by_user|=false. 77 // we simulate that with a script-initiated close but pass |by_user|=false.
66 DCHECK(balloon_view_.get()); 78 DCHECK(balloon_view_.get());
67 balloon_view_->Close(false); 79 balloon_view_->Close(false);
68 } 80 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/notifications/balloon_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698