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

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

Issue 10972002: chrome: Add TabModalConfirmDialog interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/ui/browser_dialogs.h" 9 #include "chrome/browser/ui/browser_dialogs.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
11 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 11 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/notification_types.h" 13 #include "content/public/browser/notification_types.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "ui/base/gtk/gtk_hig_constants.h" 15 #include "ui/base/gtk/gtk_hig_constants.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
18 18
19 namespace chrome { 19 TabModalConfirmDialog* TabModalConfirmDialog::Create(
20 20 TabModalConfirmDialogDelegate* delegate,
21 // Declared in browser_dialogs.h so others don't have to depend on our header. 21 TabContents* tab_contents) {
22 void ShowTabModalConfirmDialog(TabModalConfirmDialogDelegate* delegate, 22 return new TabModalConfirmDialogGtk(delegate, tab_contents);
23 TabContents* tab_contents) {
24 new TabModalConfirmDialogGtk(delegate, tab_contents);
25 } 23 }
26 24
27 } // namespace chrome
28
29 TabModalConfirmDialogGtk::TabModalConfirmDialogGtk( 25 TabModalConfirmDialogGtk::TabModalConfirmDialogGtk(
30 TabModalConfirmDialogDelegate* delegate, 26 TabModalConfirmDialogDelegate* delegate,
31 TabContents* tab_contents) 27 TabContents* tab_contents)
32 : delegate_(delegate) { 28 : delegate_(delegate) {
33 dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); 29 dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing);
34 GtkWidget* label = gtk_label_new( 30 GtkWidget* label = gtk_label_new(
35 UTF16ToUTF8(delegate->GetMessage()).c_str()); 31 UTF16ToUTF8(delegate->GetMessage()).c_str());
36 gfx::Image* icon = delegate->GetIcon(); 32 gfx::Image* icon = delegate->GetIcon();
37 GtkWidget* image = icon ? gtk_image_new_from_pixbuf(icon->ToGdkPixbuf()) 33 GtkWidget* image = icon ? gtk_image_new_from_pixbuf(icon->ToGdkPixbuf())
38 : gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION, 34 : gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 83 }
88 84
89 void TabModalConfirmDialogGtk::DeleteDelegate() { 85 void TabModalConfirmDialogGtk::DeleteDelegate() {
90 delete this; 86 delete this;
91 } 87 }
92 88
93 TabModalConfirmDialogGtk::~TabModalConfirmDialogGtk() { 89 TabModalConfirmDialogGtk::~TabModalConfirmDialogGtk() {
94 gtk_widget_destroy(dialog_); 90 gtk_widget_destroy(dialog_);
95 } 91 }
96 92
93 void TabModalConfirmDialogGtk::AcceptTabModalDialog() {
94 OnAccept(NULL);
95 }
96
97 void TabModalConfirmDialogGtk::CancelTabModalDialog() {
98 OnCancel(NULL);
99 }
100
97 void TabModalConfirmDialogGtk::OnAccept(GtkWidget* widget) { 101 void TabModalConfirmDialogGtk::OnAccept(GtkWidget* widget) {
98 delegate_->Accept(); 102 delegate_->Accept();
99 } 103 }
100 104
101 void TabModalConfirmDialogGtk::OnCancel(GtkWidget* widget) { 105 void TabModalConfirmDialogGtk::OnCancel(GtkWidget* widget) {
102 delegate_->Cancel(); 106 delegate_->Cancel();
103 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698