Chromium Code Reviews| Index: chrome/browser/ui/views/html_dialog_view.cc |
| =================================================================== |
| --- chrome/browser/ui/views/html_dialog_view.cc (revision 133279) |
| +++ chrome/browser/ui/views/html_dialog_view.cc (working copy) |
| @@ -6,6 +6,7 @@ |
| #include <vector> |
| +#include "base/property_bag.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser_dialogs.h" |
| @@ -16,7 +17,9 @@ |
| #include "content/public/browser/notification_types.h" |
| #include "content/public/browser/web_contents.h" |
| #include "ui/base/keycodes/keyboard_codes.h" |
| +#include "ui/views/controls/webview/webview.h" |
| #include "ui/views/events/event.h" |
| +#include "ui/views/layout/fill_layout.h" |
| #include "ui/views/widget/root_view.h" |
| #include "ui/views/widget/widget.h" |
| @@ -36,11 +39,11 @@ |
| Browser* browser, |
| HtmlDialogUIDelegate* delegate, |
| DialogStyle style) { |
| - HtmlDialogView* html_view = new HtmlDialogView(profile, browser, delegate); |
| - views::Widget::CreateWindowWithParent(html_view, parent); |
| - html_view->InitDialog(); |
| - html_view->GetWidget()->Show(); |
| - return html_view->GetWidget()->GetNativeWindow(); |
| + views::Widget* widget = views::Widget::CreateWindowWithParent( |
| + new HtmlDialogView(profile, browser, delegate), |
| + parent); |
| + widget->Show(); |
| + return widget->GetNativeWindow(); |
| } |
| void CloseHtmlDialog(gfx::NativeWindow window) { |
| @@ -55,11 +58,15 @@ |
| HtmlDialogView::HtmlDialogView(Profile* profile, |
| Browser* browser, |
| HtmlDialogUIDelegate* delegate) |
| - : DOMView(), |
| - HtmlDialogTabContentsDelegate(profile), |
| + : HtmlDialogTabContentsDelegate(profile), |
| initialized_(false), |
| delegate_(delegate), |
| - dialog_controller_(new HtmlDialogController(this, profile, browser)) { |
| + dialog_controller_(new HtmlDialogController(this, profile, browser)), |
| + web_view_(new views::WebView(profile)) { |
| + AddChildView(web_view_); |
| + SetLayoutManager(new views::FillLayout); |
| + // Pressing the ESC key will close the dialog. |
| + AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, false, false, false)); |
| } |
| HtmlDialogView::~HtmlDialogView() { |
| @@ -82,13 +89,11 @@ |
| return true; |
| } |
| -void HtmlDialogView::ViewHierarchyChanged( |
| - bool is_add, View* parent, View* child) { |
| - DOMView::ViewHierarchyChanged(is_add, parent, child); |
| - if (is_add && GetWidget() && !initialized_) { |
| - initialized_ = true; |
| - RegisterDialogAccelerators(); |
| - } |
| +void HtmlDialogView::ViewHierarchyChanged(bool is_add, |
| + views::View* parent, |
| + views::View* child) { |
| + if (is_add && GetWidget()) |
| + InitDialog(); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -127,7 +132,7 @@ |
| } |
| views::View* HtmlDialogView::GetInitiallyFocusedView() { |
| - return this; |
| + return web_view_; |
| } |
| bool HtmlDialogView::ShouldShowWindowTitle() const { |
| @@ -281,13 +286,29 @@ |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// HtmlDialogView: |
| +// HtmlDialogView, protected: |
| + |
| +void HtmlDialogView::OnRenderHostCreated(content::RenderViewHost* host) { |
| +} |
| + |
| +void HtmlDialogView::OnTabMainFrameLoaded() { |
| +} |
| + |
| +void HtmlDialogView::OnTabMainFrameRender() { |
| + tab_watcher_.reset(); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// HtmlDialogView, private: |
| + |
| void HtmlDialogView::InitDialog() { |
| - // Now Init the DOMView. This view runs in its own process to render the html. |
| - DOMView::Init(profile(), NULL); |
| + static bool initialized = false; |
|
sky
2012/04/20 22:59:37
How come initialized is static?
Ben Goodger (Google)
2012/04/21 04:49:28
so I can only init once.
sky
2012/04/21 16:13:31
Doesn't this need to set up a bunch of state that
|
| + if (initialized) |
| + return; |
| + initialized = true; |
| - WebContents* web_contents = dom_contents_->web_contents(); |
| + content::WebContents* web_contents = web_view_->GetWebContents(); |
| web_contents->SetDelegate(this); |
| // Set the delegate. This must be done before loading the page. See |
| @@ -303,20 +324,5 @@ |
| GetWidget()->CenterWindow(out); |
| } |
| - DOMView::LoadURL(GetDialogContentURL()); |
| + web_view_->LoadInitialURL(GetDialogContentURL()); |
| } |
| - |
| -void HtmlDialogView::RegisterDialogAccelerators() { |
| - // Pressing the ESC key will close the dialog. |
| - AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, false, false, false)); |
| -} |
| - |
| -void HtmlDialogView::OnRenderHostCreated(content::RenderViewHost* host) { |
| -} |
| - |
| -void HtmlDialogView::OnTabMainFrameLoaded() { |
| -} |
| - |
| -void HtmlDialogView::OnTabMainFrameRender() { |
| - tab_watcher_.reset(); |
| -} |