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

Side by Side Diff: chrome/browser/ui/views/frame/contents_container.cc

Issue 13674016: alternate ntp: fix crash in ContentsContainer destructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/frame/contents_container.h" 5 #include "chrome/browser/ui/views/frame/contents_container.h"
6 6
7 #include "content/public/browser/notification_service.h" 7 #include "content/public/browser/notification_service.h"
8 #include "content/public/browser/notification_types.h" 8 #include "content/public/browser/notification_types.h"
9 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 ContentsContainer::~ContentsContainer() { 92 ContentsContainer::~ContentsContainer() {
93 } 93 }
94 94
95 void ContentsContainer::MakeOverlayContentsActiveContents() { 95 void ContentsContainer::MakeOverlayContentsActiveContents() {
96 DCHECK(overlay_); 96 DCHECK(overlay_);
97 97
98 active_ = overlay_; 98 active_ = overlay_;
99 overlay_ = NULL; 99 overlay_ = NULL;
100 overlay_web_contents_ = NULL; 100 overlay_web_contents_ = NULL;
101 // Unregister from observing previous |overlay_web_contents_|.
102 registrar_.RemoveAll();
101 // Since |overlay_| has been nuked, shadow view is not needed anymore. 103 // Since |overlay_| has been nuked, shadow view is not needed anymore.
102 // Note that the previous |active_| will be deleted by caller (see 104 // Note that the previous |active_| will be deleted by caller (see
103 // BrowserView::ActiveTabChanged()) after this call, hence removing the old 105 // BrowserView::ActiveTabChanged()) after this call, hence removing the old
104 // |active_| as a child, and making the new |active_| (which is the previous 106 // |active_| as a child, and making the new |active_| (which is the previous
105 // |overlay_|) the first child. 107 // |overlay_|) the first child.
106 shadow_view_.reset(); 108 shadow_view_.reset();
107 Layout(); 109 Layout();
108 } 110 }
109 111
110 void ContentsContainer::SetOverlay(views::WebView* overlay, 112 void ContentsContainer::SetOverlay(views::WebView* overlay,
(...skipping 27 matching lines...) Expand all
138 RemoveChildView(shadow_view_.get()); 140 RemoveChildView(shadow_view_.get());
139 RemoveChildView(overlay_); 141 RemoveChildView(overlay_);
140 } 142 }
141 overlay_ = overlay; 143 overlay_ = overlay;
142 if (overlay_) 144 if (overlay_)
143 AddChildView(overlay_); 145 AddChildView(overlay_);
144 } 146 }
145 147
146 if (overlay_web_contents_ != overlay_web_contents) { 148 if (overlay_web_contents_ != overlay_web_contents) {
147 #if !defined(OS_WIN) 149 #if !defined(OS_WIN)
148 // Unregister from previous overlay web contents' render view host. 150 // Unregister from observing previous |overlay_web_contents_|.
149 if (overlay_web_contents_) 151 registrar_.RemoveAll();
150 registrar_.RemoveAll();
151 #endif // !defined(OS_WIN) 152 #endif // !defined(OS_WIN)
152 153
153 overlay_web_contents_ = overlay_web_contents; 154 overlay_web_contents_ = overlay_web_contents;
154 155
155 #if !defined(OS_WIN) 156 #if !defined(OS_WIN)
156 // Register to new overlay web contents' render view host. 157 // Register to new overlay web contents' render view host.
157 if (overlay_web_contents_) { 158 if (overlay_web_contents_) {
158 content::RenderViewHost* rvh = overlay_web_contents_->GetRenderViewHost(); 159 content::RenderViewHost* rvh = overlay_web_contents_->GetRenderViewHost();
159 DCHECK(rvh); 160 DCHECK(rvh);
160 content::NotificationSource source = 161 content::NotificationSource source =
161 content::Source<content::RenderWidgetHost>(rvh); 162 content::Source<content::RenderWidgetHost>(rvh);
162 registrar_.Add(this, 163 registrar_.Add(this,
sky 2013/04/05 19:44:17 Can we removeAll right here too?
kuan 2013/04/05 21:54:11 i already RemoveAll @151, is that enough?
sky 2013/04/05 23:00:08 Yes, that's fine.
163 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, 164 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE,
164 source); 165 source);
165 } 166 }
166 #endif // !defined(OS_WIN) 167 #endif // !defined(OS_WIN)
167 } 168 }
168 169
169 overlay_height_ = height; 170 overlay_height_ = height;
170 overlay_height_units_ = units; 171 overlay_height_units_ = units;
171 draw_drop_shadow_ = draw_drop_shadow; 172 draw_drop_shadow_ = draw_drop_shadow;
172 173
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 std::string ContentsContainer::GetClassName() const { 267 std::string ContentsContainer::GetClassName() const {
267 return kViewClassName; 268 return kViewClassName;
268 } 269 }
269 270
270 void ContentsContainer::Observe(int type, 271 void ContentsContainer::Observe(int type,
271 const content::NotificationSource& source, 272 const content::NotificationSource& source,
272 const content::NotificationDetails& details) { 273 const content::NotificationDetails& details) {
273 DCHECK_EQ(content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, 274 DCHECK_EQ(content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE,
274 type); 275 type);
275 // Remove shadow view if it's not needed. 276 // Remove shadow view if it's not needed.
276 if (overlay_ && !draw_drop_shadow_) 277 if (overlay_ && !draw_drop_shadow_ && overlay_web_contents_ &&
278 (content::Source<content::RenderWidgetHost>(source)).ptr() ==
sky 2013/04/05 19:44:17 Shouldn't this be a DCHECK?
kuan 2013/04/05 21:54:11 this is the dilemma i have: @159, GetRenderViewHos
sky 2013/04/05 23:00:08 Only register if rvh is non-null.
kuan 2013/04/05 23:10:54 Done.
279 overlay_web_contents_->GetRenderViewHost()) {
277 shadow_view_.reset(); 280 shadow_view_.reset();
281 }
278 } 282 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698