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

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

Issue 9265018: Change grow box computation back to a method on BrowserWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 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) 2011 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/ui/views/tab_contents/tab_contents_container.h" 5 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "chrome/browser/ui/view_ids.h" 9 #include "chrome/browser/ui/view_ids.h"
10 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h" 10 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h"
(...skipping 26 matching lines...) Expand all
37 void TabContentsContainer::ChangeWebContents(WebContents* contents) { 37 void TabContentsContainer::ChangeWebContents(WebContents* contents) {
38 if (web_contents_) { 38 if (web_contents_) {
39 native_container_->DetachContents(web_contents_); 39 native_container_->DetachContents(web_contents_);
40 web_contents_->WasHidden(); 40 web_contents_->WasHidden();
41 RemoveObservers(); 41 RemoveObservers();
42 } 42 }
43 web_contents_ = contents; 43 web_contents_ = contents;
44 // When detaching the last tab of the browser ChangeWebContents is invoked 44 // When detaching the last tab of the browser ChangeWebContents is invoked
45 // with NULL. Don't attempt to do anything in that case. 45 // with NULL. Don't attempt to do anything in that case.
46 if (web_contents_) { 46 if (web_contents_) {
47 RenderWidgetHostViewChanged(web_contents_->GetRenderWidgetHostView());
48 native_container_->AttachContents(web_contents_); 47 native_container_->AttachContents(web_contents_);
49 AddObservers(); 48 AddObservers();
50 } 49 }
51 } 50 }
52 51
53 content::WebContents* TabContentsContainer::web_contents() { 52 content::WebContents* TabContentsContainer::web_contents() {
54 return web_contents_; 53 return web_contents_;
55 } 54 }
56 55
57 void TabContentsContainer::WebContentsFocused(WebContents* contents) { 56 void TabContentsContainer::WebContentsFocused(WebContents* contents) {
58 native_container_->WebContentsFocused(contents); 57 native_container_->WebContentsFocused(contents);
59 } 58 }
60 59
61 void TabContentsContainer::SetFastResize(bool fast_resize) { 60 void TabContentsContainer::SetFastResize(bool fast_resize) {
62 native_container_->SetFastResize(fast_resize); 61 native_container_->SetFastResize(fast_resize);
63 } 62 }
64 63
65 void TabContentsContainer::SetReservedContentsRect(
66 const gfx::Rect& reserved_rect) {
67 cached_reserved_rect_ = reserved_rect;
68 if (web_contents_ && web_contents_->GetRenderWidgetHostView()) {
69 web_contents_->GetRenderWidgetHostView()->set_reserved_contents_rect(
70 reserved_rect);
71 }
72 }
73
74 //////////////////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////////////////
75 // TabContentsContainer, content::NotificationObserver implementation: 65 // TabContentsContainer, content::NotificationObserver implementation:
76 66
77 void TabContentsContainer::Observe( 67 void TabContentsContainer::Observe(
78 int type, 68 int type,
79 const content::NotificationSource& source, 69 const content::NotificationSource& source,
80 const content::NotificationDetails& details) { 70 const content::NotificationDetails& details) {
81 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { 71 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
82 std::pair<RenderViewHost*, RenderViewHost*>* switched_details = 72 std::pair<RenderViewHost*, RenderViewHost*>* switched_details =
83 content::Details<std::pair<RenderViewHost*, RenderViewHost*> >( 73 content::Details<std::pair<RenderViewHost*, RenderViewHost*> >(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 170 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
181 content::Source<WebContents>(web_contents_)); 171 content::Source<WebContents>(web_contents_));
182 } 172 }
183 173
184 void TabContentsContainer::RemoveObservers() { 174 void TabContentsContainer::RemoveObservers() {
185 registrar_.RemoveAll(); 175 registrar_.RemoveAll();
186 } 176 }
187 177
188 void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host, 178 void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host,
189 RenderViewHost* new_host) { 179 RenderViewHost* new_host) {
190 if (new_host)
191 RenderWidgetHostViewChanged(new_host->view());
192 native_container_->RenderViewHostChanged(old_host, new_host); 180 native_container_->RenderViewHostChanged(old_host, new_host);
193 } 181 }
194 182
195 void TabContentsContainer::TabContentsDestroyed(WebContents* contents) { 183 void TabContentsContainer::TabContentsDestroyed(WebContents* contents) {
196 // Sometimes, a TabContents is destroyed before we know about it. This allows 184 // Sometimes, a TabContents is destroyed before we know about it. This allows
197 // us to clean up our state in case this happens. 185 // us to clean up our state in case this happens.
198 DCHECK(contents == web_contents_); 186 DCHECK(contents == web_contents_);
199 ChangeWebContents(NULL); 187 ChangeWebContents(NULL);
200 } 188 }
201
202 void TabContentsContainer::RenderWidgetHostViewChanged(
203 RenderWidgetHostView* new_view) {
204 if (new_view)
205 new_view->set_reserved_contents_rect(cached_reserved_rect_);
206 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tab_contents/tab_contents_container.h ('k') | chrome/test/base/test_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698