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

Side by Side Diff: chrome/browser/ui/views/tab_contents/tab_contents_container_views.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: Merged with current head Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_ 5 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h"
6 #define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_
7 #pragma once
8 6
7 #include "chrome/browser/renderer_host/render_view_host.h"
8 #include "chrome/browser/renderer_host/render_widget_host_view.h"
9 #include "chrome/browser/tab_contents/interstitial_page.h"
10 #include "chrome/browser/tab_contents/tab_contents.h"
11 #include "chrome/browser/ui/view_ids.h"
12 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk .h"
9 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h" 13 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h"
10 #include "chrome/common/notification_observer.h" 14 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
11 #include "chrome/common/notification_registrar.h" 15 #include "chrome/common/notification_details.h"
12 #include "views/view.h" 16 #include "chrome/common/notification_source.h"
17 #include "views/fill_layout.h"
13 18
14 class NativeTabContentsContainer; 19 // Some of this class is implemented in tab_contents_container.cc, where
15 class RenderViewHost; 20 // the implementation doesn't vary between a pure views approach and a
16 class RenderWidgetHostView; 21 // native view host approach. See the header file for details.
17 class TabContents;
18 22
19 class TabContentsContainer : public views::View, 23 ////////////////////////////////////////////////////////////////////////////////
20 public NotificationObserver { 24 // TabContentsContainer, public:
21 public:
22 TabContentsContainer();
23 virtual ~TabContentsContainer();
24 25
25 // Changes the TabContents associated with this view. 26 TabContentsContainer::TabContentsContainer()
26 void ChangeTabContents(TabContents* contents); 27 : tab_contents_(NULL) {
28 SetID(VIEW_ID_TAB_CONTAINER);
29 }
27 30
28 View* GetFocusView() { return native_container_->GetView(); } 31 void TabContentsContainer::ChangeTabContents(TabContents* contents) {
32 if (tab_contents_) {
33 views::View *v = static_cast<TabContentsViewViews*>(tab_contents_->view());
34 RemoveChildView(v);
35 tab_contents_->WasHidden();
36 RemoveObservers();
37 }
38 tab_contents_ = contents;
39 // When detaching the last tab of the browser ChangeTabContents is invoked
40 // with NULL. Don't attempt to do anything in that case.
41 if (tab_contents_) {
42 views::View *v = static_cast<TabContentsViewViews*>(contents->view());
43 AddChildView(v);
44 SetLayoutManager(new views::FillLayout());
45 Layout();
46 AddObservers();
47 }
48 }
29 49
30 // Accessor for |tab_contents_|. 50 void TabContentsContainer::TabContentsFocused(TabContents* tab_contents) {
31 TabContents* tab_contents() const { return tab_contents_; } 51 }
32 52
33 // Called by the BrowserView to notify that |tab_contents| got the focus. 53 void TabContentsContainer::SetFastResize(bool fast_resize) {
34 void TabContentsFocused(TabContents* tab_contents); 54 }
35 55
36 // Tells the container to update less frequently during resizing operations 56 void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host,
37 // so performance is better. 57 RenderViewHost* new_host) {
38 void SetFastResize(bool fast_resize); 58 NOTIMPLEMENTED(); // TODO(anicolao)
39 59 }
40 // Updates the current reserved rect in view coordinates where contents
41 // should not be rendered to draw the resize corner, sidebar mini tabs etc.
42 void SetReservedContentsRect(const gfx::Rect& reserved_rect);
43
44 // Overridden from NotificationObserver:
45 virtual void Observe(NotificationType type,
46 const NotificationSource& source,
47 const NotificationDetails& details);
48
49 // Overridden from views::View:
50 virtual void Layout();
51 virtual AccessibilityTypes::Role GetAccessibleRole();
52
53 protected:
54 // Overridden from views::View:
55 virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
56 views::View* child);
57
58 private:
59 // Add or remove observers for events that we care about.
60 void AddObservers();
61 void RemoveObservers();
62
63 // Called when the RenderViewHost of the hosted TabContents has changed, e.g.
64 // to show an interstitial page.
65 void RenderViewHostChanged(RenderViewHost* old_host,
66 RenderViewHost* new_host);
67
68 // Called when a TabContents is destroyed. This gives us a chance to clean
69 // up our internal state if the TabContents is somehow destroyed before we
70 // get notified.
71 void TabContentsDestroyed(TabContents* contents);
72
73 // Called when the RenderWidgetHostView of the hosted TabContents has changed.
74 void RenderWidgetHostViewChanged(RenderWidgetHostView* new_view);
75
76 // An instance of a NativeTabContentsContainer object that holds the native
77 // view handle associated with the attached TabContents.
78 NativeTabContentsContainer* native_container_;
79
80 // The attached TabContents.
81 TabContents* tab_contents_;
82
83 // Handles registering for our notifications.
84 NotificationRegistrar registrar_;
85
86 // The current reserved rect in view coordinates where contents should not be
87 // rendered to draw the resize corner, sidebar mini tabs etc.
88 // Cached here to update ever changing renderers.
89 gfx::Rect cached_reserved_rect_;
90
91 DISALLOW_COPY_AND_ASSIGN(TabContentsContainer);
92 };
93
94 #endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tab_contents/tab_contents_container_views.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698