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

Side by Side Diff: chrome/browser/tab_contents/infobar.cc

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 9 years, 3 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/tab_contents/infobar.h" 5 #include "chrome/browser/tab_contents/infobar.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "chrome/browser/infobars/infobar_tab_helper.h"
11 #include "chrome/browser/tab_contents/infobar_container.h" 12 #include "chrome/browser/tab_contents/infobar_container.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
13 #include "ui/base/animation/slide_animation.h" 14 #include "ui/base/animation/slide_animation.h"
14 15
15 SkColor GetInfoBarTopColor(InfoBarDelegate::Type infobar_type) { 16 SkColor GetInfoBarTopColor(InfoBarDelegate::Type infobar_type) {
16 // Yellow 17 // Yellow
17 static const SkColor kWarningBackgroundColorTop = 18 static const SkColor kWarningBackgroundColorTop =
18 SkColorSetRGB(255, 242, 183); 19 SkColorSetRGB(255, 242, 183);
19 // Gray 20 // Gray
20 static const SkColor kPageActionBackgroundColorTop = 21 static const SkColor kPageActionBackgroundColorTop =
(...skipping 11 matching lines...) Expand all
32 static const SkColor kPageActionBackgroundColorBottom = 33 static const SkColor kPageActionBackgroundColorBottom =
33 SkColorSetRGB(217, 217, 217); 34 SkColorSetRGB(217, 217, 217);
34 35
35 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ? 36 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ?
36 kWarningBackgroundColorBottom : kPageActionBackgroundColorBottom; 37 kWarningBackgroundColorBottom : kPageActionBackgroundColorBottom;
37 } 38 }
38 39
39 // TODO(pkasting): Port Mac to use this. 40 // TODO(pkasting): Port Mac to use this.
40 #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) 41 #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK)
41 42
42 InfoBar::InfoBar(TabContentsWrapper* owner, InfoBarDelegate* delegate) 43 InfoBar::InfoBar(TabContentsWrapper* owner, InfoBarDelegate* delegate)
Peter Kasting 2011/08/31 18:47:32 I think |owner| and |owner_| should be converted t
43 : owner_(owner), 44 : owner_(owner),
44 delegate_(delegate), 45 delegate_(delegate),
45 container_(NULL), 46 container_(NULL),
46 ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)), 47 ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)),
47 arrow_height_(0), 48 arrow_height_(0),
48 arrow_target_height_(kDefaultArrowTargetHeight), 49 arrow_target_height_(kDefaultArrowTargetHeight),
49 arrow_half_width_(0), 50 arrow_half_width_(0),
50 bar_height_(0), 51 bar_height_(0),
51 bar_target_height_(kDefaultBarTargetHeight) { 52 bar_target_height_(kDefaultBarTargetHeight) {
52 DCHECK(owner_ != NULL); 53 DCHECK(owner_ != NULL);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 98 }
98 99
99 void InfoBar::AnimationProgressed(const ui::Animation* animation) { 100 void InfoBar::AnimationProgressed(const ui::Animation* animation) {
100 RecalculateHeights(false); 101 RecalculateHeights(false);
101 } 102 }
102 103
103 void InfoBar::RemoveSelf() { 104 void InfoBar::RemoveSelf() {
104 // |owner_| can be NULL here, e.g. because the user clicks the close button 105 // |owner_| can be NULL here, e.g. because the user clicks the close button
105 // when the infobar is already closing. 106 // when the infobar is already closing.
106 if (delegate_ && owner_) 107 if (delegate_ && owner_)
107 owner_->RemoveInfoBar(delegate_); 108 owner_->infobar_tab_helper()->RemoveInfoBar(delegate_);
108 } 109 }
109 110
110 void InfoBar::SetBarTargetHeight(int height) { 111 void InfoBar::SetBarTargetHeight(int height) {
111 if (bar_target_height_ != height) { 112 if (bar_target_height_ != height) {
112 bar_target_height_ = height; 113 bar_target_height_ = height;
113 RecalculateHeights(false); 114 RecalculateHeights(false);
114 } 115 }
115 } 116 }
116 117
117 int InfoBar::OffsetY(const gfx::Size& prefsize) const { 118 int InfoBar::OffsetY(const gfx::Size& prefsize) const {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void InfoBar::MaybeDelete() { 176 void InfoBar::MaybeDelete() {
176 if (!owner_ && delegate_ && (animation_.GetCurrentValue() == 0.0)) { 177 if (!owner_ && delegate_ && (animation_.GetCurrentValue() == 0.0)) {
177 if (container_) 178 if (container_)
178 container_->RemoveInfoBar(this); 179 container_->RemoveInfoBar(this);
179 delegate_->InfoBarClosed(); 180 delegate_->InfoBarClosed();
180 delegate_ = NULL; 181 delegate_ = NULL;
181 } 182 }
182 } 183 }
183 184
184 #endif // TOOLKIT_VIEWS || TOOLKIT_GTK 185 #endif // TOOLKIT_VIEWS || TOOLKIT_GTK
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698