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

Side by Side Diff: extensions/renderer/dispatcher.cc

Issue 1642283002: Deal with frame removal by content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add AfterDidCreateDocumentElement/AfterDidFinishDocumentLoad 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/dispatcher.h" 5 #include "extensions/renderer/dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 } 493 }
494 494
495 // In testing, the document lifetime events can happen after the render 495 // In testing, the document lifetime events can happen after the render
496 // process shutdown event. 496 // process shutdown event.
497 // See: http://crbug.com/21508 and http://crbug.com/500851 497 // See: http://crbug.com/21508 and http://crbug.com/500851
498 if (content_watcher_) { 498 if (content_watcher_) {
499 content_watcher_->DidCreateDocumentElement(frame); 499 content_watcher_->DidCreateDocumentElement(frame);
500 } 500 }
501 } 501 }
502 502
503 void Dispatcher::AfterDidCreateDocumentElement(
504 const base::WeakPtr<content::RenderFrame>& render_frame) {
505 DCHECK(render_frame.get());
506 ExtensionFrameHelper* frame_helper =
507 ExtensionFrameHelper::Get(render_frame.get());
ncarter (slow) 2016/02/11 22:47:32 Nasko pointed me at this CL to see if there might
robwu 2016/02/11 23:36:50 Done. I don't see any issue with passing a weakptr
ncarter (slow) 2016/02/12 19:32:57 I'm not opposed to it per se either, but I think i
robwu 2016/02/12 19:51:43 That makes sense. Thanks for explaining your line
508 if (!frame_helper)
509 return; // The frame is invisible to extensions.
510
511 script_injection_manager_->AfterDidCreateDocumentElement(render_frame.get());
512 if (!render_frame.get())
513 return; // Frame was destroyed by injected user script.
514
515 frame_helper->AfterDidCreateDocumentElement(render_frame);
516 }
517
518 void Dispatcher::AfterDidFinishDocumentLoad(
519 const base::WeakPtr<content::RenderFrame>& render_frame) {
520 if (!ExtensionFrameHelper::Get(render_frame.get()))
521 return; // The frame is invisible to extensions.
522
523 script_injection_manager_->AfterDidFinishDocumentLoad(render_frame.get());
524 // The frame might be destroyed by the injected user script at this point.
525 }
526
503 void Dispatcher::OnExtensionResponse(int request_id, 527 void Dispatcher::OnExtensionResponse(int request_id,
504 bool success, 528 bool success,
505 const base::ListValue& response, 529 const base::ListValue& response,
506 const std::string& error) { 530 const std::string& error) {
507 request_sender_->HandleResponse(request_id, success, response, error); 531 request_sender_->HandleResponse(request_id, success, response, error);
508 } 532 }
509 533
510 void Dispatcher::DispatchEvent(const std::string& extension_id, 534 void Dispatcher::DispatchEvent(const std::string& extension_id,
511 const std::string& event_name) const { 535 const std::string& event_name) const {
512 base::ListValue args; 536 base::ListValue args;
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 // The "guestViewDeny" module must always be loaded last. It registers 1636 // The "guestViewDeny" module must always be loaded last. It registers
1613 // error-providing custom elements for the GuestView types that are not 1637 // error-providing custom elements for the GuestView types that are not
1614 // available, and thus all of those types must have been checked and loaded 1638 // available, and thus all of those types must have been checked and loaded
1615 // (or not loaded) beforehand. 1639 // (or not loaded) beforehand.
1616 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { 1640 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
1617 module_system->Require("guestViewDeny"); 1641 module_system->Require("guestViewDeny");
1618 } 1642 }
1619 } 1643 }
1620 1644
1621 } // namespace extensions 1645 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698