OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/html_dialog_gtk.h" | 5 #include "chrome/browser/ui/gtk/html_dialog_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 HtmlDialogGtk::~HtmlDialogGtk() { | 64 HtmlDialogGtk::~HtmlDialogGtk() { |
65 } | 65 } |
66 | 66 |
67 //////////////////////////////////////////////////////////////////////////////// | 67 //////////////////////////////////////////////////////////////////////////////// |
68 // HtmlDialogUIDelegate implementation: | 68 // HtmlDialogUIDelegate implementation: |
69 | 69 |
70 bool HtmlDialogGtk::IsDialogModal() const { | 70 bool HtmlDialogGtk::IsDialogModal() const { |
71 return delegate_ ? delegate_->IsDialogModal() : false; | 71 return delegate_ ? delegate_->IsDialogModal() : false; |
72 } | 72 } |
73 | 73 |
74 std::wstring HtmlDialogGtk::GetDialogTitle() const { | 74 string16 HtmlDialogGtk::GetDialogTitle() const { |
75 return delegate_ ? delegate_->GetDialogTitle() : L""; | 75 return delegate_ ? delegate_->GetDialogTitle() : string16(); |
76 } | 76 } |
77 | 77 |
78 GURL HtmlDialogGtk::GetDialogContentURL() const { | 78 GURL HtmlDialogGtk::GetDialogContentURL() const { |
79 if (delegate_) | 79 if (delegate_) |
80 return delegate_->GetDialogContentURL(); | 80 return delegate_->GetDialogContentURL(); |
81 else | 81 else |
82 return GURL(); | 82 return GURL(); |
83 } | 83 } |
84 | 84 |
85 void HtmlDialogGtk::GetWebUIMessageHandlers( | 85 void HtmlDialogGtk::GetWebUIMessageHandlers( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 HtmlDialogUI::GetPropertyAccessor().SetProperty( | 165 HtmlDialogUI::GetPropertyAccessor().SetProperty( |
166 tab_->tab_contents()->property_bag(), this); | 166 tab_->tab_contents()->property_bag(), this); |
167 | 167 |
168 tab_->controller().LoadURL(GetDialogContentURL(), | 168 tab_->controller().LoadURL(GetDialogContentURL(), |
169 GURL(), PageTransition::START_PAGE); | 169 GURL(), PageTransition::START_PAGE); |
170 GtkDialogFlags flags = GTK_DIALOG_NO_SEPARATOR; | 170 GtkDialogFlags flags = GTK_DIALOG_NO_SEPARATOR; |
171 if (delegate_->IsDialogModal()) | 171 if (delegate_->IsDialogModal()) |
172 flags = static_cast<GtkDialogFlags>(flags | GTK_DIALOG_MODAL); | 172 flags = static_cast<GtkDialogFlags>(flags | GTK_DIALOG_MODAL); |
173 | 173 |
174 dialog_ = gtk_dialog_new_with_buttons( | 174 dialog_ = gtk_dialog_new_with_buttons( |
175 WideToUTF8(delegate_->GetDialogTitle()).c_str(), | 175 UTF16ToUTF8(delegate_->GetDialogTitle()).c_str(), |
176 parent_window_, | 176 parent_window_, |
177 flags, | 177 flags, |
178 NULL); | 178 NULL); |
179 | 179 |
180 SetDialogStyle(); | 180 SetDialogStyle(); |
181 gtk_widget_set_name(dialog_, "chrome-html-dialog"); | 181 gtk_widget_set_name(dialog_, "chrome-html-dialog"); |
182 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); | 182 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); |
183 | 183 |
184 tab_contents_container_.reset(new TabContentsContainerGtk(NULL)); | 184 tab_contents_container_.reset(new TabContentsContainerGtk(NULL)); |
185 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_)->vbox), | 185 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_)->vbox), |
186 tab_contents_container_->widget(), TRUE, TRUE, 0); | 186 tab_contents_container_->widget(), TRUE, TRUE, 0); |
187 | 187 |
188 tab_contents_container_->SetTab(tab_.get()); | 188 tab_contents_container_->SetTab(tab_.get()); |
189 | 189 |
190 gfx::Size dialog_size; | 190 gfx::Size dialog_size; |
191 delegate_->GetDialogSize(&dialog_size); | 191 delegate_->GetDialogSize(&dialog_size); |
192 | 192 |
193 gtk_widget_set_size_request(GTK_WIDGET(tab_contents_container_->widget()), | 193 gtk_widget_set_size_request(GTK_WIDGET(tab_contents_container_->widget()), |
194 dialog_size.width(), | 194 dialog_size.width(), |
195 dialog_size.height()); | 195 dialog_size.height()); |
196 | 196 |
197 gtk_widget_show_all(dialog_); | 197 gtk_widget_show_all(dialog_); |
198 | 198 |
199 return GTK_WINDOW(dialog_); | 199 return GTK_WINDOW(dialog_); |
200 } | 200 } |
201 | 201 |
202 void HtmlDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { | 202 void HtmlDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { |
203 OnDialogClosed(std::string()); | 203 OnDialogClosed(std::string()); |
204 } | 204 } |
OLD | NEW |