OLD | NEW |
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 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 | 640 |
641 // static | 641 // static |
642 blink::WebSandboxFlags RenderFrameImpl::ContentToWebSandboxFlags( | 642 blink::WebSandboxFlags RenderFrameImpl::ContentToWebSandboxFlags( |
643 content::SandboxFlags flags) { | 643 content::SandboxFlags flags) { |
644 return static_cast<blink::WebSandboxFlags>(flags); | 644 return static_cast<blink::WebSandboxFlags>(flags); |
645 } | 645 } |
646 | 646 |
647 // RenderFrameImpl ---------------------------------------------------------- | 647 // RenderFrameImpl ---------------------------------------------------------- |
648 RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id) | 648 RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id) |
649 : frame_(NULL), | 649 : frame_(NULL), |
| 650 is_local_root_(false), |
650 render_view_(render_view->AsWeakPtr()), | 651 render_view_(render_view->AsWeakPtr()), |
651 routing_id_(routing_id), | 652 routing_id_(routing_id), |
652 is_swapped_out_(false), | 653 is_swapped_out_(false), |
653 render_frame_proxy_(NULL), | 654 render_frame_proxy_(NULL), |
654 is_detaching_(false), | 655 is_detaching_(false), |
655 proxy_routing_id_(MSG_ROUTING_NONE), | 656 proxy_routing_id_(MSG_ROUTING_NONE), |
656 #if defined(ENABLE_PLUGINS) | 657 #if defined(ENABLE_PLUGINS) |
657 plugin_power_saver_helper_(NULL), | 658 plugin_power_saver_helper_(NULL), |
658 #endif | 659 #endif |
659 cookie_jar_(this), | 660 cookie_jar_(this), |
660 selection_text_offset_(0), | 661 selection_text_offset_(0), |
661 selection_range_(gfx::Range::InvalidRange()), | 662 selection_range_(gfx::Range::InvalidRange()), |
662 handling_select_range_(false), | 663 handling_select_range_(false), |
663 notification_permission_dispatcher_(NULL), | 664 notification_permission_dispatcher_(NULL), |
664 web_user_media_client_(NULL), | 665 web_user_media_client_(NULL), |
665 media_permission_dispatcher_(NULL), | 666 media_permission_dispatcher_(NULL), |
666 midi_dispatcher_(NULL), | 667 midi_dispatcher_(NULL), |
667 #if defined(OS_ANDROID) | 668 #if defined(OS_ANDROID) |
668 media_player_manager_(NULL), | 669 media_player_manager_(NULL), |
669 #endif | 670 #endif |
670 #if defined(ENABLE_BROWSER_CDMS) | 671 #if defined(ENABLE_BROWSER_CDMS) |
671 cdm_manager_(NULL), | 672 cdm_manager_(NULL), |
672 #endif | 673 #endif |
673 #if defined(VIDEO_HOLE) | 674 #if defined(VIDEO_HOLE) |
674 contains_media_player_(false), | 675 contains_media_player_(false), |
675 #endif | 676 #endif |
| 677 devtools_agent_(nullptr), |
676 geolocation_dispatcher_(NULL), | 678 geolocation_dispatcher_(NULL), |
677 push_messaging_dispatcher_(NULL), | 679 push_messaging_dispatcher_(NULL), |
678 presentation_dispatcher_(NULL), | 680 presentation_dispatcher_(NULL), |
679 screen_orientation_dispatcher_(NULL), | 681 screen_orientation_dispatcher_(NULL), |
680 manifest_manager_(NULL), | 682 manifest_manager_(NULL), |
681 accessibility_mode_(AccessibilityModeOff), | 683 accessibility_mode_(AccessibilityModeOff), |
682 renderer_accessibility_(NULL), | 684 renderer_accessibility_(NULL), |
683 weak_factory_(this) { | 685 weak_factory_(this) { |
684 std::pair<RoutingIDFrameMap::iterator, bool> result = | 686 std::pair<RoutingIDFrameMap::iterator, bool> result = |
685 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 687 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 DCHECK(!frame_); | 725 DCHECK(!frame_); |
724 | 726 |
725 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( | 727 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( |
726 std::make_pair(web_frame, this)); | 728 std::make_pair(web_frame, this)); |
727 CHECK(result.second) << "Inserting a duplicate item."; | 729 CHECK(result.second) << "Inserting a duplicate item."; |
728 | 730 |
729 frame_ = web_frame; | 731 frame_ = web_frame; |
730 } | 732 } |
731 | 733 |
732 void RenderFrameImpl::Initialize() { | 734 void RenderFrameImpl::Initialize() { |
| 735 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame(); |
| 736 |
733 #if defined(ENABLE_PLUGINS) | 737 #if defined(ENABLE_PLUGINS) |
734 new PepperBrowserConnection(this); | 738 new PepperBrowserConnection(this); |
735 #endif | 739 #endif |
736 new SharedWorkerRepository(this); | 740 new SharedWorkerRepository(this); |
737 | 741 |
738 if (!frame_->parent()) | 742 if (!frame_->parent()) |
739 new ImageLoadingHelper(this); | 743 new ImageLoadingHelper(this); |
740 | 744 |
| 745 if (is_local_root_ && !render_frame_proxy_) { |
| 746 // DevToolsAgent is a RenderFrameObserver, and will destruct itself |
| 747 // when |this| is deleted. |
| 748 devtools_agent_ = new DevToolsAgent(this); |
| 749 } |
| 750 |
741 // We delay calling this until we have the WebFrame so that any observer or | 751 // We delay calling this until we have the WebFrame so that any observer or |
742 // embedder can call GetWebFrame on any RenderFrame. | 752 // embedder can call GetWebFrame on any RenderFrame. |
743 GetContentClient()->renderer()->RenderFrameCreated(this); | 753 GetContentClient()->renderer()->RenderFrameCreated(this); |
744 } | 754 } |
745 | 755 |
746 RenderWidget* RenderFrameImpl::GetRenderWidget() { | 756 RenderWidget* RenderFrameImpl::GetRenderWidget() { |
747 return render_view_.get(); | 757 return render_view_.get(); |
748 } | 758 } |
749 | 759 |
750 #if defined(ENABLE_PLUGINS) | 760 #if defined(ENABLE_PLUGINS) |
(...skipping 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3311 | 3321 |
3312 void RenderFrameImpl::didFinishResourceLoad(blink::WebLocalFrame* frame, | 3322 void RenderFrameImpl::didFinishResourceLoad(blink::WebLocalFrame* frame, |
3313 unsigned identifier) { | 3323 unsigned identifier) { |
3314 DCHECK(!frame_ || frame_ == frame); | 3324 DCHECK(!frame_ || frame_ == frame); |
3315 InternalDocumentStateData* internal_data = | 3325 InternalDocumentStateData* internal_data = |
3316 InternalDocumentStateData::FromDataSource(frame->dataSource()); | 3326 InternalDocumentStateData::FromDataSource(frame->dataSource()); |
3317 if (!internal_data->use_error_page()) | 3327 if (!internal_data->use_error_page()) |
3318 return; | 3328 return; |
3319 | 3329 |
3320 // Do not show error page when DevTools is attached. | 3330 // Do not show error page when DevTools is attached. |
3321 if (render_view_->devtools_agent_ && | 3331 RenderFrameImpl* localRoot = this; |
3322 render_view_->devtools_agent_->IsAttached()) { | 3332 while (localRoot->frame_ && localRoot->frame_->parent() && |
| 3333 localRoot->frame_->parent()->isWebLocalFrame()) { |
| 3334 localRoot = RenderFrameImpl::FromWebFrame(localRoot->frame_->parent()); |
| 3335 DCHECK(localRoot); |
| 3336 } |
| 3337 if (localRoot->devtools_agent_ && localRoot->devtools_agent_->IsAttached()) |
3323 return; | 3338 return; |
3324 } | |
3325 | 3339 |
3326 // Display error page, if appropriate. | 3340 // Display error page, if appropriate. |
3327 std::string error_domain = "http"; | 3341 std::string error_domain = "http"; |
3328 int http_status_code = internal_data->http_status_code(); | 3342 int http_status_code = internal_data->http_status_code(); |
3329 if (GetContentClient()->renderer()->HasErrorPage( | 3343 if (GetContentClient()->renderer()->HasErrorPage( |
3330 http_status_code, &error_domain)) { | 3344 http_status_code, &error_domain)) { |
3331 WebURLError error; | 3345 WebURLError error; |
3332 error.unreachableURL = frame->document().url(); | 3346 error.unreachableURL = frame->document().url(); |
3333 error.domain = WebString::fromUTF8(error_domain); | 3347 error.domain = WebString::fromUTF8(error_domain); |
3334 error.reason = http_status_code; | 3348 error.reason = http_status_code; |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4674 | 4688 |
4675 #if defined(ENABLE_BROWSER_CDMS) | 4689 #if defined(ENABLE_BROWSER_CDMS) |
4676 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4690 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4677 if (!cdm_manager_) | 4691 if (!cdm_manager_) |
4678 cdm_manager_ = new RendererCdmManager(this); | 4692 cdm_manager_ = new RendererCdmManager(this); |
4679 return cdm_manager_; | 4693 return cdm_manager_; |
4680 } | 4694 } |
4681 #endif // defined(ENABLE_BROWSER_CDMS) | 4695 #endif // defined(ENABLE_BROWSER_CDMS) |
4682 | 4696 |
4683 } // namespace content | 4697 } // namespace content |
OLD | NEW |