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

Side by Side Diff: chrome/browser/views/notifications/balloon_view.cc

Issue 363003: Implement cancel() API on a Notification object so that script can cancel or ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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
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/views/notifications/balloon_view.h" 5 #include "chrome/browser/views/notifications/balloon_view.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/gfx/gdi_util.h" 10 #include "app/gfx/gdi_util.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } // namespace 64 } // namespace
65 65
66 class BalloonCloseButtonListener : public views::ButtonListener { 66 class BalloonCloseButtonListener : public views::ButtonListener {
67 public: 67 public:
68 explicit BalloonCloseButtonListener(BalloonView* view) 68 explicit BalloonCloseButtonListener(BalloonView* view)
69 : view_(view) {} 69 : view_(view) {}
70 virtual ~BalloonCloseButtonListener() {} 70 virtual ~BalloonCloseButtonListener() {}
71 71
72 // The only button currently is the close button. 72 // The only button currently is the close button.
73 virtual void ButtonPressed(views::Button* sender, const views::Event&) { 73 virtual void ButtonPressed(views::Button* sender, const views::Event&) {
74 view_->Close(); 74 view_->Close(true);
75 } 75 }
76 76
77 private: 77 private:
78 // Non-owned pointer to the view which owns this object. 78 // Non-owned pointer to the view which owns this object.
79 BalloonView* view_; 79 BalloonView* view_;
80 }; 80 };
81 81
82 BalloonViewImpl::BalloonViewImpl() 82 BalloonViewImpl::BalloonViewImpl()
83 : balloon_(NULL), 83 : balloon_(NULL),
84 frame_container_(NULL), 84 frame_container_(NULL),
(...skipping 18 matching lines...) Expand all
103 gfx::Insets insets(3, 3, 3, 3); 103 gfx::Insets insets(3, 3, 3, 3);
104 shelf_background_.reset( 104 shelf_background_.reset(
105 views::Painter::CreateImagePainter(*shelf_bitmap, insets, true)); 105 views::Painter::CreateImagePainter(*shelf_bitmap, insets, true));
106 balloon_background_.reset( 106 balloon_background_.reset(
107 views::Painter::CreateImagePainter(*border_bitmap, insets, false)); 107 views::Painter::CreateImagePainter(*border_bitmap, insets, false));
108 } 108 }
109 109
110 BalloonViewImpl::~BalloonViewImpl() { 110 BalloonViewImpl::~BalloonViewImpl() {
111 } 111 }
112 112
113 void BalloonViewImpl::Close() { 113 void BalloonViewImpl::Close(bool by_user) {
114 MessageLoop::current()->PostTask(FROM_HERE, 114 MessageLoop::current()->PostTask(FROM_HERE,
115 method_factory_.NewRunnableMethod(&BalloonViewImpl::DelayedClose)); 115 method_factory_.NewRunnableMethod(
116 &BalloonViewImpl::DelayedClose, by_user));
116 } 117 }
117 118
118 void BalloonViewImpl::DelayedClose() { 119 void BalloonViewImpl::DelayedClose(bool by_user) {
119 html_contents_->Shutdown(); 120 html_contents_->Shutdown();
120 html_container_->CloseNow(); 121 html_container_->CloseNow();
121 frame_container_->CloseNow(); 122 frame_container_->CloseNow();
122 balloon_->Close(true); 123 balloon_->OnClose(by_user);
123 } 124 }
124 125
125 void BalloonViewImpl::DidChangeBounds(const gfx::Rect& previous, 126 void BalloonViewImpl::DidChangeBounds(const gfx::Rect& previous,
126 const gfx::Rect& current) { 127 const gfx::Rect& current) {
127 SizeContentsWindow(); 128 SizeContentsWindow();
128 } 129 }
129 130
130 void BalloonViewImpl::SizeContentsWindow() { 131 void BalloonViewImpl::SizeContentsWindow() {
131 if (!html_container_ || !frame_container_) 132 if (!html_container_ || !frame_container_)
132 return; 133 return;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 SkScalar y_offset = 333 SkScalar y_offset =
333 static_cast<SkScalar>(background_height - kShelfBorderTopOverlap); 334 static_cast<SkScalar>(background_height - kShelfBorderTopOverlap);
334 canvas->translate(0, y_offset); 335 canvas->translate(0, y_offset);
335 shelf_background_->Paint(background_width, GetShelfHeight(), canvas); 336 shelf_background_->Paint(background_width, GetShelfHeight(), canvas);
336 canvas->restore(); 337 canvas->restore();
337 338
338 View::Paint(canvas); 339 View::Paint(canvas);
339 } 340 }
340 341
341 void BalloonViewImpl::Observe(NotificationType type, 342 void BalloonViewImpl::Observe(NotificationType type,
342 const NotificationSource& source, 343 const NotificationSource& source,
343 const NotificationDetails& details) { 344 const NotificationDetails& details) {
344 if (type != NotificationType::NOTIFY_BALLOON_DISCONNECTED) { 345 if (type != NotificationType::NOTIFY_BALLOON_DISCONNECTED) {
345 NOTREACHED(); 346 NOTREACHED();
346 return; 347 return;
347 } 348 }
348 349
349 // If the renderer process attached to this balloon is disconnected 350 // If the renderer process attached to this balloon is disconnected
350 // (e.g., because of a crash), we want to close the balloon. 351 // (e.g., because of a crash), we want to close the balloon.
351 notification_registrar_.Remove(this, 352 notification_registrar_.Remove(this,
352 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); 353 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_));
353 Close(); 354 Close(false);
354 } 355 }
OLDNEW
« no previous file with comments | « chrome/browser/views/notifications/balloon_view.h ('k') | chrome/renderer/notification_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698