1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" 6 7 #include "chrome/browser/ui/view_ids.h" 8 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h" 9 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.h" 10 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h" 11 #include "content/browser/renderer_host/render_view_host.h" 12 #include "content/browser/renderer_host/render_widget_host_view.h" 13 #include "content/browser/tab_contents/interstitial_page.h" 14 #include "content/browser/tab_contents/tab_contents.h" 15 #include "content/common/notification_details.h" 16 #include "content/common/notification_source.h" 17 #include "views/layout/fill_layout.h" 18 19 // Some of this class is implemented in tab_contents_container.cc, where 20 // the implementation doesn't vary between a pure views approach and a 21 // native view host approach. See the header file for details. 22 23 //////////////////////////////////////////////////////////////////////////////// 24 // TabContentsContainer, public: 25 TabContentsContainer()26TabContentsContainer::TabContentsContainer() 27 : tab_contents_(NULL) { 28 SetID(VIEW_ID_TAB_CONTAINER); 29 } 30 SetReservedContentsRect(const gfx::Rect & reserved_rect)31void TabContentsContainer::SetReservedContentsRect( 32 const gfx::Rect& reserved_rect) { 33 cached_reserved_rect_ = reserved_rect; 34 // TODO(anicolao): find out what this is supposed to be used for and ensure 35 // it's OK for touch. 36 } 37 ChangeTabContents(TabContents * contents)38void TabContentsContainer::ChangeTabContents(TabContents* contents) { 39 if (tab_contents_) { 40 views::View *v = static_cast<TabContentsViewTouch*>(tab_contents_->view()); 41 RemoveChildView(v); 42 tab_contents_->WasHidden(); 43 RemoveObservers(); 44 } 45 tab_contents_ = contents; 46 // When detaching the last tab of the browser ChangeTabContents is invoked 47 // with NULL. Don't attempt to do anything in that case. 48 if (tab_contents_) { 49 views::View *v = static_cast<TabContentsViewTouch*>(contents->view()); 50 AddChildView(v); 51 SetLayoutManager(new views::FillLayout()); 52 Layout(); 53 AddObservers(); 54 } 55 } 56 TabContentsFocused(TabContents * tab_contents)57void TabContentsContainer::TabContentsFocused(TabContents* tab_contents) { 58 } 59 SetFastResize(bool fast_resize)60void TabContentsContainer::SetFastResize(bool fast_resize) { 61 } 62 RenderViewHostChanged(RenderViewHost * old_host,RenderViewHost * new_host)63void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host, 64 RenderViewHost* new_host) { 65 NOTIMPLEMENTED(); // TODO(anicolao) 66 } 67