OLD | NEW |
---|---|
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 Loading... | |
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 content::RenderFrame* render_frame) { | |
505 ExtensionFrameHelper* frame_helper = ExtensionFrameHelper::Get(render_frame); | |
506 if (!frame_helper) | |
507 return; // The frame is invisible to extensions. | |
508 | |
509 base::WeakPtr<ExtensionFrameHelper> frame_helper_weak = | |
510 frame_helper->AsWeakPtr(); | |
511 | |
512 script_injection_manager_->AfterDidCreateDocumentElement(render_frame); | |
Devlin
2016/02/12 22:21:56
Would it make sense to have the script injection m
robwu
2016/02/12 22:37:13
I avoided that, because ScriptInjectionManager nee
Devlin
2016/02/12 22:51:01
What's the optimization there? Just avoiding crea
robwu
2016/02/12 23:24:49
This happens (which seems not that expensive):
1.
Devlin
2016/02/12 23:42:24
That sounds reasonable to me. If we're going to s
| |
513 if (!frame_helper_weak.get()) | |
514 return; // Frame was destroyed by injected user script. | |
515 | |
516 frame_helper->AfterDidCreateDocumentElement(); | |
517 } | |
518 | |
519 void Dispatcher::AfterDidFinishDocumentLoad( | |
520 content::RenderFrame* render_frame) { | |
521 if (!ExtensionFrameHelper::Get(render_frame)) | |
522 return; // The frame is invisible to extensions. | |
523 | |
524 script_injection_manager_->AfterDidFinishDocumentLoad(render_frame); | |
525 // The frame might be destroyed by the injected user script at this point. | |
526 } | |
527 | |
503 void Dispatcher::OnExtensionResponse(int request_id, | 528 void Dispatcher::OnExtensionResponse(int request_id, |
504 bool success, | 529 bool success, |
505 const base::ListValue& response, | 530 const base::ListValue& response, |
506 const std::string& error) { | 531 const std::string& error) { |
507 request_sender_->HandleResponse(request_id, success, response, error); | 532 request_sender_->HandleResponse(request_id, success, response, error); |
508 } | 533 } |
509 | 534 |
510 void Dispatcher::DispatchEvent(const std::string& extension_id, | 535 void Dispatcher::DispatchEvent(const std::string& extension_id, |
511 const std::string& event_name) const { | 536 const std::string& event_name) const { |
512 base::ListValue args; | 537 base::ListValue args; |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1612 // The "guestViewDeny" module must always be loaded last. It registers | 1637 // The "guestViewDeny" module must always be loaded last. It registers |
1613 // error-providing custom elements for the GuestView types that are not | 1638 // 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 | 1639 // available, and thus all of those types must have been checked and loaded |
1615 // (or not loaded) beforehand. | 1640 // (or not loaded) beforehand. |
1616 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { | 1641 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
1617 module_system->Require("guestViewDeny"); | 1642 module_system->Require("guestViewDeny"); |
1618 } | 1643 } |
1619 } | 1644 } |
1620 | 1645 |
1621 } // namespace extensions | 1646 } // namespace extensions |
OLD | NEW |