OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/notifications/balloon_view_views.h" | 5 #include "chrome/browser/ui/views/notifications/balloon_view_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 new views::BubbleBorder(views::BubbleBorder::FLOAT, | 109 new views::BubbleBorder(views::BubbleBorder::FLOAT, |
110 views::BubbleBorder::NO_SHADOW); | 110 views::BubbleBorder::NO_SHADOW); |
111 set_border(bubble_border); | 111 set_border(bubble_border); |
112 } | 112 } |
113 | 113 |
114 BalloonViewImpl::~BalloonViewImpl() { | 114 BalloonViewImpl::~BalloonViewImpl() { |
115 } | 115 } |
116 | 116 |
117 void BalloonViewImpl::Close(bool by_user) { | 117 void BalloonViewImpl::Close(bool by_user) { |
118 animation_->Stop(); | 118 animation_->Stop(); |
119 html_contents_->Shutdown(); | 119 // Destroy html_contents_ here since it relies on Profile which might get |
120 // Detach contents from widget before then close. | 120 // deleted before the destructor is called when the views are torn down. |
| 121 html_contents_.reset(); |
| 122 // Detach contents from the widget before they close. |
121 // This is necessary because a widget may be deleted | 123 // This is necessary because a widget may be deleted |
122 // after this when chrome is shutting down. | 124 // after this when chrome is shutting down. |
123 html_container_->GetRootView()->RemoveAllChildViews(true); | 125 html_container_->GetRootView()->RemoveAllChildViews(true); |
124 html_container_->Close(); | 126 html_container_->Close(); |
125 frame_container_->GetRootView()->RemoveAllChildViews(true); | 127 frame_container_->GetRootView()->RemoveAllChildViews(true); |
126 frame_container_->Close(); | 128 frame_container_->Close(); |
127 closed_by_user_ = by_user; | 129 closed_by_user_ = by_user; |
128 // |frame_container_->::Close()| is async. When processed it'll call back to | 130 // |frame_container_->::Close()| is async. When processed it'll call back to |
129 // DeleteDelegate() and we'll cleanup. | 131 // DeleteDelegate() and we'll cleanup. |
130 } | 132 } |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 return; | 529 return; |
528 } | 530 } |
529 | 531 |
530 // If the renderer process attached to this balloon is disconnected | 532 // If the renderer process attached to this balloon is disconnected |
531 // (e.g., because of a crash), we want to close the balloon. | 533 // (e.g., because of a crash), we want to close the balloon. |
532 notification_registrar_.Remove( | 534 notification_registrar_.Remove( |
533 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, | 535 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, |
534 content::Source<Balloon>(balloon_)); | 536 content::Source<Balloon>(balloon_)); |
535 Close(false); | 537 Close(false); |
536 } | 538 } |
OLD | NEW |