| 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/views/html_dialog_view.h" | 5 #include "chrome/browser/ui/views/html_dialog_view.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 Browser* browser, | 43 Browser* browser, |
| 44 HtmlDialogUIDelegate* delegate, | 44 HtmlDialogUIDelegate* delegate, |
| 45 DialogStyle style) { | 45 DialogStyle style) { |
| 46 HtmlDialogView* html_view = new HtmlDialogView(profile, browser, delegate); | 46 HtmlDialogView* html_view = new HtmlDialogView(profile, browser, delegate); |
| 47 browser::CreateViewsWindow(parent, html_view, style); | 47 browser::CreateViewsWindow(parent, html_view, style); |
| 48 html_view->InitDialog(); | 48 html_view->InitDialog(); |
| 49 html_view->GetWidget()->Show(); | 49 html_view->GetWidget()->Show(); |
| 50 return html_view->GetWidget()->GetNativeWindow(); | 50 return html_view->GetWidget()->GetNativeWindow(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void CloseHtmlDialog(gfx::NativeWindow window) { |
| 54 views::Widget::GetWidgetForNativeWindow(window)->Close(); |
| 55 } |
| 56 |
| 53 } // namespace browser | 57 } // namespace browser |
| 54 | 58 |
| 55 //////////////////////////////////////////////////////////////////////////////// | 59 //////////////////////////////////////////////////////////////////////////////// |
| 56 // HtmlDialogView, public: | 60 // HtmlDialogView, public: |
| 57 | 61 |
| 58 HtmlDialogView::HtmlDialogView(Profile* profile, | 62 HtmlDialogView::HtmlDialogView(Profile* profile, |
| 59 Browser* browser, | 63 Browser* browser, |
| 60 HtmlDialogUIDelegate* delegate) | 64 HtmlDialogUIDelegate* delegate) |
| 61 : DOMView(), | 65 : DOMView(), |
| 62 HtmlDialogTabContentsDelegate(profile), | 66 HtmlDialogTabContentsDelegate(profile), |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 #endif | 249 #endif |
| 246 } | 250 } |
| 247 | 251 |
| 248 void HtmlDialogView::CloseContents(WebContents* source) { | 252 void HtmlDialogView::CloseContents(WebContents* source) { |
| 249 bool close_dialog = false; | 253 bool close_dialog = false; |
| 250 OnCloseContents(source, &close_dialog); | 254 OnCloseContents(source, &close_dialog); |
| 251 if (close_dialog) | 255 if (close_dialog) |
| 252 OnDialogClosed(std::string()); | 256 OnDialogClosed(std::string()); |
| 253 } | 257 } |
| 254 | 258 |
| 259 content::WebContents* HtmlDialogView::OpenURLFromTab( |
| 260 content::WebContents* source, |
| 261 const content::OpenURLParams& params) { |
| 262 content::WebContents* new_contents = NULL; |
| 263 if (delegate_ && |
| 264 delegate_->HandleOpenURLFromTab(source, params, &new_contents)) { |
| 265 return new_contents; |
| 266 } |
| 267 return HtmlDialogTabContentsDelegate::OpenURLFromTab(source, params); |
| 268 } |
| 269 |
| 270 void HtmlDialogView::AddNewContents(content::WebContents* source, |
| 271 content::WebContents* new_contents, |
| 272 WindowOpenDisposition disposition, |
| 273 const gfx::Rect& initial_pos, |
| 274 bool user_gesture) { |
| 275 if (delegate_ && delegate_->HandleAddNewContents( |
| 276 source, new_contents, disposition, initial_pos, user_gesture)) { |
| 277 return; |
| 278 } |
| 279 HtmlDialogTabContentsDelegate::AddNewContents( |
| 280 source, new_contents, disposition, initial_pos, user_gesture); |
| 281 } |
| 282 |
| 255 //////////////////////////////////////////////////////////////////////////////// | 283 //////////////////////////////////////////////////////////////////////////////// |
| 256 // HtmlDialogView: | 284 // HtmlDialogView: |
| 257 | 285 |
| 258 void HtmlDialogView::InitDialog() { | 286 void HtmlDialogView::InitDialog() { |
| 259 // Now Init the DOMView. This view runs in its own process to render the html. | 287 // Now Init the DOMView. This view runs in its own process to render the html. |
| 260 DOMView::Init(profile(), NULL); | 288 DOMView::Init(profile(), NULL); |
| 261 | 289 |
| 262 WebContents* web_contents = dom_contents_->web_contents(); | 290 WebContents* web_contents = dom_contents_->web_contents(); |
| 263 web_contents->SetDelegate(this); | 291 web_contents->SetDelegate(this); |
| 264 | 292 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 283 } | 311 } |
| 284 | 312 |
| 285 void HtmlDialogView::OnTabMainFrameFirstRender() { | 313 void HtmlDialogView::OnTabMainFrameFirstRender() { |
| 286 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) | 314 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) |
| 287 if (initialized_) { | 315 if (initialized_) { |
| 288 views::NativeWidgetGtk::UpdateFreezeUpdatesProperty( | 316 views::NativeWidgetGtk::UpdateFreezeUpdatesProperty( |
| 289 GTK_WINDOW(GetWidget()->GetNativeView()), false); | 317 GTK_WINDOW(GetWidget()->GetNativeView()), false); |
| 290 } | 318 } |
| 291 #endif | 319 #endif |
| 292 } | 320 } |
| OLD | NEW |