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

Side by Side Diff: chrome/browser/ui/views/tab_contents/tab_contents_container.cc

Issue 3547008: Handle resize corner layout entirely in the platform BrowserWindow*/BrowserView* code... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 #include "chrome/browser/views/tab_contents/tab_contents_container.h" 5 #include "chrome/browser/views/tab_contents/tab_contents_container.h"
6 6
7 #include "chrome/browser/renderer_host/render_view_host.h"
8 #include "chrome/browser/renderer_host/render_widget_host_view.h"
7 #include "chrome/browser/tab_contents/interstitial_page.h" 9 #include "chrome/browser/tab_contents/interstitial_page.h"
8 #include "chrome/browser/tab_contents/tab_contents.h" 10 #include "chrome/browser/tab_contents/tab_contents.h"
9 #include "chrome/browser/view_ids.h" 11 #include "chrome/browser/view_ids.h"
10 #include "chrome/browser/views/tab_contents/native_tab_contents_container.h" 12 #include "chrome/browser/views/tab_contents/native_tab_contents_container.h"
11 #include "chrome/common/notification_service.h" 13 #include "chrome/common/notification_service.h"
12 14
13 //////////////////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////////////////
14 // TabContentsContainer, public: 16 // TabContentsContainer, public:
15 17
16 TabContentsContainer::TabContentsContainer() 18 TabContentsContainer::TabContentsContainer()
17 : native_container_(NULL), 19 : native_container_(NULL),
18 tab_contents_(NULL) { 20 tab_contents_(NULL),
21 reserved_area_delegate_(NULL) {
19 SetID(VIEW_ID_TAB_CONTAINER); 22 SetID(VIEW_ID_TAB_CONTAINER);
20 } 23 }
21 24
22 TabContentsContainer::~TabContentsContainer() { 25 TabContentsContainer::~TabContentsContainer() {
23 if (tab_contents_) 26 if (tab_contents_)
24 RemoveObservers(); 27 RemoveObservers();
25 } 28 }
26 29
27 void TabContentsContainer::ChangeTabContents(TabContents* contents) { 30 void TabContentsContainer::ChangeTabContents(TabContents* contents) {
28 if (tab_contents_) { 31 if (tab_contents_) {
29 native_container_->DetachContents(tab_contents_); 32 native_container_->DetachContents(tab_contents_);
30 tab_contents_->WasHidden(); 33 tab_contents_->WasHidden();
31 RemoveObservers(); 34 RemoveObservers();
32 } 35 }
36 TabContents* old_contents = tab_contents_;
33 tab_contents_ = contents; 37 tab_contents_ = contents;
34 // When detaching the last tab of the browser ChangeTabContents is invoked 38 // When detaching the last tab of the browser ChangeTabContents is invoked
35 // with NULL. Don't attempt to do anything in that case. 39 // with NULL. Don't attempt to do anything in that case.
36 if (tab_contents_) { 40 if (tab_contents_) {
41 RenderWidgetHostViewChanged(
42 old_contents ? old_contents->GetRenderWidgetHostView() : NULL,
43 tab_contents_->GetRenderWidgetHostView());
37 native_container_->AttachContents(tab_contents_); 44 native_container_->AttachContents(tab_contents_);
38 AddObservers(); 45 AddObservers();
39 } 46 }
40 } 47 }
41 48
42 void TabContentsContainer::TabContentsFocused(TabContents* tab_contents) { 49 void TabContentsContainer::TabContentsFocused(TabContents* tab_contents) {
43 native_container_->TabContentsFocused(tab_contents); 50 native_container_->TabContentsFocused(tab_contents);
44 } 51 }
45 52
46 void TabContentsContainer::SetFastResize(bool fast_resize) { 53 void TabContentsContainer::SetFastResize(bool fast_resize) {
(...skipping 16 matching lines...) Expand all
63 } else { 70 } else {
64 NOTREACHED(); 71 NOTREACHED();
65 } 72 }
66 } 73 }
67 74
68 //////////////////////////////////////////////////////////////////////////////// 75 ////////////////////////////////////////////////////////////////////////////////
69 // TabContentsContainer, View overrides: 76 // TabContentsContainer, View overrides:
70 77
71 void TabContentsContainer::Layout() { 78 void TabContentsContainer::Layout() {
72 if (native_container_) { 79 if (native_container_) {
80 if (reserved_area_delegate_)
81 reserved_area_delegate_->UpdateReservedContentsRect(this);
73 native_container_->GetView()->SetBounds(0, 0, width(), height()); 82 native_container_->GetView()->SetBounds(0, 0, width(), height());
74 native_container_->GetView()->Layout(); 83 native_container_->GetView()->Layout();
75 } 84 }
76 } 85 }
77 86
78 AccessibilityTypes::Role TabContentsContainer::GetAccessibleRole() { 87 AccessibilityTypes::Role TabContentsContainer::GetAccessibleRole() {
79 return AccessibilityTypes::ROLE_WINDOW; 88 return AccessibilityTypes::ROLE_WINDOW;
80 } 89 }
81 90
82 void TabContentsContainer::ViewHierarchyChanged(bool is_add, 91 void TabContentsContainer::ViewHierarchyChanged(bool is_add,
(...skipping 20 matching lines...) Expand all
103 NotificationType::TAB_CONTENTS_DESTROYED, 112 NotificationType::TAB_CONTENTS_DESTROYED,
104 Source<TabContents>(tab_contents_)); 113 Source<TabContents>(tab_contents_));
105 } 114 }
106 115
107 void TabContentsContainer::RemoveObservers() { 116 void TabContentsContainer::RemoveObservers() {
108 registrar_.RemoveAll(); 117 registrar_.RemoveAll();
109 } 118 }
110 119
111 void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host, 120 void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host,
112 RenderViewHost* new_host) { 121 RenderViewHost* new_host) {
122 if (new_host) {
123 RenderWidgetHostViewChanged(
124 old_host ? old_host->view() : NULL, new_host->view());
125 }
113 native_container_->RenderViewHostChanged(old_host, new_host); 126 native_container_->RenderViewHostChanged(old_host, new_host);
114 } 127 }
115 128
116 void TabContentsContainer::TabContentsDestroyed(TabContents* contents) { 129 void TabContentsContainer::TabContentsDestroyed(TabContents* contents) {
117 // Sometimes, a TabContents is destroyed before we know about it. This allows 130 // Sometimes, a TabContents is destroyed before we know about it. This allows
118 // us to clean up our state in case this happens. 131 // us to clean up our state in case this happens.
119 DCHECK(contents == tab_contents_); 132 DCHECK(contents == tab_contents_);
120 ChangeTabContents(NULL); 133 ChangeTabContents(NULL);
121 } 134 }
135
136 void TabContentsContainer::RenderWidgetHostViewChanged(
137 RenderWidgetHostView* old_view, RenderWidgetHostView* new_view) {
138 // Carry over the reserved rect, if possible.
139 if (old_view && new_view) {
140 new_view->set_reserved_contents_rect(old_view->reserved_contents_rect());
141 } else {
142 if (reserved_area_delegate_)
143 reserved_area_delegate_->UpdateReservedContentsRect(this);
144 }
145 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tab_contents/tab_contents_container.h ('k') | chrome/common/render_messages_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698