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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1642283002: Deal with frame removal by content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ImageDocument: Account for detach in DOM mutations Created 4 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 3332 matching lines...) Expand 10 before | Expand all | Expand 10 after
3343 if (frame == main_frame) { 3343 if (frame == main_frame) {
3344 // For now, don't remember plugin zoom values. We don't want to mix them 3344 // For now, don't remember plugin zoom values. We don't want to mix them
3345 // with normal web content (i.e. a fixed layout plugin would usually want 3345 // with normal web content (i.e. a fixed layout plugin would usually want
3346 // them different). 3346 // them different).
3347 render_view_->Send(new ViewHostMsg_DocumentAvailableInMainFrame( 3347 render_view_->Send(new ViewHostMsg_DocumentAvailableInMainFrame(
3348 render_view_->GetRoutingID(), 3348 render_view_->GetRoutingID(),
3349 main_frame->document().isPluginDocument())); 3349 main_frame->document().isPluginDocument()));
3350 } 3350 }
3351 } 3351 }
3352 3352
3353 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 3353 // Notify observers; The frame can be detached by an extension script.
3354 DidCreateDocumentElement()); 3354 if (observers_.might_have_observers()) {
nasko 2016/02/08 18:12:53 Yuck :(. Why is this the only method that needs th
robwu 2016/02/09 01:18:10 This is needed because the observers expect the su
3355 base::WeakPtr<RenderFrameImpl> self = weak_factory_.GetWeakPtr();
3356 base::ObserverListBase<RenderFrameObserver>::Iterator it(&observers_);
3357 RenderFrameObserver* obs;
3358 while ((obs = it.GetNext()) != nullptr) {
3359 obs->DidCreateDocumentElement();
3360 if (!self.get())
3361 return;
3362 }
3363 }
3355 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 3364 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
3356 DidCreateDocumentElement(frame)); 3365 DidCreateDocumentElement(frame));
3357 } 3366 }
3358 3367
3359 void RenderFrameImpl::didReceiveTitle(blink::WebLocalFrame* frame, 3368 void RenderFrameImpl::didReceiveTitle(blink::WebLocalFrame* frame,
3360 const blink::WebString& title, 3369 const blink::WebString& title,
3361 blink::WebTextDirection direction) { 3370 blink::WebTextDirection direction) {
3362 DCHECK(!frame_ || frame_ == frame); 3371 DCHECK(!frame_ || frame_ == frame);
3363 // Ignore all but top level navigations. 3372 // Ignore all but top level navigations.
3364 if (!frame->parent()) { 3373 if (!frame->parent()) {
(...skipping 23 matching lines...) Expand all
3388 "id", routing_id_); 3397 "id", routing_id_);
3389 DCHECK(!frame_ || frame_ == frame); 3398 DCHECK(!frame_ || frame_ == frame);
3390 WebDataSource* ds = frame->dataSource(); 3399 WebDataSource* ds = frame->dataSource();
3391 DocumentState* document_state = DocumentState::FromDataSource(ds); 3400 DocumentState* document_state = DocumentState::FromDataSource(ds);
3392 document_state->set_finish_document_load_time(Time::Now()); 3401 document_state->set_finish_document_load_time(Time::Now());
3393 3402
3394 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); 3403 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_));
3395 3404
3396 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 3405 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
3397 DidFinishDocumentLoad(frame)); 3406 DidFinishDocumentLoad(frame));
3398 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishDocumentLoad()); 3407 // Notify observers; The frame can be detached by an extension script.
3408 if (observers_.might_have_observers()) {
3409 base::WeakPtr<RenderFrameImpl> self = weak_factory_.GetWeakPtr();
3410 base::ObserverListBase<RenderFrameObserver>::Iterator it(&observers_);
3411 RenderFrameObserver* obs;
3412 while ((obs = it.GetNext()) != nullptr) {
3413 obs->DidFinishDocumentLoad();
3414 if (!self.get())
3415 return;
3416 }
3417 }
3399 3418
3400 // Check whether we have new encoding name. 3419 // Check whether we have new encoding name.
3401 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); 3420 UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
3402 3421
3403 // If this is an empty document with an http status code indicating an error, 3422 // If this is an empty document with an http status code indicating an error,
3404 // we may want to display our own error page, so the user doesn't end up 3423 // we may want to display our own error page, so the user doesn't end up
3405 // with an unexplained blank page. 3424 // with an unexplained blank page.
3406 if (!document_is_empty) 3425 if (!document_is_empty)
3407 return; 3426 return;
3408 3427
(...skipping 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after
6108 int match_count, 6127 int match_count,
6109 int ordinal, 6128 int ordinal,
6110 const WebRect& selection_rect, 6129 const WebRect& selection_rect,
6111 bool final_status_update) { 6130 bool final_status_update) {
6112 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6131 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6113 selection_rect, ordinal, 6132 selection_rect, ordinal,
6114 final_status_update)); 6133 final_status_update));
6115 } 6134 }
6116 6135
6117 } // namespace content 6136 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698