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

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

Issue 1303773002: Give the main frame a RenderWidget. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 3 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 (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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener( 671 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener(
672 params.opener_frame_route_id, &opener_view_routing_id); 672 params.opener_frame_route_id, &opener_view_routing_id);
673 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer) 673 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer)
674 opener_id_ = opener_view_routing_id; 674 opener_id_ = opener_view_routing_id;
675 675
676 display_mode_= params.initial_size.display_mode; 676 display_mode_= params.initial_size.display_mode;
677 677
678 // Ensure we start with a valid next_page_id_ from the browser. 678 // Ensure we start with a valid next_page_id_ from the browser.
679 DCHECK_GE(next_page_id_, 0); 679 DCHECK_GE(next_page_id_, 0);
680 680
681 if (params.main_frame_routing_id != MSG_ROUTING_NONE) {
682 main_render_frame_ = RenderFrameImpl::Create(
683 this, params.main_frame_routing_id);
684 // The main frame WebLocalFrame object is closed by
685 // RenderFrameImpl::frameDetached().
686 WebLocalFrame* web_frame = WebLocalFrame::create(
687 blink::WebTreeScopeType::Document, main_render_frame_);
688 main_render_frame_->SetWebFrame(web_frame);
689 }
690
691 webwidget_ = WebView::create(this); 681 webwidget_ = WebView::create(this);
692 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); 682 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_));
693 683
694 g_view_map.Get().insert(std::make_pair(webview(), this)); 684 g_view_map.Get().insert(std::make_pair(webview(), this));
695 g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this)); 685 g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this));
696 686
697 const base::CommandLine& command_line = 687 const base::CommandLine& command_line =
698 *base::CommandLine::ForCurrentProcess(); 688 *base::CommandLine::ForCurrentProcess();
699 689
700 if (command_line.HasSwitch(switches::kStatsCollectionController)) 690 if (command_line.HasSwitch(switches::kStatsCollectionController))
701 stats_collection_observer_.reset(new StatsCollectionObserver(this)); 691 stats_collection_observer_.reset(new StatsCollectionObserver(this));
702 692
693 if (params.main_frame_routing_id != MSG_ROUTING_NONE) {
694 main_render_frame_ = RenderFrameImpl::CreateMainFrame(
695 this, params.main_frame_routing_id, params.main_frame_widget_routing_id,
696 params.surface_id, params.hidden, screen_info(), compositor_deps_);
697 }
698
703 RenderFrameProxy* proxy = NULL; 699 RenderFrameProxy* proxy = NULL;
704 if (params.proxy_routing_id != MSG_ROUTING_NONE) { 700 if (params.proxy_routing_id != MSG_ROUTING_NONE) {
705 CHECK(params.swapped_out); 701 CHECK(params.swapped_out);
706 if (main_render_frame_) { 702 if (main_render_frame_) {
707 proxy = RenderFrameProxy::CreateProxyToReplaceFrame( 703 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(
708 main_render_frame_, params.proxy_routing_id, 704 main_render_frame_, params.proxy_routing_id,
709 blink::WebTreeScopeType::Document); 705 blink::WebTreeScopeType::Document);
710 main_render_frame_->set_render_frame_proxy(proxy); 706 main_render_frame_->set_render_frame_proxy(proxy);
711 } else { 707 } else {
712 proxy = RenderFrameProxy::CreateFrameProxy( 708 proxy = RenderFrameProxy::CreateFrameProxy(
713 params.proxy_routing_id, 709 params.proxy_routing_id,
714 MSG_ROUTING_NONE, 710 MSG_ROUTING_NONE,
715 routing_id_, 711 routing_id_,
716 params.replicated_frame_state); 712 params.replicated_frame_state);
717 } 713 }
718 } 714 }
719 715
720 // When not using swapped out state, just use the WebRemoteFrame as the main 716 // When not using swapped out state, just use the WebRemoteFrame as the main
721 // frame. 717 // frame.
722 if (proxy && SiteIsolationPolicy::IsSwappedOutStateForbidden()) { 718 if (proxy && SiteIsolationPolicy::IsSwappedOutStateForbidden()) {
723 webview()->setMainFrame(proxy->web_frame()); 719 webview()->setMainFrame(proxy->web_frame());
724 // Initialize the WebRemoteFrame with information replicated from the 720 // Initialize the WebRemoteFrame with information replicated from the
725 // browser process. 721 // browser process.
726 proxy->SetReplicatedState(params.replicated_frame_state); 722 proxy->SetReplicatedState(params.replicated_frame_state);
727 } else {
728 webview()->setMainFrame(main_render_frame_->GetWebFrame());
dcheng 2015/08/24 18:50:20 I moved this into RenderFrameImpl::CreateMainFrame
729 } 723 }
730 if (main_render_frame_) 724 if (main_render_frame_)
731 main_render_frame_->Initialize(); 725 main_render_frame_->Initialize();
732 726
733 #if defined(OS_ANDROID) 727 #if defined(OS_ANDROID)
734 content_detectors_.push_back(linked_ptr<ContentDetector>( 728 content_detectors_.push_back(linked_ptr<ContentDetector>(
735 new AddressDetector())); 729 new AddressDetector()));
736 const std::string& contry_iso = 730 const std::string& contry_iso =
737 params.renderer_preferences.network_contry_iso; 731 params.renderer_preferences.network_contry_iso;
738 if (!contry_iso.empty()) { 732 if (!contry_iso.empty()) {
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 params.disposition = NavigationPolicyToDisposition(policy); 1597 params.disposition = NavigationPolicyToDisposition(policy);
1604 if (!request.isNull()) { 1598 if (!request.isNull()) {
1605 params.target_url = request.url(); 1599 params.target_url = request.url();
1606 params.referrer = GetReferrerFromRequest(creator, request); 1600 params.referrer = GetReferrerFromRequest(creator, request);
1607 } 1601 }
1608 params.features = features; 1602 params.features = features;
1609 1603
1610 for (size_t i = 0; i < features.additionalFeatures.size(); ++i) 1604 for (size_t i = 0; i < features.additionalFeatures.size(); ++i)
1611 params.additional_features.push_back(features.additionalFeatures[i]); 1605 params.additional_features.push_back(features.additionalFeatures[i]);
1612 1606
1613 int32 routing_id = MSG_ROUTING_NONE; 1607 ViewHostMsg_CreateWindow_Reply reply;
1614 int32 main_frame_routing_id = MSG_ROUTING_NONE; 1608 reply.route_id = MSG_ROUTING_NONE;
1615 int32 surface_id = 0; 1609 reply.main_frame_route_id = MSG_ROUTING_NONE;
1616 int64 cloned_session_storage_namespace_id = 0; 1610 reply.main_frame_widget_route_id = MSG_ROUTING_NONE;
1611 reply.surface_id = 0;
1612 reply.cloned_session_storage_namespace_id = 0;
1617 1613
1618 RenderThread::Get()->Send(new ViewHostMsg_CreateWindow( 1614 RenderThread::Get()->Send(new ViewHostMsg_CreateWindow(params, &reply));
1619 params, &routing_id, &main_frame_routing_id, &surface_id, 1615 if (reply.route_id == MSG_ROUTING_NONE)
1620 &cloned_session_storage_namespace_id));
1621 if (routing_id == MSG_ROUTING_NONE)
1622 return NULL; 1616 return NULL;
1623 1617
1624 WebUserGestureIndicator::consumeUserGesture(); 1618 WebUserGestureIndicator::consumeUserGesture();
1625 1619
1626 // While this view may be a background extension page, it can spawn a visible 1620 // While this view may be a background extension page, it can spawn a visible
1627 // render view. So we just assume that the new one is not another background 1621 // render view. So we just assume that the new one is not another background
1628 // page instead of passing on our own value. 1622 // page instead of passing on our own value.
1629 // TODO(vangelis): Can we tell if the new view will be a background page? 1623 // TODO(vangelis): Can we tell if the new view will be a background page?
1630 bool never_visible = false; 1624 bool never_visible = false;
1631 1625
1632 ViewMsg_Resize_Params initial_size = ViewMsg_Resize_Params(); 1626 ViewMsg_Resize_Params initial_size = ViewMsg_Resize_Params();
1633 initial_size.screen_info = screen_info_; 1627 initial_size.screen_info = screen_info_;
1634 1628
1635 // The initial hidden state for the RenderViewImpl here has to match what the 1629 // The initial hidden state for the RenderViewImpl here has to match what the
1636 // browser will eventually decide for the given disposition. Since we have to 1630 // browser will eventually decide for the given disposition. Since we have to
1637 // return from this call synchronously, we just have to make our best guess 1631 // return from this call synchronously, we just have to make our best guess
1638 // and rely on the browser sending a WasHidden / WasShown message if it 1632 // and rely on the browser sending a WasHidden / WasShown message if it
1639 // disagrees. 1633 // disagrees.
1640 ViewMsg_New_Params view_params; 1634 ViewMsg_New_Params view_params;
1641 1635
1642 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); 1636 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator);
1643 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); 1637 view_params.opener_frame_route_id = creator_frame->GetRoutingID();
1644 DCHECK_EQ(routing_id_, creator_frame->render_view()->GetRoutingID()); 1638 DCHECK_EQ(routing_id_, creator_frame->render_view()->GetRoutingID());
1645 1639
1646 view_params.window_was_created_with_opener = true; 1640 view_params.window_was_created_with_opener = true;
1647 view_params.renderer_preferences = renderer_preferences_; 1641 view_params.renderer_preferences = renderer_preferences_;
1648 view_params.web_preferences = webkit_preferences_; 1642 view_params.web_preferences = webkit_preferences_;
1649 view_params.view_id = routing_id; 1643 view_params.view_id = reply.route_id;
1650 view_params.main_frame_routing_id = main_frame_routing_id; 1644 view_params.main_frame_routing_id = reply.main_frame_route_id;
1651 view_params.surface_id = surface_id; 1645 view_params.main_frame_widget_routing_id = reply.main_frame_widget_route_id;
1646 view_params.surface_id = reply.surface_id;
1652 view_params.session_storage_namespace_id = 1647 view_params.session_storage_namespace_id =
1653 cloned_session_storage_namespace_id; 1648 reply.cloned_session_storage_namespace_id;
1654 view_params.swapped_out = false; 1649 view_params.swapped_out = false;
1655 // WebCore will take care of setting the correct name. 1650 // WebCore will take care of setting the correct name.
1656 view_params.replicated_frame_state = FrameReplicationState(); 1651 view_params.replicated_frame_state = FrameReplicationState();
1657 view_params.proxy_routing_id = MSG_ROUTING_NONE; 1652 view_params.proxy_routing_id = MSG_ROUTING_NONE;
1658 view_params.hidden = (params.disposition == NEW_BACKGROUND_TAB); 1653 view_params.hidden = (params.disposition == NEW_BACKGROUND_TAB);
1659 view_params.never_visible = never_visible; 1654 view_params.never_visible = never_visible;
1660 view_params.next_page_id = 1; 1655 view_params.next_page_id = 1;
1661 view_params.initial_size = initial_size; 1656 view_params.initial_size = initial_size;
1662 view_params.enable_auto_resize = false; 1657 view_params.enable_auto_resize = false;
1663 view_params.min_size = gfx::Size(); 1658 view_params.min_size = gfx::Size();
(...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3798 std::vector<gfx::Size> sizes; 3793 std::vector<gfx::Size> sizes;
3799 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 3794 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
3800 if (!url.isEmpty()) 3795 if (!url.isEmpty())
3801 urls.push_back( 3796 urls.push_back(
3802 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 3797 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
3803 } 3798 }
3804 SendUpdateFaviconURL(urls); 3799 SendUpdateFaviconURL(urls);
3805 } 3800 }
3806 3801
3807 } // namespace content 3802 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698