| 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/web_dialog_view.h" | 5 #include "chrome/browser/ui/views/web_dialog_view.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 using content::WebContents; | 31 using content::WebContents; |
| 32 using content::WebUIMessageHandler; | 32 using content::WebUIMessageHandler; |
| 33 | 33 |
| 34 namespace browser { | 34 namespace browser { |
| 35 | 35 |
| 36 // Declared in browser_dialogs.h so that others don't need to depend on our .h. | 36 // Declared in browser_dialogs.h so that others don't need to depend on our .h. |
| 37 gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, | 37 gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, |
| 38 Profile* profile, | 38 Profile* profile, |
| 39 Browser* browser, | 39 Browser* browser, |
| 40 WebDialogDelegate* delegate) { | 40 web_dialogs::WebDialogDelegate* delegate) { |
| 41 views::Widget* widget = views::Widget::CreateWindowWithParent( | 41 views::Widget* widget = views::Widget::CreateWindowWithParent( |
| 42 new WebDialogView(profile, browser, delegate), parent); | 42 new WebDialogView(profile, browser, delegate), parent); |
| 43 widget->Show(); | 43 widget->Show(); |
| 44 return widget->GetNativeWindow(); | 44 return widget->GetNativeWindow(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace browser | 47 } // namespace browser |
| 48 | 48 |
| 49 //////////////////////////////////////////////////////////////////////////////// | 49 //////////////////////////////////////////////////////////////////////////////// |
| 50 // WebDialogView, public: | 50 // WebDialogView, public: |
| 51 | 51 |
| 52 WebDialogView::WebDialogView(Profile* profile, | 52 WebDialogView::WebDialogView(Profile* profile, |
| 53 Browser* browser, | 53 Browser* browser, |
| 54 WebDialogDelegate* delegate) | 54 web_dialogs::WebDialogDelegate* delegate) |
| 55 : WebDialogWebContentsDelegate(profile), | 55 : ChromeWebDialogWebContentsDelegate(profile), |
| 56 initialized_(false), | 56 initialized_(false), |
| 57 delegate_(delegate), | 57 delegate_(delegate), |
| 58 dialog_controller_(new WebDialogController(this, profile, browser)), | 58 dialog_controller_(new WebDialogController(this, profile, browser)), |
| 59 web_view_(new views::WebView(profile)) { | 59 web_view_(new views::WebView(profile)) { |
| 60 web_view_->set_allow_accelerators(true); | 60 web_view_->set_allow_accelerators(true); |
| 61 AddChildView(web_view_); | 61 AddChildView(web_view_); |
| 62 SetLayoutManager(new views::FillLayout); | 62 SetLayoutManager(new views::FillLayout); |
| 63 // Pressing the ESC key will close the dialog. | 63 // Pressing the ESC key will close the dialog. |
| 64 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, false, false, false)); | 64 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, false, false, false)); |
| 65 } | 65 } |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 void WebDialogView::InitDialog() { | 303 void WebDialogView::InitDialog() { |
| 304 content::WebContents* web_contents = web_view_->GetWebContents(); | 304 content::WebContents* web_contents = web_view_->GetWebContents(); |
| 305 if (web_contents->GetDelegate() == this) | 305 if (web_contents->GetDelegate() == this) |
| 306 return; | 306 return; |
| 307 | 307 |
| 308 web_contents->SetDelegate(this); | 308 web_contents->SetDelegate(this); |
| 309 | 309 |
| 310 // Set the delegate. This must be done before loading the page. See | 310 // Set the delegate. This must be done before loading the page. See |
| 311 // the comment above WebDialogUI in its header file for why. | 311 // the comment above WebDialogUI in its header file for why. |
| 312 WebDialogUI::GetPropertyAccessor().SetProperty( | 312 web_dialogs::WebDialogUI::GetPropertyAccessor().SetProperty( |
| 313 web_contents->GetPropertyBag(), this); | 313 web_contents->GetPropertyBag(), this); |
| 314 tab_watcher_.reset(new TabRenderWatcher(web_contents, this)); | 314 tab_watcher_.reset(new TabRenderWatcher(web_contents, this)); |
| 315 | 315 |
| 316 if (delegate_) { | 316 if (delegate_) { |
| 317 gfx::Size out; | 317 gfx::Size out; |
| 318 delegate_->GetDialogSize(&out); | 318 delegate_->GetDialogSize(&out); |
| 319 if (!out.IsEmpty() && GetWidget()) | 319 if (!out.IsEmpty() && GetWidget()) |
| 320 GetWidget()->CenterWindow(out); | 320 GetWidget()->CenterWindow(out); |
| 321 } | 321 } |
| 322 | 322 |
| 323 web_view_->LoadInitialURL(GetDialogContentURL()); | 323 web_view_->LoadInitialURL(GetDialogContentURL()); |
| 324 } | 324 } |
| OLD | NEW |