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

Side by Side Diff: chrome/browser/views/infobars/infobar_container.cc

Issue 165370: Merge 22711 - Fix a few bugs with the theme infobar:... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 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
« no previous file with comments | « chrome/browser/views/infobars/infobar_container.h ('k') | chrome/common/notification_type.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
Merged /trunk/src/chrome/browser/views/infobars/infobar_container.cc:r22711
Merged /branches/chrome_webkit_merge_branch/chrome/browser/views/infobars/infobar_container.cc:r69-2775
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/infobar_container.h" 5 #include "chrome/browser/views/infobars/infobar_container.h"
6 6
7 #include "chrome/browser/tab_contents/infobar_delegate.h" 7 #include "chrome/browser/tab_contents/infobar_delegate.h"
8 #include "chrome/browser/tab_contents/tab_contents.h" 8 #include "chrome/browser/tab_contents/tab_contents.h"
9 #include "chrome/browser/views/frame/browser_view.h" 9 #include "chrome/browser/views/frame/browser_view.h"
10 #include "chrome/browser/views/infobars/infobars.h" 10 #include "chrome/browser/views/infobars/infobars.h"
(...skipping 20 matching lines...) Expand all
31 // hierarchy does this automatically (see InfoBar::InfoBarRemoved). 31 // hierarchy does this automatically (see InfoBar::InfoBarRemoved).
32 RemoveAllChildViews(false); 32 RemoveAllChildViews(false);
33 tab_contents_ = contents; 33 tab_contents_ = contents;
34 if (tab_contents_) { 34 if (tab_contents_) {
35 UpdateInfoBars(); 35 UpdateInfoBars();
36 Source<TabContents> tc_source(tab_contents_); 36 Source<TabContents> tc_source(tab_contents_);
37 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_ADDED, 37 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_ADDED,
38 tc_source); 38 tc_source);
39 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, 39 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
40 tc_source); 40 tc_source);
41 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED,
42 tc_source);
41 } 43 }
42 } 44 }
43 45
44 void InfoBarContainer::InfoBarAnimated(bool completed) { 46 void InfoBarContainer::InfoBarAnimated(bool completed) {
45 if (browser_view_) 47 if (browser_view_)
46 browser_view_->SelectedTabToolbarSizeChanged(!completed); 48 browser_view_->SelectedTabToolbarSizeChanged(!completed);
47 } 49 }
48 50
49 void InfoBarContainer::RemoveDelegate(InfoBarDelegate* delegate) { 51 void InfoBarContainer::RemoveDelegate(InfoBarDelegate* delegate) {
50 tab_contents_->RemoveInfoBar(delegate); 52 tab_contents_->RemoveInfoBar(delegate);
(...skipping 30 matching lines...) Expand all
81 browser_view_->SelectedTabToolbarSizeChanged(false); 83 browser_view_->SelectedTabToolbarSizeChanged(false);
82 } 84 }
83 } 85 }
84 86
85 // InfoBarContainer, NotificationObserver implementation: ---------------------- 87 // InfoBarContainer, NotificationObserver implementation: ----------------------
86 88
87 void InfoBarContainer::Observe(NotificationType type, 89 void InfoBarContainer::Observe(NotificationType type,
88 const NotificationSource& source, 90 const NotificationSource& source,
89 const NotificationDetails& details) { 91 const NotificationDetails& details) {
90 if (type == NotificationType::TAB_CONTENTS_INFOBAR_ADDED) { 92 if (type == NotificationType::TAB_CONTENTS_INFOBAR_ADDED) {
91 AddInfoBar(Details<InfoBarDelegate>(details).ptr()); 93 AddInfoBar(Details<InfoBarDelegate>(details).ptr(), true); // animated
92 } else if (type == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED) { 94 } else if (type == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED) {
93 RemoveInfoBar(Details<InfoBarDelegate>(details).ptr()); 95 RemoveInfoBar(Details<InfoBarDelegate>(details).ptr(), true); // animated
96 } else if (type == NotificationType::TAB_CONTENTS_INFOBAR_REPLACED) {
97 std::pair<InfoBarDelegate*, InfoBarDelegate*>* delegates =
98 Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details).ptr();
99 ReplaceInfoBar(delegates->first, delegates->second);
94 } else { 100 } else {
95 NOTREACHED(); 101 NOTREACHED();
96 } 102 }
97 } 103 }
98 104
99 // InfoBarContainer, private: -------------------------------------------------- 105 // InfoBarContainer, private: --------------------------------------------------
100 106
101 void InfoBarContainer::UpdateInfoBars() { 107 void InfoBarContainer::UpdateInfoBars() {
102 for (int i = 0; i < tab_contents_->infobar_delegate_count(); ++i) { 108 for (int i = 0; i < tab_contents_->infobar_delegate_count(); ++i) {
103 InfoBarDelegate* delegate = tab_contents_->GetInfoBarDelegateAt(i); 109 InfoBarDelegate* delegate = tab_contents_->GetInfoBarDelegateAt(i);
104 InfoBar* infobar = delegate->CreateInfoBar(); 110 InfoBar* infobar = delegate->CreateInfoBar();
105 infobar->set_container(this); 111 infobar->set_container(this);
106 AddChildView(infobar); 112 AddChildView(infobar);
107 infobar->Open(); 113 infobar->Open();
108 } 114 }
109 } 115 }
110 116
111 void InfoBarContainer::AddInfoBar(InfoBarDelegate* delegate) { 117 void InfoBarContainer::AddInfoBar(InfoBarDelegate* delegate,
118 bool use_animation) {
112 InfoBar* infobar = delegate->CreateInfoBar(); 119 InfoBar* infobar = delegate->CreateInfoBar();
113 infobar->set_container(this); 120 infobar->set_container(this);
114 infobar->AnimateOpen();
115 AddChildView(infobar); 121 AddChildView(infobar);
122
123 if (use_animation)
124 infobar->AnimateOpen();
125 else
126 infobar->Open();
116 } 127 }
117 128
118 void InfoBarContainer::RemoveInfoBar(InfoBarDelegate* delegate) { 129 void InfoBarContainer::RemoveInfoBar(InfoBarDelegate* delegate,
130 bool use_animation) {
119 int index = 0; 131 int index = 0;
120 for (; index < tab_contents_->infobar_delegate_count(); ++index) { 132 for (; index < tab_contents_->infobar_delegate_count(); ++index) {
121 if (tab_contents_->GetInfoBarDelegateAt(index) == delegate) 133 if (tab_contents_->GetInfoBarDelegateAt(index) == delegate)
122 break; 134 break;
123 } 135 }
124 136
125 // The View will be removed once the Close animation completes. 137 InfoBar* infobar = static_cast<InfoBar*>(GetChildViewAt(index));
126 static_cast<InfoBar*>(GetChildViewAt(index))->AnimateClose(); 138 if (use_animation) {
139 // The View will be removed once the Close animation completes.
140 infobar->AnimateClose();
141 } else {
142 infobar->Close();
143 }
127 } 144 }
145
146 void InfoBarContainer::ReplaceInfoBar(InfoBarDelegate* old_delegate,
147 InfoBarDelegate* new_delegate) {
148 RemoveInfoBar(old_delegate, false); // no animation
149 AddInfoBar(new_delegate, false); // no animation
150 }
OLDNEW
« no previous file with comments | « chrome/browser/views/infobars/infobar_container.h ('k') | chrome/common/notification_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698