| Index: chrome/browser/ui/views/tab_contents/tab_contents_container_native.cc
|
| diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_container.h b/chrome/browser/ui/views/tab_contents/tab_contents_container_native.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_native.cc
|
| index 1ba30ed6d712c1526f770e4b3cf796c1b0d1d3c0..fa75886c78851c0d12562d49e513c1942ce286cf 100644
|
| --- a/chrome/browser/ui/views/tab_contents/tab_contents_container.h
|
| +++ b/chrome/browser/ui/views/tab_contents/tab_contents_container_native.cc
|
| @@ -1,94 +1,80 @@
|
| -// 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.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/common/notification_details.h"
|
| +#include "chrome/common/notification_source.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()
|
| + : native_container_(NULL),
|
| + tab_contents_(NULL) {
|
| + SetID(VIEW_ID_TAB_CONTAINER);
|
| +}
|
| +
|
| +void TabContentsContainer::ChangeTabContents(TabContents* contents) {
|
| + if (tab_contents_) {
|
| + native_container_->DetachContents(tab_contents_);
|
| + 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_) {
|
| + RenderWidgetHostViewChanged(tab_contents_->GetRenderWidgetHostView());
|
| + native_container_->AttachContents(tab_contents_);
|
| + AddObservers();
|
| + }
|
| +}
|
| +
|
| +void TabContentsContainer::TabContentsFocused(TabContents* tab_contents) {
|
| + native_container_->TabContentsFocused(tab_contents);
|
| +}
|
| +
|
| +void TabContentsContainer::SetFastResize(bool fast_resize) {
|
| + native_container_->SetFastResize(fast_resize);
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// TabContentsContainer, View overrides:
|
| +
|
| +void TabContentsContainer::Layout() {
|
| + if (native_container_) {
|
| + native_container_->GetView()->SetBounds(0, 0, width(), height());
|
| + native_container_->GetView()->Layout();
|
| + }
|
| +}
|
| +
|
| +void TabContentsContainer::ViewHierarchyChanged(bool is_add,
|
| + views::View* parent,
|
| + views::View* child) {
|
| + if (is_add && child == this) {
|
| + native_container_ = NativeTabContentsContainer::CreateNativeContainer(this);
|
| + AddChildView(native_container_->GetView());
|
| + }
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// TabContentsContainer, private:
|
| +
|
| +void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host,
|
| + RenderViewHost* new_host) {
|
| + if (new_host)
|
| + RenderWidgetHostViewChanged(new_host->view());
|
| + native_container_->RenderViewHostChanged(old_host, new_host);
|
| +}
|
|
|