Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1233)

Unified Diff: chrome/browser/ui/views/html_dialog_view.cc

Issue 10171006: Convert more users away from DOMView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/html_dialog_view.h ('k') | chrome/browser/ui/views/html_dialog_view_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/html_dialog_view.cc
===================================================================
--- chrome/browser/ui/views/html_dialog_view.cc (revision 133597)
+++ 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,16 +58,25 @@
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)) {
+ web_view_->set_allow_accelerators(true);
+ 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() {
}
+content::WebContents* HtmlDialogView::web_contents() {
+ return web_view_->web_contents();
+}
+
////////////////////////////////////////////////////////////////////////////////
// HtmlDialogView, views::View implementation:
@@ -82,13 +94,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 +137,7 @@
}
views::View* HtmlDialogView::GetInitiallyFocusedView() {
- return this;
+ return web_view_;
}
bool HtmlDialogView::ShouldShowWindowTitle() const {
@@ -281,13 +291,26 @@
}
////////////////////////////////////////////////////////////////////////////////
-// HtmlDialogView:
+// HtmlDialogView, TabRenderWatcher::Delegate implementation:
+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);
+ content::WebContents* web_contents = web_view_->GetWebContents();
+ if (web_contents->GetDelegate() == this)
+ return;
- WebContents* web_contents = dom_contents_->web_contents();
web_contents->SetDelegate(this);
// Set the delegate. This must be done before loading the page. See
@@ -303,20 +326,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();
-}
« no previous file with comments | « chrome/browser/ui/views/html_dialog_view.h ('k') | chrome/browser/ui/views/html_dialog_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698