OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/confirm_infobar_gtk.h" | 5 #include "chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/ui/gtk/event_utils.h" | 10 #include "chrome/browser/ui/gtk/event_utils.h" |
11 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 11 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
12 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" | 12 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" |
13 #include "chrome/browser/ui/gtk/gtk_util.h" | 13 #include "chrome/browser/ui/gtk/gtk_util.h" |
14 #include "ui/base/gtk/gtk_signal_registrar.h" | 14 #include "ui/base/gtk/gtk_signal_registrar.h" |
15 | 15 |
16 | 16 |
17 // ConfirmInfoBarDelegate ------------------------------------------------------ | 17 // ConfirmInfoBarDelegate ------------------------------------------------------ |
18 | 18 |
19 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { | 19 // static |
20 return new ConfirmInfoBarGtk(owner, this); | 20 scoped_ptr<InfoBar> ConfirmInfoBarDelegate::CreateInfoBar( |
| 21 scoped_ptr<ConfirmInfoBarDelegate> delegate) { |
| 22 return scoped_ptr<InfoBar>(new ConfirmInfoBarGtk(delegate.Pass())); |
21 } | 23 } |
22 | 24 |
23 | 25 |
24 // ConfirmInfoBarGtk ----------------------------------------------------------- | 26 // ConfirmInfoBarGtk ----------------------------------------------------------- |
25 | 27 |
26 ConfirmInfoBarGtk::ConfirmInfoBarGtk(InfoBarService* owner, | 28 ConfirmInfoBarGtk::ConfirmInfoBarGtk( |
27 ConfirmInfoBarDelegate* delegate) | 29 scoped_ptr<ConfirmInfoBarDelegate> delegate) |
28 : InfoBarGtk(owner, delegate), | 30 : InfoBarGtk(delegate.PassAs<InfoBarDelegate>()), |
29 confirm_hbox_(NULL), | 31 confirm_hbox_(NULL), |
30 size_group_(NULL) { | 32 size_group_(NULL) { |
31 } | 33 } |
32 | 34 |
33 ConfirmInfoBarGtk::~ConfirmInfoBarGtk() { | 35 ConfirmInfoBarGtk::~ConfirmInfoBarGtk() { |
34 if (size_group_) | 36 if (size_group_) |
35 g_object_unref(size_group_); | 37 g_object_unref(size_group_); |
36 } | 38 } |
37 | 39 |
38 void ConfirmInfoBarGtk::InitWidgets() { | 40 void ConfirmInfoBarGtk::PlatformSpecificSetOwner() { |
39 InfoBarGtk::InitWidgets(); | 41 InfoBarGtk::PlatformSpecificSetOwner(); |
40 | 42 |
41 confirm_hbox_ = gtk_chrome_shrinkable_hbox_new(FALSE, FALSE, | 43 confirm_hbox_ = gtk_chrome_shrinkable_hbox_new(FALSE, FALSE, |
42 kEndOfLabelSpacing); | 44 kEndOfLabelSpacing); |
43 // This alignment allocates the confirm hbox only as much space as it | 45 // This alignment allocates the confirm hbox only as much space as it |
44 // requests, and less if there is not enough available. | 46 // requests, and less if there is not enough available. |
45 GtkWidget* align = gtk_alignment_new(0, 0, 0, 1); | 47 GtkWidget* align = gtk_alignment_new(0, 0, 0, 1); |
46 gtk_container_add(GTK_CONTAINER(align), confirm_hbox_); | 48 gtk_container_add(GTK_CONTAINER(align), confirm_hbox_); |
47 gtk_box_pack_start(GTK_BOX(hbox()), align, TRUE, TRUE, 0); | 49 gtk_box_pack_start(GTK_BOX(hbox()), align, TRUE, TRUE, 0); |
48 | 50 |
49 // We add the buttons in reverse order and pack end instead of start so | 51 // We add the buttons in reverse order and pack end instead of start so |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 void ConfirmInfoBarGtk::OnCancelButton(GtkWidget* widget) { | 106 void ConfirmInfoBarGtk::OnCancelButton(GtkWidget* widget) { |
105 if (delegate()->AsConfirmInfoBarDelegate()->Cancel()) | 107 if (delegate()->AsConfirmInfoBarDelegate()->Cancel()) |
106 RemoveSelf(); | 108 RemoveSelf(); |
107 } | 109 } |
108 | 110 |
109 void ConfirmInfoBarGtk::OnLinkClicked(GtkWidget* widget) { | 111 void ConfirmInfoBarGtk::OnLinkClicked(GtkWidget* widget) { |
110 if (delegate()->AsConfirmInfoBarDelegate()->LinkClicked( | 112 if (delegate()->AsConfirmInfoBarDelegate()->LinkClicked( |
111 event_utils::DispositionForCurrentButtonPressEvent())) | 113 event_utils::DispositionForCurrentButtonPressEvent())) |
112 RemoveSelf(); | 114 RemoveSelf(); |
113 } | 115 } |
OLD | NEW |