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

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

Issue 21372006: Revert 212329 "Reland "Close web contents modal dialogs on conte..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 | Annotate | Revision Log
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 13 matching lines...) Expand all
24 24
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 : web_contents_(web_contents), 34 : delegate_(delegate),
35 delegate_(delegate),
36 window_(NULL) { 35 window_(NULL) {
37 dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); 36 dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing);
38 GtkWidget* label = gtk_label_new( 37 GtkWidget* label = gtk_label_new(
39 UTF16ToUTF8(delegate->GetMessage()).c_str()); 38 UTF16ToUTF8(delegate->GetMessage()).c_str());
40 gfx::Image* icon = delegate->GetIcon(); 39 gfx::Image* icon = delegate->GetIcon();
41 GtkWidget* image = icon ? gtk_image_new_from_pixbuf(icon->ToGdkPixbuf()) 40 GtkWidget* image = icon ? gtk_image_new_from_pixbuf(icon->ToGdkPixbuf())
42 : gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION, 41 : gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION,
43 GTK_ICON_SIZE_DIALOG); 42 GTK_ICON_SIZE_DIALOG);
44 gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0); 43 gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0);
45 44
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (accept_button_icon_id) { 93 if (accept_button_icon_id) {
95 gtk_button_set_image(GTK_BUTTON(ok_), gtk_image_new_from_stock( 94 gtk_button_set_image(GTK_BUTTON(ok_), gtk_image_new_from_stock(
96 accept_button_icon_id, GTK_ICON_SIZE_BUTTON)); 95 accept_button_icon_id, GTK_ICON_SIZE_BUTTON));
97 } 96 }
98 g_signal_connect(ok_, "clicked", G_CALLBACK(OnAcceptThunk), this); 97 g_signal_connect(ok_, "clicked", G_CALLBACK(OnAcceptThunk), this);
99 gtk_box_pack_end(GTK_BOX(buttonBox), ok_, FALSE, TRUE, 0); 98 gtk_box_pack_end(GTK_BOX(buttonBox), ok_, FALSE, TRUE, 0);
100 99
101 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroyThunk), this); 100 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroyThunk), this);
102 101
103 window_ = CreateWebContentsModalDialogGtk(dialog_, cancel_); 102 window_ = CreateWebContentsModalDialogGtk(dialog_, cancel_);
104 delegate_->set_operations_delegate(this); 103 delegate_->set_close_delegate(this);
105 104
106 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 105 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
107 WebContentsModalDialogManager::FromWebContents(web_contents); 106 WebContentsModalDialogManager::FromWebContents(web_contents);
108 web_contents_modal_dialog_manager->ShowDialog(window_); 107 web_contents_modal_dialog_manager->ShowDialog(window_);
109 } 108 }
110 109
111 TabModalConfirmDialogGtk::~TabModalConfirmDialogGtk() { 110 TabModalConfirmDialogGtk::~TabModalConfirmDialogGtk() {
112 gtk_widget_destroy(dialog_); 111 gtk_widget_destroy(dialog_);
113 } 112 }
114 113
115 void TabModalConfirmDialogGtk::AcceptTabModalDialog() { 114 void TabModalConfirmDialogGtk::AcceptTabModalDialog() {
116 OnAccept(NULL); 115 OnAccept(NULL);
117 } 116 }
118 117
119 void TabModalConfirmDialogGtk::CancelTabModalDialog() { 118 void TabModalConfirmDialogGtk::CancelTabModalDialog() {
120 OnCancel(NULL); 119 OnCancel(NULL);
121 } 120 }
122 121
123 void TabModalConfirmDialogGtk::CloseDialog() { 122 void TabModalConfirmDialogGtk::CloseDialog() {
124 gtk_widget_destroy(window_); 123 gtk_widget_destroy(window_);
125 } 124 }
126 125
127 void TabModalConfirmDialogGtk::SetPreventCloseOnLoadStart(bool prevent) {
128 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
129 WebContentsModalDialogManager::FromWebContents(web_contents_);
130 web_contents_modal_dialog_manager->SetPreventCloseOnLoadStart(window_,
131 prevent);
132 }
133
134 void TabModalConfirmDialogGtk::OnAccept(GtkWidget* widget) { 126 void TabModalConfirmDialogGtk::OnAccept(GtkWidget* widget) {
135 delegate_->Accept(); 127 delegate_->Accept();
136 } 128 }
137 129
138 void TabModalConfirmDialogGtk::OnCancel(GtkWidget* widget) { 130 void TabModalConfirmDialogGtk::OnCancel(GtkWidget* widget) {
139 delegate_->Cancel(); 131 delegate_->Cancel();
140 } 132 }
141 133
142 void TabModalConfirmDialogGtk::OnLinkClicked(GtkWidget* widget) { 134 void TabModalConfirmDialogGtk::OnLinkClicked(GtkWidget* widget) {
143 delegate_->LinkClicked(event_utils::DispositionForCurrentButtonPressEvent()); 135 delegate_->LinkClicked(event_utils::DispositionForCurrentButtonPressEvent());
144 } 136 }
145 137
146 void TabModalConfirmDialogGtk::OnDestroy(GtkWidget* widget) { 138 void TabModalConfirmDialogGtk::OnDestroy(GtkWidget* widget) {
147 delete this; 139 delete this;
148 } 140 }
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.h ('k') | trunk/src/chrome/browser/ui/tab_modal_confirm_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698