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

Side by Side Diff: chrome/browser/ui/views/infobars/extension_infobar.cc

Issue 6675033: Fix DCHECK in infobar animation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added InvalidateLayout calls to animation and target_height changes. Created 9 years, 8 months 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/infobars/extension_infobar.h" 5 #include "chrome/browser/ui/views/infobars/extension_infobar.h"
6 6
7 #include "chrome/browser/extensions/extension_context_menu_model.h" 7 #include "chrome/browser/extensions/extension_context_menu_model.h"
8 #include "chrome/browser/extensions/extension_host.h" 8 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/extensions/extension_infobar_delegate.h" 9 #include "chrome/browser/extensions/extension_infobar_delegate.h"
10 #include "chrome/browser/platform_util.h" 10 #include "chrome/browser/platform_util.h"
(...skipping 25 matching lines...) Expand all
36 36
37 ExtensionInfoBar::ExtensionInfoBar(ExtensionInfoBarDelegate* delegate) 37 ExtensionInfoBar::ExtensionInfoBar(ExtensionInfoBarDelegate* delegate)
38 : InfoBarView(delegate), 38 : InfoBarView(delegate),
39 delegate_(delegate), 39 delegate_(delegate),
40 menu_(NULL), 40 menu_(NULL),
41 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { 41 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) {
42 delegate->set_observer(this); 42 delegate->set_observer(this);
43 43
44 ExtensionView* extension_view = delegate->extension_host()->view(); 44 ExtensionView* extension_view = delegate->extension_host()->view();
45 int height = extension_view->GetPreferredSize().height(); 45 int height = extension_view->GetPreferredSize().height();
46 set_target_height((height > 0) ? 46 SetTargetHeight((height > 0) ?
47 (height + InfoBarBackground::kSeparatorLineHeight) : height); 47 (height + InfoBarBackground::kSeparatorLineHeight) : height);
48 48
49 // Get notified of resize events for the ExtensionView. 49 // Get notified of resize events for the ExtensionView.
50 extension_view->SetContainer(this); 50 extension_view->SetContainer(this);
51 } 51 }
52 52
53 ExtensionInfoBar::~ExtensionInfoBar() { 53 ExtensionInfoBar::~ExtensionInfoBar() {
54 if (GetDelegate()) { 54 if (GetDelegate()) {
55 GetDelegate()->extension_host()->view()->SetContainer(NULL); 55 GetDelegate()->extension_host()->view()->SetContainer(NULL);
56 GetDelegate()->set_observer(NULL); 56 GetDelegate()->set_observer(NULL);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // infobar view). 123 // infobar view).
124 if (delegate->closing()) 124 if (delegate->closing())
125 return; 125 return;
126 126
127 view->SetVisible(true); 127 view->SetVisible(true);
128 128
129 if (height() == 0) 129 if (height() == 0)
130 animation()->Reset(0.0); 130 animation()->Reset(0.0);
131 131
132 // Clamp height to a min and a max size of between 1 and 2 InfoBars. 132 // Clamp height to a min and a max size of between 1 and 2 InfoBars.
133 set_target_height(std::min(2 * kDefaultTargetHeight, 133 SetTargetHeight(std::min(2 * kDefaultTargetHeight,
134 std::max(kDefaultTargetHeight, view->GetPreferredSize().height()))); 134 std::max(kDefaultTargetHeight, view->GetPreferredSize().height())));
135 135
136 animation()->Show(); 136 animation()->Show();
137 } 137 }
138 138
139 void ExtensionInfoBar::OnImageLoaded(SkBitmap* image, 139 void ExtensionInfoBar::OnImageLoaded(SkBitmap* image,
140 const ExtensionResource& resource, 140 const ExtensionResource& resource,
141 int index) { 141 int index) {
142 if (!GetDelegate()) 142 if (!GetDelegate())
143 return; // The delegate can go away while we asynchronously load images. 143 return; // The delegate can go away while we asynchronously load images.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 NULL); 184 NULL);
185 } 185 }
186 186
187 options_menu_menu_.reset(new views::Menu2(options_menu_contents_.get())); 187 options_menu_menu_.reset(new views::Menu2(options_menu_contents_.get()));
188 options_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPLEFT); 188 options_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPLEFT);
189 } 189 }
190 190
191 ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() { 191 ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() {
192 return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL; 192 return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL;
193 } 193 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_infobar_apitest.cc ('k') | chrome/browser/ui/views/infobars/infobar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698