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

Side by Side Diff: trunk/src/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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/gtk/infobars/infobar_container_gtk.h" 5 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/message_loop/message_loop.h"
11 #include "chrome/browser/infobars/infobar_delegate.h" 12 #include "chrome/browser/infobars/infobar_delegate.h"
12 #include "chrome/browser/platform_util.h" 13 #include "chrome/browser/platform_util.h"
13 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 15 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
15 #include "chrome/browser/ui/gtk/gtk_util.h" 16 #include "chrome/browser/ui/gtk/gtk_util.h"
16 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" 17 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h"
17 #include "third_party/skia/include/effects/SkGradientShader.h" 18 #include "third_party/skia/include/effects/SkGradientShader.h"
18 #include "ui/gfx/canvas_skia_paint.h" 19 #include "ui/gfx/canvas_skia_paint.h"
19 #include "ui/gfx/color_utils.h" 20 #include "ui/gfx/color_utils.h"
20 #include "ui/gfx/gtk_compat.h" 21 #include "ui/gfx/gtk_compat.h"
(...skipping 24 matching lines...) Expand all
45 return sum; 46 return sum;
46 } 47 }
47 48
48 bool InfoBarContainerGtk::ContainsInfobars() const { 49 bool InfoBarContainerGtk::ContainsInfobars() const {
49 return !infobars_gtk_.empty(); 50 return !infobars_gtk_.empty();
50 } 51 }
51 52
52 void InfoBarContainerGtk::PlatformSpecificAddInfoBar(InfoBar* infobar, 53 void InfoBarContainerGtk::PlatformSpecificAddInfoBar(InfoBar* infobar,
53 size_t position) { 54 size_t position) {
54 InfoBarGtk* infobar_gtk = static_cast<InfoBarGtk*>(infobar); 55 InfoBarGtk* infobar_gtk = static_cast<InfoBarGtk*>(infobar);
56 infobar_gtk->InitWidgets();
55 infobars_gtk_.insert(infobars_gtk_.begin() + position, infobar_gtk); 57 infobars_gtk_.insert(infobars_gtk_.begin() + position, infobar_gtk);
56 58
57 if (infobars_gtk_.back() == infobar_gtk) { 59 if (infobars_gtk_.back() == infobar_gtk) {
58 gtk_box_pack_start(GTK_BOX(widget()), infobar_gtk->widget(), 60 gtk_box_pack_start(GTK_BOX(widget()), infobar_gtk->widget(),
59 FALSE, FALSE, 0); 61 FALSE, FALSE, 0);
60 } else { 62 } else {
61 // Clear out our container and then repack it to make sure everything is in 63 // Clear out our container and then repack it to make sure everything is in
62 // the right order. 64 // the right order.
63 gtk_util::RemoveAllChildren(widget()); 65 gtk_util::RemoveAllChildren(widget());
64 66
65 // Repack our container. 67 // Repack our container.
66 for (std::vector<InfoBarGtk*>::const_iterator it = infobars_gtk_.begin(); 68 for (std::vector<InfoBarGtk*>::const_iterator it = infobars_gtk_.begin();
67 it != infobars_gtk_.end(); ++it) { 69 it != infobars_gtk_.end(); ++it) {
68 gtk_box_pack_start(GTK_BOX(widget()), (*it)->widget(), 70 gtk_box_pack_start(GTK_BOX(widget()), (*it)->widget(),
69 FALSE, FALSE, 0); 71 FALSE, FALSE, 0);
70 } 72 }
71 } 73 }
72 } 74 }
73 75
74 void InfoBarContainerGtk::PlatformSpecificRemoveInfoBar(InfoBar* infobar) { 76 void InfoBarContainerGtk::PlatformSpecificRemoveInfoBar(InfoBar* infobar) {
75 InfoBarGtk* infobar_gtk = static_cast<InfoBarGtk*>(infobar); 77 InfoBarGtk* infobar_gtk = static_cast<InfoBarGtk*>(infobar);
76 gtk_container_remove(GTK_CONTAINER(widget()), infobar_gtk->widget()); 78 gtk_container_remove(GTK_CONTAINER(widget()), infobar_gtk->widget());
77 79
78 std::vector<InfoBarGtk*>::iterator it = 80 std::vector<InfoBarGtk*>::iterator it =
79 std::find(infobars_gtk_.begin(), infobars_gtk_.end(), infobar); 81 std::find(infobars_gtk_.begin(), infobars_gtk_.end(), infobar);
80 if (it != infobars_gtk_.end()) 82 if (it != infobars_gtk_.end())
81 infobars_gtk_.erase(it); 83 infobars_gtk_.erase(it);
84
85 base::MessageLoop::current()->DeleteSoon(FROM_HERE, infobar);
82 } 86 }
83 87
84 void InfoBarContainerGtk::PlatformSpecificInfoBarStateChanged( 88 void InfoBarContainerGtk::PlatformSpecificInfoBarStateChanged(
85 bool is_animating) { 89 bool is_animating) {
86 // Force a redraw of all infobars since something has a new height and we 90 // Force a redraw of all infobars since something has a new height and we
87 // need to make sure we animate our arrows. 91 // need to make sure we animate our arrows.
88 for (std::vector<InfoBarGtk*>::iterator it = infobars_gtk_.begin(); 92 for (std::vector<InfoBarGtk*>::iterator it = infobars_gtk_.begin();
89 it != infobars_gtk_.end(); ++it) { 93 it != infobars_gtk_.end(); ++it) {
90 gtk_widget_queue_draw((*it)->widget()); 94 gtk_widget_queue_draw((*it)->widget());
91 } 95 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 SkCanvas& canvas = *canvas_paint.sk_canvas(); 187 SkCanvas& canvas = *canvas_paint.sk_canvas();
184 188
185 canvas.drawPath(path, paint); 189 canvas.drawPath(path, paint);
186 190
187 paint.setShader(NULL); 191 paint.setShader(NULL);
188 paint.setColor(SkColorSetA(gfx::GdkColorToSkColor(source->GetBorderColor()), 192 paint.setColor(SkColorSetA(gfx::GdkColorToSkColor(source->GetBorderColor()),
189 SkColorGetA(grad_colors[0]))); 193 SkColorGetA(grad_colors[0])));
190 paint.setStyle(SkPaint::kStroke_Style); 194 paint.setStyle(SkPaint::kStroke_Style);
191 canvas.drawPath(path, paint); 195 canvas.drawPath(path, paint);
192 } 196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698