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

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: addressed scott's comments 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 if (rvh) {
161 content::Source<content::RenderWidgetHost>(rvh); 162 content::NotificationSource source =
162 registrar_.Add(this, 163 content::Source<content::RenderWidgetHost>(rvh);
163 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, 164 registrar_.Add(this,
164 source); 165 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE,
166 source);
167 }
165 } 168 }
166 #endif // !defined(OS_WIN) 169 #endif // !defined(OS_WIN)
167 } 170 }
168 171
169 overlay_height_ = height; 172 overlay_height_ = height;
170 overlay_height_units_ = units; 173 overlay_height_units_ = units;
171 draw_drop_shadow_ = draw_drop_shadow; 174 draw_drop_shadow_ = draw_drop_shadow;
172 175
173 // Add shadow view if there's overlay and drop shadow is needed. 176 // Add shadow view if there's overlay and drop shadow is needed.
174 // Remove shadow view if there's no overlay. 177 // Remove shadow view if there's no overlay.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 std::string ContentsContainer::GetClassName() const { 269 std::string ContentsContainer::GetClassName() const {
267 return kViewClassName; 270 return kViewClassName;
268 } 271 }
269 272
270 void ContentsContainer::Observe(int type, 273 void ContentsContainer::Observe(int type,
271 const content::NotificationSource& source, 274 const content::NotificationSource& source,
272 const content::NotificationDetails& details) { 275 const content::NotificationDetails& details) {
273 DCHECK_EQ(content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, 276 DCHECK_EQ(content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE,
274 type); 277 type);
275 // Remove shadow view if it's not needed. 278 // Remove shadow view if it's not needed.
276 if (overlay_ && !draw_drop_shadow_) 279 if (overlay_ && !draw_drop_shadow_) {
280 DCHECK(overlay_web_contents_);
281 DCHECK_EQ(overlay_web_contents_->GetRenderViewHost(),
282 (content::Source<content::RenderWidgetHost>(source)).ptr());
277 shadow_view_.reset(); 283 shadow_view_.reset();
284 }
278 } 285 }
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