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

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: Updated the diff using -M1% -B1% to capture the refactoring better 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) 2010 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/views/tab_contents/tab_contents_container.h"
6 #define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_
7 #pragma once
8 6
9 #include "chrome/browser/views/tab_contents/native_tab_contents_container.h" 7 #include "chrome/browser/renderer_host/render_view_host.h"
10 #include "chrome/common/notification_observer.h" 8 #include "chrome/browser/renderer_host/render_widget_host_view.h"
11 #include "chrome/common/notification_registrar.h" 9 #include "chrome/browser/tab_contents/interstitial_page.h"
12 #include "views/view.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"
13 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h"
14 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
15 #include "chrome/common/notification_details.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 // Interface to request the reserved contents area updates.
23 class ReservedAreaDelegate {
24 public:
25 // Notifies that |source|'s reserved contents area should be updated.
26 // Reserved contents area is a rect in tab contents view coordinates where
27 // contents should not be rendered (to display the resize corner, sidebar
28 // mini tabs or any other UI elements overlaying this container).
29 virtual void UpdateReservedContentsRect(
30 const TabContentsContainer* source) = 0;
31 protected:
32 virtual ~ReservedAreaDelegate() {}
33 };
34 25
35 TabContentsContainer(); 26 TabContentsContainer::TabContentsContainer()
36 virtual ~TabContentsContainer(); 27 : tab_contents_(NULL),
28 reserved_area_delegate_(NULL) {
29 SetID(VIEW_ID_TAB_CONTAINER);
30 }
37 31
38 // Changes the TabContents associated with this view. 32 void TabContentsContainer::ChangeTabContents(TabContents* contents) {
39 void ChangeTabContents(TabContents* contents); 33 if (tab_contents_) {
34 views::View *v = static_cast<TabContentsViewViews*>(tab_contents_->view());
35 RemoveChildView(v);
36 tab_contents_->WasHidden();
37 RemoveObservers();
38 }
39 tab_contents_ = contents;
40 // When detaching the last tab of the browser ChangeTabContents is invoked
41 // with NULL. Don't attempt to do anything in that case.
42 if (tab_contents_) {
43 views::View *v = static_cast<TabContentsViewViews*>(contents->view());
44 AddChildView(v);
45 SetLayoutManager(new views::FillLayout());
46 Layout();
47 AddObservers();
48 }
49 }
40 50
41 View* GetFocusView() { return native_container_->GetView(); } 51 void TabContentsContainer::TabContentsFocused(TabContents* tab_contents) {
52 }
42 53
43 // Accessor for |tab_contents_|. 54 void TabContentsContainer::SetFastResize(bool fast_resize) {
44 TabContents* tab_contents() const { return tab_contents_; } 55 }
45 56
46 // Called by the BrowserView to notify that |tab_contents| got the focus. 57 void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host,
47 void TabContentsFocused(TabContents* tab_contents); 58 RenderViewHost* new_host) {
48 59 NOTIMPLEMENTED(); // TODO(anicolao)
49 // Tells the container to update less frequently during resizing operations 60 }
50 // so performance is better.
51 void SetFastResize(bool fast_resize);
52
53 void set_reserved_area_delegate(ReservedAreaDelegate* delegate) {
54 reserved_area_delegate_ = delegate;
55 }
56
57 // Overridden from NotificationObserver:
58 virtual void Observe(NotificationType type,
59 const NotificationSource& source,
60 const NotificationDetails& details);
61
62 // Overridden from views::View:
63 virtual void Layout();
64 virtual AccessibilityTypes::Role GetAccessibleRole();
65
66 protected:
67 // Overridden from views::View:
68 virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
69 views::View* child);
70
71 private:
72 // Add or remove observers for events that we care about.
73 void AddObservers();
74 void RemoveObservers();
75
76 // Called when the RenderViewHost of the hosted TabContents has changed, e.g.
77 // to show an interstitial page.
78 void RenderViewHostChanged(RenderViewHost* old_host,
79 RenderViewHost* new_host);
80
81 // Called when a TabContents is destroyed. This gives us a chance to clean
82 // up our internal state if the TabContents is somehow destroyed before we
83 // get notified.
84 void TabContentsDestroyed(TabContents* contents);
85
86 // Called when the RenderWidgetHostView of the hosted TabContents has changed.
87 void RenderWidgetHostViewChanged(RenderWidgetHostView* old_view,
88 RenderWidgetHostView* new_view);
89
90 // An instance of a NativeTabContentsContainer object that holds the native
91 // view handle associated with the attached TabContents.
92 NativeTabContentsContainer* native_container_;
93
94 // The attached TabContents.
95 TabContents* tab_contents_;
96
97 // Handles registering for our notifications.
98 NotificationRegistrar registrar_;
99
100 // Delegate for enquiring reserved contents area. Not owned by us.
101 ReservedAreaDelegate* reserved_area_delegate_;
102
103 DISALLOW_COPY_AND_ASSIGN(TabContentsContainer);
104 };
105
106 #endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698