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 // static | 19 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { |
20 scoped_ptr<InfoBar> ConfirmInfoBarDelegate::CreateInfoBar( | 20 return new ConfirmInfoBarGtk(owner, this); |
21 scoped_ptr<ConfirmInfoBarDelegate> delegate) { | |
22 return scoped_ptr<InfoBar>(new ConfirmInfoBarGtk(delegate.Pass())); | |
23 } | 21 } |
24 | 22 |
25 | 23 |
26 // ConfirmInfoBarGtk ----------------------------------------------------------- | 24 // ConfirmInfoBarGtk ----------------------------------------------------------- |
27 | 25 |
28 ConfirmInfoBarGtk::ConfirmInfoBarGtk( | 26 ConfirmInfoBarGtk::ConfirmInfoBarGtk(InfoBarService* owner, |
29 scoped_ptr<ConfirmInfoBarDelegate> delegate) | 27 ConfirmInfoBarDelegate* delegate) |
30 : InfoBarGtk(delegate.PassAs<InfoBarDelegate>()), | 28 : InfoBarGtk(owner, delegate), |
31 confirm_hbox_(NULL), | 29 confirm_hbox_(NULL), |
32 size_group_(NULL) { | 30 size_group_(NULL) { |
33 } | 31 } |
34 | 32 |
35 ConfirmInfoBarGtk::~ConfirmInfoBarGtk() { | 33 ConfirmInfoBarGtk::~ConfirmInfoBarGtk() { |
36 if (size_group_) | 34 if (size_group_) |
37 g_object_unref(size_group_); | 35 g_object_unref(size_group_); |
38 } | 36 } |
39 | 37 |
40 void ConfirmInfoBarGtk::PlatformSpecificSetOwner() { | 38 void ConfirmInfoBarGtk::InitWidgets() { |
41 InfoBarGtk::PlatformSpecificSetOwner(); | 39 InfoBarGtk::InitWidgets(); |
42 | 40 |
43 confirm_hbox_ = gtk_chrome_shrinkable_hbox_new(FALSE, FALSE, | 41 confirm_hbox_ = gtk_chrome_shrinkable_hbox_new(FALSE, FALSE, |
44 kEndOfLabelSpacing); | 42 kEndOfLabelSpacing); |
45 // This alignment allocates the confirm hbox only as much space as it | 43 // This alignment allocates the confirm hbox only as much space as it |
46 // requests, and less if there is not enough available. | 44 // requests, and less if there is not enough available. |
47 GtkWidget* align = gtk_alignment_new(0, 0, 0, 1); | 45 GtkWidget* align = gtk_alignment_new(0, 0, 0, 1); |
48 gtk_container_add(GTK_CONTAINER(align), confirm_hbox_); | 46 gtk_container_add(GTK_CONTAINER(align), confirm_hbox_); |
49 gtk_box_pack_start(GTK_BOX(hbox()), align, TRUE, TRUE, 0); | 47 gtk_box_pack_start(GTK_BOX(hbox()), align, TRUE, TRUE, 0); |
50 | 48 |
51 // We add the buttons in reverse order and pack end instead of start so | 49 // 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... |
106 void ConfirmInfoBarGtk::OnCancelButton(GtkWidget* widget) { | 104 void ConfirmInfoBarGtk::OnCancelButton(GtkWidget* widget) { |
107 if (delegate()->AsConfirmInfoBarDelegate()->Cancel()) | 105 if (delegate()->AsConfirmInfoBarDelegate()->Cancel()) |
108 RemoveSelf(); | 106 RemoveSelf(); |
109 } | 107 } |
110 | 108 |
111 void ConfirmInfoBarGtk::OnLinkClicked(GtkWidget* widget) { | 109 void ConfirmInfoBarGtk::OnLinkClicked(GtkWidget* widget) { |
112 if (delegate()->AsConfirmInfoBarDelegate()->LinkClicked( | 110 if (delegate()->AsConfirmInfoBarDelegate()->LinkClicked( |
113 event_utils::DispositionForCurrentButtonPressEvent())) | 111 event_utils::DispositionForCurrentButtonPressEvent())) |
114 RemoveSelf(); | 112 RemoveSelf(); |
115 } | 113 } |
OLD | NEW |