Index: chrome/browser/ui/views/tab_contents/tab_contents_container_views.cc |
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_container.h b/chrome/browser/ui/views/tab_contents/tab_contents_container_views.cc |
similarity index 5% |
copy from chrome/browser/ui/views/tab_contents/tab_contents_container.h |
copy to chrome/browser/ui/views/tab_contents/tab_contents_container_views.cc |
index 1ba30ed6d712c1526f770e4b3cf796c1b0d1d3c0..5ff8a5dac2fed2caa445721a58d652b48ce8893e 100644 |
--- a/chrome/browser/ui/views/tab_contents/tab_contents_container.h |
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_container_views.cc |
@@ -1,94 +1,59 @@ |
-// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// 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. |
-#ifndef CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_ |
-#define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_ |
-#pragma once |
+#include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" |
+#include "chrome/browser/renderer_host/render_view_host.h" |
+#include "chrome/browser/renderer_host/render_widget_host_view.h" |
+#include "chrome/browser/tab_contents/interstitial_page.h" |
+#include "chrome/browser/tab_contents/tab_contents.h" |
+#include "chrome/browser/ui/view_ids.h" |
+#include "chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.h" |
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h" |
-#include "chrome/common/notification_observer.h" |
-#include "chrome/common/notification_registrar.h" |
-#include "views/view.h" |
- |
-class NativeTabContentsContainer; |
-class RenderViewHost; |
-class RenderWidgetHostView; |
-class TabContents; |
- |
-class TabContentsContainer : public views::View, |
- public NotificationObserver { |
- public: |
- TabContentsContainer(); |
- virtual ~TabContentsContainer(); |
- |
- // Changes the TabContents associated with this view. |
- void ChangeTabContents(TabContents* contents); |
- |
- View* GetFocusView() { return native_container_->GetView(); } |
- |
- // Accessor for |tab_contents_|. |
- TabContents* tab_contents() const { return tab_contents_; } |
- |
- // Called by the BrowserView to notify that |tab_contents| got the focus. |
- void TabContentsFocused(TabContents* tab_contents); |
- |
- // Tells the container to update less frequently during resizing operations |
- // so performance is better. |
- void SetFastResize(bool fast_resize); |
- |
- // Updates the current reserved rect in view coordinates where contents |
- // should not be rendered to draw the resize corner, sidebar mini tabs etc. |
- void SetReservedContentsRect(const gfx::Rect& reserved_rect); |
- |
- // Overridden from NotificationObserver: |
- virtual void Observe(NotificationType type, |
- const NotificationSource& source, |
- const NotificationDetails& details); |
- |
- // Overridden from views::View: |
- virtual void Layout(); |
- virtual AccessibilityTypes::Role GetAccessibleRole(); |
- |
- protected: |
- // Overridden from views::View: |
- virtual void ViewHierarchyChanged(bool is_add, views::View* parent, |
- views::View* child); |
- |
- private: |
- // Add or remove observers for events that we care about. |
- void AddObservers(); |
- void RemoveObservers(); |
- |
- // Called when the RenderViewHost of the hosted TabContents has changed, e.g. |
- // to show an interstitial page. |
- void RenderViewHostChanged(RenderViewHost* old_host, |
- RenderViewHost* new_host); |
- |
- // Called when a TabContents is destroyed. This gives us a chance to clean |
- // up our internal state if the TabContents is somehow destroyed before we |
- // get notified. |
- void TabContentsDestroyed(TabContents* contents); |
- |
- // Called when the RenderWidgetHostView of the hosted TabContents has changed. |
- void RenderWidgetHostViewChanged(RenderWidgetHostView* new_view); |
- |
- // An instance of a NativeTabContentsContainer object that holds the native |
- // view handle associated with the attached TabContents. |
- NativeTabContentsContainer* native_container_; |
- |
- // The attached TabContents. |
- TabContents* tab_contents_; |
- |
- // Handles registering for our notifications. |
- NotificationRegistrar registrar_; |
- |
- // The current reserved rect in view coordinates where contents should not be |
- // rendered to draw the resize corner, sidebar mini tabs etc. |
- // Cached here to update ever changing renderers. |
- gfx::Rect cached_reserved_rect_; |
- |
- DISALLOW_COPY_AND_ASSIGN(TabContentsContainer); |
-}; |
- |
-#endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_ |
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" |
+#include "chrome/common/notification_details.h" |
+#include "chrome/common/notification_source.h" |
+#include "views/fill_layout.h" |
+ |
+// Some of this class is implemented in tab_contents_container.cc, where |
+// the implementation doesn't vary between a pure views approach and a |
+// native view host approach. See the header file for details. |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
+// TabContentsContainer, public: |
+ |
+TabContentsContainer::TabContentsContainer() |
+ : tab_contents_(NULL) { |
+ SetID(VIEW_ID_TAB_CONTAINER); |
+} |
+ |
+void TabContentsContainer::ChangeTabContents(TabContents* contents) { |
+ if (tab_contents_) { |
+ views::View *v = static_cast<TabContentsViewViews*>(tab_contents_->view()); |
+ RemoveChildView(v); |
+ tab_contents_->WasHidden(); |
+ RemoveObservers(); |
+ } |
+ 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_) { |
+ views::View *v = static_cast<TabContentsViewViews*>(contents->view()); |
+ AddChildView(v); |
+ SetLayoutManager(new views::FillLayout()); |
+ Layout(); |
+ AddObservers(); |
+ } |
+} |
+ |
+void TabContentsContainer::TabContentsFocused(TabContents* tab_contents) { |
+} |
+ |
+void TabContentsContainer::SetFastResize(bool fast_resize) { |
+} |
+ |
+void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host, |
+ RenderViewHost* new_host) { |
+ NOTIMPLEMENTED(); // TODO(anicolao) |
+} |