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

Unified Diff: chrome/browser/ui/views/tab_contents/tab_contents_container.cc

Issue 6024007: First cut at creating a refactored version of tab_contents_views. This is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated the diff using -M1% -B1% to capture the refactoring better Created 9 years, 12 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
Index: chrome/browser/ui/views/tab_contents/tab_contents_container.cc
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_container.cc b/chrome/browser/ui/views/tab_contents/tab_contents_container.cc
index 47ed229eb4bd11a8a17b01040e0e08aec0d04c33..ec2fc68ae1a1e62d5ab391b82bc785f710b857cd 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_container.cc
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.cc
@@ -1,3 +1,6 @@
+// For reasons that are as yet unclear to me, all of this "common" code
sky 2011/01/05 16:43:03 Is this comment right?
Ben Goodger (Google) 2011/01/05 17:14:44 I don't believe it is - the TAB_CONTENTS_DESTROYED
Alex Nicolaou 2011/01/06 09:37:17 No sorry this is construction dust from a intermed
+// is dead code. Left here for cleanup post-refactoring.
Ben Goodger (Google) 2011/01/05 17:14:44 Also, comments like this should go below the licen
Alex Nicolaou 2011/01/06 09:37:17 Sorry this comment will get deleted it's wrong.
+
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,75 +16,15 @@
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_source.h"
-#if defined(TOUCH_UI)
-#include "chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.h"
-#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
-#include "views/border.h"
-#include "views/fill_layout.h"
-#endif
////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, public:
-TabContentsContainer::TabContentsContainer()
- : native_container_(NULL),
- tab_contents_(NULL),
- reserved_area_delegate_(NULL) {
- SetID(VIEW_ID_TAB_CONTAINER);
-}
-
TabContentsContainer::~TabContentsContainer() {
if (tab_contents_)
RemoveObservers();
}
-void TabContentsContainer::ChangeTabContents(TabContents* contents) {
- if (tab_contents_) {
-#if !defined(TOUCH_UI)
- native_container_->DetachContents(tab_contents_);
-#else
- views::View *v = static_cast<TabContentsViewViews*>(tab_contents_->view());
- RemoveChildView(v);
-#endif
- tab_contents_->WasHidden();
- RemoveObservers();
- }
-#if !defined(TOUCH_UI)
- TabContents* old_contents = tab_contents_;
-#endif
- tab_contents_ = contents;
- // When detaching the last tab of the browser ChangeTabContents is invoked
- // with NULL. Don't attempt to do anything in that case.
- if (tab_contents_) {
-#if defined(TOUCH_UI)
- views::View *v = static_cast<TabContentsViewViews*>(contents->view());
- // Guard against re-adding ourselves, which happens because the NULL
- // value is ignored by the pre-existing if() above.
- if (v->GetParent() != this) {
- AddChildView(v);
- SetLayoutManager(new views::FillLayout());
- Layout();
- }
-#else
- RenderWidgetHostViewChanged(
- old_contents ? old_contents->GetRenderWidgetHostView() : NULL,
- tab_contents_->GetRenderWidgetHostView());
- native_container_->AttachContents(tab_contents_);
-#endif
- AddObservers();
- }
-}
-
-void TabContentsContainer::TabContentsFocused(TabContents* tab_contents) {
- if (native_container_)
- native_container_->TabContentsFocused(tab_contents);
-}
-
-void TabContentsContainer::SetFastResize(bool fast_resize) {
- if (native_container_)
- native_container_->SetFastResize(fast_resize);
-}
-
////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, NotificationObserver implementation:
@@ -103,36 +46,10 @@ void TabContentsContainer::Observe(NotificationType type,
////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, View overrides:
-void TabContentsContainer::Layout() {
-#if defined(TOUCH_UI)
- views::View::Layout();
-#else
- if (native_container_) {
- if (reserved_area_delegate_)
- reserved_area_delegate_->UpdateReservedContentsRect(this);
- native_container_->GetView()->SetBounds(0, 0, width(), height());
- native_container_->GetView()->Layout();
- }
-#endif
-}
-
AccessibilityTypes::Role TabContentsContainer::GetAccessibleRole() {
return AccessibilityTypes::ROLE_WINDOW;
}
-void TabContentsContainer::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
-#if defined(TOUCH_UI)
- views::View::ViewHierarchyChanged(is_add, parent, child);
-#else
- if (is_add && child == this) {
- native_container_ = NativeTabContentsContainer::CreateNativeContainer(this);
- AddChildView(native_container_->GetView());
- }
-#endif
-}
-
////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, private:
@@ -153,19 +70,6 @@ void TabContentsContainer::RemoveObservers() {
registrar_.RemoveAll();
}
-void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host,
- RenderViewHost* new_host) {
-#if defined(TOUCH_UI)
- NOTIMPLEMENTED(); // TODO(anicolao)
-#else
- if (new_host) {
- RenderWidgetHostViewChanged(
- old_host ? old_host->view() : NULL, new_host->view());
- }
- native_container_->RenderViewHostChanged(old_host, new_host);
-#endif
-}
-
void TabContentsContainer::TabContentsDestroyed(TabContents* contents) {
// Sometimes, a TabContents is destroyed before we know about it. This allows
// us to clean up our state in case this happens.

Powered by Google App Engine
This is Rietveld 408576698