OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/infobars/extension_infobar.h" | 5 #include "chrome/browser/views/infobars/extension_infobar.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "app/slide_animation.h" | 8 #include "app/slide_animation.h" |
9 #include "chrome/browser/extensions/extension_context_menu_model.h" | 9 #include "chrome/browser/extensions/extension_context_menu_model.h" |
10 #include "chrome/browser/extensions/extension_infobar_delegate.h" | 10 #include "chrome/browser/extensions/extension_infobar_delegate.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 ExtensionInfoBar::~ExtensionInfoBar() { | 61 ExtensionInfoBar::~ExtensionInfoBar() { |
62 if (delegate_) { | 62 if (delegate_) { |
63 delegate_->extension_host()->view()->SetContainer(NULL); | 63 delegate_->extension_host()->view()->SetContainer(NULL); |
64 delegate_->set_observer(NULL); | 64 delegate_->set_observer(NULL); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 void ExtensionInfoBar::OnExtensionPreferredSizeChanged(ExtensionView* view) { | 68 void ExtensionInfoBar::OnExtensionPreferredSizeChanged(ExtensionView* view) { |
69 DCHECK(view == delegate_->extension_host()->view()); | 69 DCHECK(view == delegate_->extension_host()->view()); |
| 70 |
| 71 // When the infobar is closed, it animates to 0 vertical height. We'll |
| 72 // continue to get size changed notifications from the ExtensionView, but we |
| 73 // need to ignore them otherwise we'll try to re-animate open (and leak the |
| 74 // infobar view). |
| 75 if (delegate_->closing()) |
| 76 return; |
| 77 |
70 delegate_->extension_host()->view()->SetVisible(true); | 78 delegate_->extension_host()->view()->SetVisible(true); |
71 | 79 |
72 gfx::Size sz = view->GetPreferredSize(); | 80 gfx::Size sz = view->GetPreferredSize(); |
73 // Clamp height to a min and a max size of between 1 and 2 InfoBars. | 81 // Clamp height to a min and a max size of between 1 and 2 InfoBars. |
74 int default_height = static_cast<int>(InfoBar::kDefaultTargetHeight); | 82 int default_height = static_cast<int>(InfoBar::kDefaultTargetHeight); |
75 sz.set_height(std::max(default_height, sz.height())); | 83 sz.set_height(std::max(default_height, sz.height())); |
76 sz.set_height(std::min(2 * default_height, sz.height())); | 84 sz.set_height(std::min(2 * default_height, sz.height())); |
77 | 85 |
78 if (height() == 0) | 86 if (height() == 0) |
79 animation()->Reset(0.0); | 87 animation()->Reset(0.0); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 tracker_.LoadImage(extension, icon_resource, gfx::Size(size, size), | 173 tracker_.LoadImage(extension, icon_resource, gfx::Size(size, size), |
166 ImageLoadingTracker::DONT_CACHE); | 174 ImageLoadingTracker::DONT_CACHE); |
167 } else { | 175 } else { |
168 OnImageLoaded(NULL, icon_resource, 0); // |image|, |index|. | 176 OnImageLoaded(NULL, icon_resource, 0); // |image|, |index|. |
169 } | 177 } |
170 } | 178 } |
171 | 179 |
172 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() { | 180 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() { |
173 return new ExtensionInfoBar(this); | 181 return new ExtensionInfoBar(this); |
174 } | 182 } |
OLD | NEW |