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

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

Issue 17500003: Close web contents modal dialogs on content load start (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compilation fixes, change "inhibit" variable names Created 7 years, 5 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.h" 7 #include "base/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 : delegate_(delegate), 34 : web_contents_(web_contents),
35 delegate_(delegate),
35 window_(NULL) { 36 window_(NULL) {
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
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (accept_button_icon_id) { 94 if (accept_button_icon_id) {
94 gtk_button_set_image(GTK_BUTTON(ok_), gtk_image_new_from_stock( 95 gtk_button_set_image(GTK_BUTTON(ok_), gtk_image_new_from_stock(
95 accept_button_icon_id, GTK_ICON_SIZE_BUTTON)); 96 accept_button_icon_id, GTK_ICON_SIZE_BUTTON));
96 } 97 }
97 g_signal_connect(ok_, "clicked", G_CALLBACK(OnAcceptThunk), this); 98 g_signal_connect(ok_, "clicked", G_CALLBACK(OnAcceptThunk), this);
98 gtk_box_pack_end(GTK_BOX(buttonBox), ok_, FALSE, TRUE, 0); 99 gtk_box_pack_end(GTK_BOX(buttonBox), ok_, FALSE, TRUE, 0);
99 100
100 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroyThunk), this); 101 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroyThunk), this);
101 102
102 window_ = CreateWebContentsModalDialogGtk(dialog_, cancel_); 103 window_ = CreateWebContentsModalDialogGtk(dialog_, cancel_);
103 delegate_->set_close_delegate(this); 104 delegate_->set_operations_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() {
111 gtk_widget_destroy(dialog_); 112 gtk_widget_destroy(dialog_);
112 } 113 }
113 114
114 void TabModalConfirmDialogGtk::AcceptTabModalDialog() { 115 void TabModalConfirmDialogGtk::AcceptTabModalDialog() {
115 OnAccept(NULL); 116 OnAccept(NULL);
116 } 117 }
117 118
118 void TabModalConfirmDialogGtk::CancelTabModalDialog() { 119 void TabModalConfirmDialogGtk::CancelTabModalDialog() {
119 OnCancel(NULL); 120 OnCancel(NULL);
120 } 121 }
121 122
122 void TabModalConfirmDialogGtk::CloseDialog() { 123 void TabModalConfirmDialogGtk::CloseDialog() {
123 gtk_widget_destroy(window_); 124 gtk_widget_destroy(window_);
124 } 125 }
125 126
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
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.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698