Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 &blink_settings); | 604 &blink_settings); |
| 605 for (const std::string& setting : blink_settings) { | 605 for (const std::string& setting : blink_settings) { |
| 606 size_t pos = setting.find('='); | 606 size_t pos = setting.find('='); |
| 607 settings->setFromStrings( | 607 settings->setFromStrings( |
| 608 blink::WebString::fromLatin1(setting.substr(0, pos)), | 608 blink::WebString::fromLatin1(setting.substr(0, pos)), |
| 609 blink::WebString::fromLatin1( | 609 blink::WebString::fromLatin1( |
| 610 pos == std::string::npos ? "" : setting.substr(pos + 1))); | 610 pos == std::string::npos ? "" : setting.substr(pos + 1))); |
| 611 } | 611 } |
| 612 } | 612 } |
| 613 | 613 |
| 614 // Looks up and returns the WebFrame corresponding to a given opener frame | |
| 615 // routing ID. Also stores the opener's RenderView routing ID into | |
| 616 // |opener_view_routing_id|. | |
| 617 WebFrame* ResolveOpener(int opener_frame_routing_id, | |
| 618 int* opener_view_routing_id) { | |
| 619 *opener_view_routing_id = MSG_ROUTING_NONE; | |
| 620 if (opener_frame_routing_id == MSG_ROUTING_NONE) | |
| 621 return nullptr; | |
| 622 | |
| 623 // Opener routing ID could refer to either a RenderFrameProxy or a | |
| 624 // RenderFrame, so need to check both. | |
| 625 RenderFrameProxy* opener_proxy = | |
| 626 RenderFrameProxy::FromRoutingID(opener_frame_routing_id); | |
| 627 if (opener_proxy) { | |
| 628 *opener_view_routing_id = opener_proxy->render_view()->GetRoutingID(); | |
| 629 | |
| 630 // TODO(nasko,alexmos): This check won't be needed once swapped-out:// is | |
| 631 // gone. | |
| 632 if (opener_proxy->IsMainFrameDetachedFromTree()) | |
|
nasko
2015/07/07 16:26:21
Can we DCHECK the IsSwappedOutForbidden() value? T
alexmos
2015/07/08 04:42:18
Done. Added a check for IsSwappedOutForbidden() b
| |
| 633 return opener_proxy->render_view()->webview()->mainFrame(); | |
| 634 else | |
| 635 return opener_proxy->web_frame(); | |
| 636 } | |
| 637 | |
| 638 RenderFrameImpl* opener_frame = | |
| 639 RenderFrameImpl::FromRoutingID(opener_frame_routing_id); | |
| 640 if (opener_frame) { | |
| 641 *opener_view_routing_id = opener_frame->render_view()->GetRoutingID(); | |
| 642 return opener_frame->GetWebFrame(); | |
| 643 } | |
| 644 | |
| 645 return nullptr; | |
| 646 } | |
| 647 | |
| 614 } // namespace | 648 } // namespace |
| 615 | 649 |
| 616 RenderViewImpl::RenderViewImpl(const ViewMsg_New_Params& params) | 650 RenderViewImpl::RenderViewImpl(const ViewMsg_New_Params& params) |
| 617 : RenderWidget(blink::WebPopupTypeNone, | 651 : RenderWidget(blink::WebPopupTypeNone, |
| 618 params.initial_size.screen_info, | 652 params.initial_size.screen_info, |
| 619 params.swapped_out, | 653 params.swapped_out, |
| 620 params.hidden, | 654 params.hidden, |
| 621 params.never_visible), | 655 params.never_visible), |
| 622 webkit_preferences_(params.web_preferences), | 656 webkit_preferences_(params.web_preferences), |
| 623 send_content_state_immediately_(false), | 657 send_content_state_immediately_(false), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 enumeration_completion_id_(0), | 689 enumeration_completion_id_(0), |
| 656 session_storage_namespace_id_(params.session_storage_namespace_id), | 690 session_storage_namespace_id_(params.session_storage_namespace_id), |
| 657 page_scale_factor_is_one_(true) { | 691 page_scale_factor_is_one_(true) { |
| 658 } | 692 } |
| 659 | 693 |
| 660 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, | 694 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, |
| 661 CompositorDependencies* compositor_deps, | 695 CompositorDependencies* compositor_deps, |
| 662 bool was_created_by_renderer) { | 696 bool was_created_by_renderer) { |
| 663 routing_id_ = params.view_id; | 697 routing_id_ = params.view_id; |
| 664 surface_id_ = params.surface_id; | 698 surface_id_ = params.surface_id; |
| 665 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer) | 699 |
| 666 opener_id_ = params.opener_route_id; | 700 int opener_view_routing_id; |
|
alexmos
2015/07/06 23:56:42
Unfortunately, I had to keep this around as a view
| |
| 701 WebFrame* opener_frame = | |
| 702 ResolveOpener(params.opener_frame_route_id, &opener_view_routing_id); | |
| 703 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer) | |
| 704 opener_id_ = opener_view_routing_id; | |
| 705 | |
| 667 display_mode_= params.initial_size.display_mode; | 706 display_mode_= params.initial_size.display_mode; |
| 668 | 707 |
| 669 // Ensure we start with a valid next_page_id_ from the browser. | 708 // Ensure we start with a valid next_page_id_ from the browser. |
| 670 DCHECK_GE(next_page_id_, 0); | 709 DCHECK_GE(next_page_id_, 0); |
| 671 | 710 |
| 672 if (params.main_frame_routing_id != MSG_ROUTING_NONE) { | 711 if (params.main_frame_routing_id != MSG_ROUTING_NONE) { |
| 673 main_render_frame_ = RenderFrameImpl::Create( | 712 main_render_frame_ = RenderFrameImpl::Create( |
| 674 this, params.main_frame_routing_id); | 713 this, params.main_frame_routing_id); |
| 675 // The main frame WebLocalFrame object is closed by | 714 // The main frame WebLocalFrame object is closed by |
| 676 // RenderFrameImpl::frameDetached(). | 715 // RenderFrameImpl::frameDetached(). |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 | 850 |
| 812 new IdleUserDetector(this); | 851 new IdleUserDetector(this); |
| 813 | 852 |
| 814 if (command_line.HasSwitch(switches::kDomAutomationController)) | 853 if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 815 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 854 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
| 816 if (command_line.HasSwitch(switches::kStatsCollectionController)) | 855 if (command_line.HasSwitch(switches::kStatsCollectionController)) |
| 817 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; | 856 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; |
| 818 | 857 |
| 819 GetContentClient()->renderer()->RenderViewCreated(this); | 858 GetContentClient()->renderer()->RenderViewCreated(this); |
| 820 | 859 |
| 821 // If we have an opener_id but we weren't created by a renderer, then | 860 // If we have an opener_frame but we weren't created by a renderer, then it's |
| 822 // it's the browser asking us to set our opener to another RenderView. | 861 // the browser asking us to set our opener to another frame. |
| 823 if (params.opener_route_id != MSG_ROUTING_NONE && !was_created_by_renderer) { | 862 if (opener_frame && !was_created_by_renderer) |
| 824 RenderViewImpl* opener_view = FromRoutingID(params.opener_route_id); | 863 webview()->mainFrame()->setOpener(opener_frame); |
|
alexmos
2015/07/06 23:56:42
Note that previously, if this RenderView was opene
nasko
2015/07/07 16:26:21
Acknowledged.
| |
| 825 if (opener_view) | |
| 826 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); | |
| 827 } | |
| 828 | 864 |
| 829 // If we are initially swapped out, navigate to kSwappedOutURL. | 865 // If we are initially swapped out, navigate to kSwappedOutURL. |
| 830 // This ensures we are in a unique origin that others cannot script. | 866 // This ensures we are in a unique origin that others cannot script. |
| 831 if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame()) | 867 if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame()) |
| 832 main_render_frame_->NavigateToSwappedOutURL(); | 868 main_render_frame_->NavigateToSwappedOutURL(); |
| 833 } | 869 } |
| 834 | 870 |
| 835 RenderViewImpl::~RenderViewImpl() { | 871 RenderViewImpl::~RenderViewImpl() { |
| 836 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); | 872 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); |
| 837 it != disambiguation_bitmaps_.end(); | 873 it != disambiguation_bitmaps_.end(); |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1603 | 1639 |
| 1604 ViewMsg_Resize_Params initial_size = ViewMsg_Resize_Params(); | 1640 ViewMsg_Resize_Params initial_size = ViewMsg_Resize_Params(); |
| 1605 initial_size.screen_info = screen_info_; | 1641 initial_size.screen_info = screen_info_; |
| 1606 | 1642 |
| 1607 // The initial hidden state for the RenderViewImpl here has to match what the | 1643 // The initial hidden state for the RenderViewImpl here has to match what the |
| 1608 // browser will eventually decide for the given disposition. Since we have to | 1644 // browser will eventually decide for the given disposition. Since we have to |
| 1609 // return from this call synchronously, we just have to make our best guess | 1645 // return from this call synchronously, we just have to make our best guess |
| 1610 // and rely on the browser sending a WasHidden / WasShown message if it | 1646 // and rely on the browser sending a WasHidden / WasShown message if it |
| 1611 // disagrees. | 1647 // disagrees. |
| 1612 ViewMsg_New_Params view_params; | 1648 ViewMsg_New_Params view_params; |
| 1613 view_params.opener_route_id = routing_id_; | 1649 |
| 1650 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); | |
| 1651 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); | |
| 1652 DCHECK_EQ(routing_id_, creator_frame->render_view()->GetRoutingID()); | |
| 1653 | |
| 1614 view_params.window_was_created_with_opener = true; | 1654 view_params.window_was_created_with_opener = true; |
| 1615 view_params.renderer_preferences = renderer_preferences_; | 1655 view_params.renderer_preferences = renderer_preferences_; |
| 1616 view_params.web_preferences = webkit_preferences_; | 1656 view_params.web_preferences = webkit_preferences_; |
| 1617 view_params.view_id = routing_id; | 1657 view_params.view_id = routing_id; |
| 1618 view_params.main_frame_routing_id = main_frame_routing_id; | 1658 view_params.main_frame_routing_id = main_frame_routing_id; |
| 1619 view_params.surface_id = surface_id; | 1659 view_params.surface_id = surface_id; |
| 1620 view_params.session_storage_namespace_id = | 1660 view_params.session_storage_namespace_id = |
| 1621 cloned_session_storage_namespace_id; | 1661 cloned_session_storage_namespace_id; |
| 1622 view_params.swapped_out = false; | 1662 view_params.swapped_out = false; |
| 1623 // WebCore will take care of setting the correct name. | 1663 // WebCore will take care of setting the correct name. |
| (...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3796 std::vector<gfx::Size> sizes; | 3836 std::vector<gfx::Size> sizes; |
| 3797 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 3837 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 3798 if (!url.isEmpty()) | 3838 if (!url.isEmpty()) |
| 3799 urls.push_back( | 3839 urls.push_back( |
| 3800 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 3840 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 3801 } | 3841 } |
| 3802 SendUpdateFaviconURL(urls); | 3842 SendUpdateFaviconURL(urls); |
| 3803 } | 3843 } |
| 3804 | 3844 |
| 3805 } // namespace content | 3845 } // namespace content |
| OLD | NEW |