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

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

Issue 5785001: A NativeViewHostViews class for embedding views inside NativeHostView instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed the location of the cast as per discussion with ben Created 10 years 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
Index: chrome/browser/ui/views/dom_view.cc
diff --git a/chrome/browser/ui/views/dom_view.cc b/chrome/browser/ui/views/dom_view.cc
index a4cc19af2b80485a088d903a03d5cf589cc5eb6a..350714549f0f6585d1b43cc5124070a7070846b1 100644
--- a/chrome/browser/ui/views/dom_view.cc
+++ b/chrome/browser/ui/views/dom_view.cc
@@ -8,13 +8,17 @@
#include "ipc/ipc_message.h"
#include "views/focus/focus_manager.h"
+#if defined(TOUCH_UI)
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
+#endif
+
DOMView::DOMView() : tab_contents_(NULL), initialized_(false) {
SetFocusable(true);
}
DOMView::~DOMView() {
if (native_view())
- Detach();
+ DetachTabContents();
}
bool DOMView::Init(Profile* profile, SiteInstance* instance) {
@@ -25,7 +29,7 @@ bool DOMView::Init(Profile* profile, SiteInstance* instance) {
tab_contents_.reset(CreateTabContents(profile, instance));
// Attach the native_view now if the view is already added to Widget.
if (GetWidget())
- Attach(tab_contents_->GetNativeView());
+ AttachTabContents();
return true;
}
@@ -56,7 +60,19 @@ void DOMView::ViewHierarchyChanged(bool is_add, views::View* parent,
// the native view has not been attached yet and tab_contents_ exists.
views::NativeViewHost::ViewHierarchyChanged(is_add, parent, child);
if (is_add && GetWidget() && !native_view() && tab_contents_.get())
- Attach(tab_contents_->GetNativeView());
+ AttachTabContents();
else if (!is_add && child == this && native_view())
- Detach();
+ DetachTabContents();
+}
+
+void DOMView::AttachTabContents() {
+#if defined(TOUCH_UI)
+ AttachToView(static_cast<TabContentsViewViews*>(tab_contents_->GetTabContentsView()));
+#else
+ Attach(tab_contents_->GetNativeView());
+#endif
+}
+
+void DOMView::DetachTabContents() {
+ Detach();
Ben Goodger (Google) 2010/12/15 18:32:28 Looks like you might actually not need this method
Alex Nicolaou 2010/12/16 22:34:48 I prefer the symmetry but done.
}

Powered by Google App Engine
This is Rietveld 408576698