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

Side by Side Diff: chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.cc

Issue 18179004: Dismiss action in tab modal dialogs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test for Mac Created 7 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
OLDNEW
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/tab_modal_confirm_dialog_gtk.h" 5 #include "chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 14 matching lines...) Expand all
25 TabModalConfirmDialog* TabModalConfirmDialog::Create( 25 TabModalConfirmDialog* TabModalConfirmDialog::Create(
26 TabModalConfirmDialogDelegate* delegate, 26 TabModalConfirmDialogDelegate* delegate,
27 content::WebContents* web_contents) { 27 content::WebContents* web_contents) {
28 return new TabModalConfirmDialogGtk(delegate, web_contents); 28 return new TabModalConfirmDialogGtk(delegate, web_contents);
29 } 29 }
30 30
31 TabModalConfirmDialogGtk::TabModalConfirmDialogGtk( 31 TabModalConfirmDialogGtk::TabModalConfirmDialogGtk(
32 TabModalConfirmDialogDelegate* delegate, 32 TabModalConfirmDialogDelegate* delegate,
33 content::WebContents* web_contents) 33 content::WebContents* web_contents)
34 : delegate_(delegate), 34 : delegate_(delegate),
35 window_(NULL) { 35 window_(NULL),
36 closing_(false) {
36 dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); 37 dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing);
37 GtkWidget* label = gtk_label_new( 38 GtkWidget* label = gtk_label_new(
38 UTF16ToUTF8(delegate->GetMessage()).c_str()); 39 UTF16ToUTF8(delegate->GetMessage()).c_str());
39 gfx::Image* icon = delegate->GetIcon(); 40 gfx::Image* icon = delegate->GetIcon();
40 GtkWidget* image = icon ? gtk_image_new_from_pixbuf(icon->ToGdkPixbuf()) 41 GtkWidget* image = icon ? gtk_image_new_from_pixbuf(icon->ToGdkPixbuf())
41 : gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION, 42 : gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION,
42 GTK_ICON_SIZE_DIALOG); 43 GTK_ICON_SIZE_DIALOG);
43 gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0); 44 gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0);
44 45
45 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); 46 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 102
102 window_ = CreateWebContentsModalDialogGtk(dialog_, cancel_); 103 window_ = CreateWebContentsModalDialogGtk(dialog_, cancel_);
103 delegate_->set_close_delegate(this); 104 delegate_->set_close_delegate(this);
104 105
105 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 106 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
106 WebContentsModalDialogManager::FromWebContents(web_contents); 107 WebContentsModalDialogManager::FromWebContents(web_contents);
107 web_contents_modal_dialog_manager->ShowDialog(window_); 108 web_contents_modal_dialog_manager->ShowDialog(window_);
108 } 109 }
109 110
110 TabModalConfirmDialogGtk::~TabModalConfirmDialogGtk() { 111 TabModalConfirmDialogGtk::~TabModalConfirmDialogGtk() {
112 // Provide a disposition in case the dialog was closed without accepting or
113 // cancelling.
114 delegate_->Close();
115
111 gtk_widget_destroy(dialog_); 116 gtk_widget_destroy(dialog_);
112 } 117 }
113 118
114 void TabModalConfirmDialogGtk::AcceptTabModalDialog() { 119 void TabModalConfirmDialogGtk::AcceptTabModalDialog() {
115 OnAccept(NULL); 120 OnAccept(NULL);
116 } 121 }
117 122
118 void TabModalConfirmDialogGtk::CancelTabModalDialog() { 123 void TabModalConfirmDialogGtk::CancelTabModalDialog() {
119 OnCancel(NULL); 124 OnCancel(NULL);
120 } 125 }
121 126
122 void TabModalConfirmDialogGtk::CloseDialog() { 127 void TabModalConfirmDialogGtk::CloseDialog() {
123 gtk_widget_destroy(window_); 128 if (!closing_) {
129 closing_ = true;
130 gtk_widget_destroy(window_);
131 }
124 } 132 }
125 133
126 void TabModalConfirmDialogGtk::OnAccept(GtkWidget* widget) { 134 void TabModalConfirmDialogGtk::OnAccept(GtkWidget* widget) {
127 delegate_->Accept(); 135 delegate_->Accept();
128 } 136 }
129 137
130 void TabModalConfirmDialogGtk::OnCancel(GtkWidget* widget) { 138 void TabModalConfirmDialogGtk::OnCancel(GtkWidget* widget) {
131 delegate_->Cancel(); 139 delegate_->Cancel();
132 } 140 }
133 141
134 void TabModalConfirmDialogGtk::OnLinkClicked(GtkWidget* widget) { 142 void TabModalConfirmDialogGtk::OnLinkClicked(GtkWidget* widget) {
135 delegate_->LinkClicked(event_utils::DispositionForCurrentButtonPressEvent()); 143 delegate_->LinkClicked(event_utils::DispositionForCurrentButtonPressEvent());
136 } 144 }
137 145
138 void TabModalConfirmDialogGtk::OnDestroy(GtkWidget* widget) { 146 void TabModalConfirmDialogGtk::OnDestroy(GtkWidget* widget) {
139 delete this; 147 delete this;
140 } 148 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.h ('k') | chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698