| OLD | NEW |
| 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/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/property_bag.h" | 9 #include "base/property_bag.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 HtmlDialogUIDelegate* delegate, | 31 HtmlDialogUIDelegate* delegate, |
| 32 DialogStyle style) { | 32 DialogStyle style) { |
| 33 // Ignore style for now. The style parameter only used in the implementation | 33 // Ignore style for now. The style parameter only used in the implementation |
| 34 // in html_dialog_view.cc file. | 34 // in html_dialog_view.cc file. |
| 35 // TODO (bshe): Add style parameter to HtmlDialogGtk. | 35 // TODO (bshe): Add style parameter to HtmlDialogGtk. |
| 36 HtmlDialogGtk* html_dialog = | 36 HtmlDialogGtk* html_dialog = |
| 37 new HtmlDialogGtk(profile, browser, delegate, parent); | 37 new HtmlDialogGtk(profile, browser, delegate, parent); |
| 38 return html_dialog->InitDialog(); | 38 return html_dialog->InitDialog(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void CloseHtmlDialog(gfx::NativeWindow window) { |
| 42 gtk_widget_destroy(GTK_WIDGET(window)); |
| 43 } |
| 44 |
| 41 } // namespace browser | 45 } // namespace browser |
| 42 | 46 |
| 43 namespace { | 47 namespace { |
| 44 | 48 |
| 45 void SetDialogStyle() { | 49 void SetDialogStyle() { |
| 46 static bool style_was_set = false; | 50 static bool style_was_set = false; |
| 47 | 51 |
| 48 if (style_was_set) | 52 if (style_was_set) |
| 49 return; | 53 return; |
| 50 style_was_set = true; | 54 style_was_set = true; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 148 |
| 145 void HtmlDialogGtk::CloseContents(WebContents* source) { | 149 void HtmlDialogGtk::CloseContents(WebContents* source) { |
| 146 DCHECK(dialog_); | 150 DCHECK(dialog_); |
| 147 | 151 |
| 148 bool close_dialog = false; | 152 bool close_dialog = false; |
| 149 OnCloseContents(source, &close_dialog); | 153 OnCloseContents(source, &close_dialog); |
| 150 if (close_dialog) | 154 if (close_dialog) |
| 151 OnDialogClosed(std::string()); | 155 OnDialogClosed(std::string()); |
| 152 } | 156 } |
| 153 | 157 |
| 158 content::WebContents* HtmlDialogGtk::OpenURLFromTab( |
| 159 content::WebContents* source, |
| 160 const content::OpenURLParams& params) { |
| 161 content::WebContents* new_contents = NULL; |
| 162 if (delegate_ && |
| 163 delegate_->HandleOpenURLFromTab(source, params, &new_contents)) { |
| 164 return new_contents; |
| 165 } |
| 166 return HtmlDialogTabContentsDelegate::OpenURLFromTab(source, params); |
| 167 } |
| 168 |
| 169 void HtmlDialogGtk::AddNewContents(content::WebContents* source, |
| 170 content::WebContents* new_contents, |
| 171 WindowOpenDisposition disposition, |
| 172 const gfx::Rect& initial_pos, |
| 173 bool user_gesture) { |
| 174 if (delegate_ && delegate_->HandleAddNewContents( |
| 175 source, new_contents, disposition, initial_pos, user_gesture)) { |
| 176 return; |
| 177 } |
| 178 HtmlDialogTabContentsDelegate::AddNewContents( |
| 179 source, new_contents, disposition, initial_pos, user_gesture); |
| 180 } |
| 181 |
| 154 bool HtmlDialogGtk::ShouldShowDialogTitle() const { | 182 bool HtmlDialogGtk::ShouldShowDialogTitle() const { |
| 155 return true; | 183 return true; |
| 156 } | 184 } |
| 157 | 185 |
| 158 //////////////////////////////////////////////////////////////////////////////// | 186 //////////////////////////////////////////////////////////////////////////////// |
| 159 // content::WebContentsDelegate implementation: | 187 // content::WebContentsDelegate implementation: |
| 160 | 188 |
| 161 // A simplified version of BrowserWindowGtk::HandleKeyboardEvent(). | 189 // A simplified version of BrowserWindowGtk::HandleKeyboardEvent(). |
| 162 // We don't handle global keyboard shortcuts here, but that's fine since | 190 // We don't handle global keyboard shortcuts here, but that's fine since |
| 163 // they're all browser-specific. (This may change in the future.) | 191 // they're all browser-specific. (This may change in the future.) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 dialog_size.height()); | 246 dialog_size.height()); |
| 219 | 247 |
| 220 gtk_widget_show_all(dialog_); | 248 gtk_widget_show_all(dialog_); |
| 221 | 249 |
| 222 return GTK_WINDOW(dialog_); | 250 return GTK_WINDOW(dialog_); |
| 223 } | 251 } |
| 224 | 252 |
| 225 void HtmlDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { | 253 void HtmlDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { |
| 226 OnDialogClosed(std::string()); | 254 OnDialogClosed(std::string()); |
| 227 } | 255 } |
| OLD | NEW |