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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 history_list_length_(0), | 637 history_list_length_(0), |
638 frames_in_progress_(0), | 638 frames_in_progress_(0), |
639 target_url_status_(TARGET_NONE), | 639 target_url_status_(TARGET_NONE), |
640 uses_temporary_zoom_level_(false), | 640 uses_temporary_zoom_level_(false), |
641 #if defined(OS_ANDROID) | 641 #if defined(OS_ANDROID) |
642 top_controls_constraints_(TOP_CONTROLS_STATE_BOTH), | 642 top_controls_constraints_(TOP_CONTROLS_STATE_BOTH), |
643 #endif | 643 #endif |
644 has_focus_(false), | 644 has_focus_(false), |
645 has_scrolled_focused_editable_node_into_rect_(false), | 645 has_scrolled_focused_editable_node_into_rect_(false), |
646 main_render_frame_(nullptr), | 646 main_render_frame_(nullptr), |
| 647 frame_widget_(nullptr), |
647 speech_recognition_dispatcher_(NULL), | 648 speech_recognition_dispatcher_(NULL), |
648 mouse_lock_dispatcher_(NULL), | 649 mouse_lock_dispatcher_(NULL), |
649 #if defined(OS_ANDROID) | 650 #if defined(OS_ANDROID) |
650 expected_content_intent_id_(0), | 651 expected_content_intent_id_(0), |
651 #endif | 652 #endif |
652 #if defined(OS_WIN) | 653 #if defined(OS_WIN) |
653 focused_plugin_id_(-1), | 654 focused_plugin_id_(-1), |
654 #endif | 655 #endif |
655 #if defined(ENABLE_PLUGINS) | 656 #if defined(ENABLE_PLUGINS) |
656 plugin_find_handler_(NULL), | 657 plugin_find_handler_(NULL), |
(...skipping 26 matching lines...) Expand all Loading... |
683 g_view_map.Get().insert(std::make_pair(webview(), this)); | 684 g_view_map.Get().insert(std::make_pair(webview(), this)); |
684 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)); |
685 | 686 |
686 const base::CommandLine& command_line = | 687 const base::CommandLine& command_line = |
687 *base::CommandLine::ForCurrentProcess(); | 688 *base::CommandLine::ForCurrentProcess(); |
688 | 689 |
689 if (command_line.HasSwitch(switches::kStatsCollectionController)) | 690 if (command_line.HasSwitch(switches::kStatsCollectionController)) |
690 stats_collection_observer_.reset(new StatsCollectionObserver(this)); | 691 stats_collection_observer_.reset(new StatsCollectionObserver(this)); |
691 | 692 |
692 if (params.main_frame_routing_id != MSG_ROUTING_NONE) { | 693 if (params.main_frame_routing_id != MSG_ROUTING_NONE) { |
693 main_render_frame_ = | 694 main_render_frame_ = RenderFrameImpl::CreateMainFrame( |
694 RenderFrameImpl::CreateMainFrame(this, params.main_frame_routing_id); | 695 this, params.main_frame_routing_id, params.main_frame_widget_routing_id, |
| 696 params.hidden, screen_info(), compositor_deps_); |
695 } | 697 } |
696 | 698 |
697 if (params.proxy_routing_id != MSG_ROUTING_NONE) { | 699 if (params.proxy_routing_id != MSG_ROUTING_NONE) { |
698 CHECK(params.swapped_out); | 700 CHECK(params.swapped_out); |
699 if (main_render_frame_) { | 701 if (main_render_frame_) { |
700 DCHECK(!SiteIsolationPolicy::IsSwappedOutStateForbidden()); | 702 DCHECK(!SiteIsolationPolicy::IsSwappedOutStateForbidden()); |
701 RenderFrameProxy* proxy = RenderFrameProxy::CreateProxyToReplaceFrame( | 703 RenderFrameProxy* proxy = RenderFrameProxy::CreateProxyToReplaceFrame( |
702 main_render_frame_, params.proxy_routing_id, | 704 main_render_frame_, params.proxy_routing_id, |
703 blink::WebTreeScopeType::Document); | 705 blink::WebTreeScopeType::Document); |
704 main_render_frame_->set_render_frame_proxy(proxy); | 706 main_render_frame_->set_render_frame_proxy(proxy); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 if (opener_frame && !was_created_by_renderer) | 817 if (opener_frame && !was_created_by_renderer) |
816 webview()->mainFrame()->setOpener(opener_frame); | 818 webview()->mainFrame()->setOpener(opener_frame); |
817 | 819 |
818 // If we are initially swapped out, navigate to kSwappedOutURL. | 820 // If we are initially swapped out, navigate to kSwappedOutURL. |
819 // This ensures we are in a unique origin that others cannot script. | 821 // This ensures we are in a unique origin that others cannot script. |
820 if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame()) | 822 if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame()) |
821 main_render_frame_->NavigateToSwappedOutURL(); | 823 main_render_frame_->NavigateToSwappedOutURL(); |
822 } | 824 } |
823 | 825 |
824 RenderViewImpl::~RenderViewImpl() { | 826 RenderViewImpl::~RenderViewImpl() { |
| 827 DCHECK(!frame_widget_); |
| 828 |
825 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); | 829 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); |
826 it != disambiguation_bitmaps_.end(); | 830 it != disambiguation_bitmaps_.end(); |
827 ++it) | 831 ++it) |
828 delete it->second; | 832 delete it->second; |
829 | 833 |
830 // If file chooser is still waiting for answer, dispatch empty answer. | 834 // If file chooser is still waiting for answer, dispatch empty answer. |
831 while (!file_chooser_completions_.empty()) { | 835 while (!file_chooser_completions_.empty()) { |
832 if (file_chooser_completions_.front()->completion) { | 836 if (file_chooser_completions_.front()->completion) { |
833 file_chooser_completions_.front()->completion->didChooseFile( | 837 file_chooser_completions_.front()->completion->didChooseFile( |
834 WebVector<WebString>()); | 838 WebVector<WebString>()); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 params.disposition = NavigationPolicyToDisposition(policy); | 1574 params.disposition = NavigationPolicyToDisposition(policy); |
1571 if (!request.isNull()) { | 1575 if (!request.isNull()) { |
1572 params.target_url = request.url(); | 1576 params.target_url = request.url(); |
1573 params.referrer = GetReferrerFromRequest(creator, request); | 1577 params.referrer = GetReferrerFromRequest(creator, request); |
1574 } | 1578 } |
1575 params.features = features; | 1579 params.features = features; |
1576 | 1580 |
1577 for (size_t i = 0; i < features.additionalFeatures.size(); ++i) | 1581 for (size_t i = 0; i < features.additionalFeatures.size(); ++i) |
1578 params.additional_features.push_back(features.additionalFeatures[i]); | 1582 params.additional_features.push_back(features.additionalFeatures[i]); |
1579 | 1583 |
1580 int32 routing_id = MSG_ROUTING_NONE; | 1584 ViewHostMsg_CreateWindow_Reply reply; |
1581 int32 main_frame_routing_id = MSG_ROUTING_NONE; | 1585 RenderThread::Get()->Send(new ViewHostMsg_CreateWindow(params, &reply)); |
1582 int64 cloned_session_storage_namespace_id = 0; | 1586 if (reply.route_id == MSG_ROUTING_NONE) |
1583 | |
1584 RenderThread::Get()->Send( | |
1585 new ViewHostMsg_CreateWindow(params, &routing_id, &main_frame_routing_id, | |
1586 &cloned_session_storage_namespace_id)); | |
1587 if (routing_id == MSG_ROUTING_NONE) | |
1588 return NULL; | 1587 return NULL; |
1589 | 1588 |
1590 WebUserGestureIndicator::consumeUserGesture(); | 1589 WebUserGestureIndicator::consumeUserGesture(); |
1591 | 1590 |
1592 // While this view may be a background extension page, it can spawn a visible | 1591 // While this view may be a background extension page, it can spawn a visible |
1593 // render view. So we just assume that the new one is not another background | 1592 // render view. So we just assume that the new one is not another background |
1594 // page instead of passing on our own value. | 1593 // page instead of passing on our own value. |
1595 // TODO(vangelis): Can we tell if the new view will be a background page? | 1594 // TODO(vangelis): Can we tell if the new view will be a background page? |
1596 bool never_visible = false; | 1595 bool never_visible = false; |
1597 | 1596 |
1598 ViewMsg_Resize_Params initial_size = ViewMsg_Resize_Params(); | 1597 ViewMsg_Resize_Params initial_size = ViewMsg_Resize_Params(); |
1599 initial_size.screen_info = screen_info_; | 1598 initial_size.screen_info = screen_info_; |
1600 | 1599 |
1601 // The initial hidden state for the RenderViewImpl here has to match what the | 1600 // The initial hidden state for the RenderViewImpl here has to match what the |
1602 // browser will eventually decide for the given disposition. Since we have to | 1601 // browser will eventually decide for the given disposition. Since we have to |
1603 // return from this call synchronously, we just have to make our best guess | 1602 // return from this call synchronously, we just have to make our best guess |
1604 // and rely on the browser sending a WasHidden / WasShown message if it | 1603 // and rely on the browser sending a WasHidden / WasShown message if it |
1605 // disagrees. | 1604 // disagrees. |
1606 ViewMsg_New_Params view_params; | 1605 ViewMsg_New_Params view_params; |
1607 | 1606 |
1608 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); | 1607 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); |
1609 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); | 1608 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); |
1610 DCHECK_EQ(routing_id_, creator_frame->render_view()->GetRoutingID()); | 1609 DCHECK_EQ(routing_id_, creator_frame->render_view()->GetRoutingID()); |
1611 | 1610 |
1612 view_params.window_was_created_with_opener = true; | 1611 view_params.window_was_created_with_opener = true; |
1613 view_params.renderer_preferences = renderer_preferences_; | 1612 view_params.renderer_preferences = renderer_preferences_; |
1614 view_params.web_preferences = webkit_preferences_; | 1613 view_params.web_preferences = webkit_preferences_; |
1615 view_params.view_id = routing_id; | 1614 view_params.view_id = reply.route_id; |
1616 view_params.main_frame_routing_id = main_frame_routing_id; | 1615 view_params.main_frame_routing_id = reply.main_frame_route_id; |
| 1616 view_params.main_frame_widget_routing_id = reply.main_frame_widget_route_id; |
1617 view_params.session_storage_namespace_id = | 1617 view_params.session_storage_namespace_id = |
1618 cloned_session_storage_namespace_id; | 1618 reply.cloned_session_storage_namespace_id; |
1619 view_params.swapped_out = false; | 1619 view_params.swapped_out = false; |
1620 // WebCore will take care of setting the correct name. | 1620 // WebCore will take care of setting the correct name. |
1621 view_params.replicated_frame_state = FrameReplicationState(); | 1621 view_params.replicated_frame_state = FrameReplicationState(); |
1622 view_params.proxy_routing_id = MSG_ROUTING_NONE; | |
1623 view_params.hidden = (params.disposition == NEW_BACKGROUND_TAB); | 1622 view_params.hidden = (params.disposition == NEW_BACKGROUND_TAB); |
1624 view_params.never_visible = never_visible; | 1623 view_params.never_visible = never_visible; |
1625 view_params.next_page_id = 1; | 1624 view_params.next_page_id = 1; |
1626 view_params.initial_size = initial_size; | 1625 view_params.initial_size = initial_size; |
1627 view_params.enable_auto_resize = false; | 1626 view_params.enable_auto_resize = false; |
1628 view_params.min_size = gfx::Size(); | 1627 view_params.min_size = gfx::Size(); |
1629 view_params.max_size = gfx::Size(); | 1628 view_params.max_size = gfx::Size(); |
1630 | 1629 |
1631 RenderViewImpl* view = | 1630 RenderViewImpl* view = |
1632 RenderViewImpl::Create(compositor_deps_, view_params, true); | 1631 RenderViewImpl::Create(compositor_deps_, view_params, true); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 // calls DidStopLoading() without a matching DidStartLoading(). | 1690 // calls DidStopLoading() without a matching DidStartLoading(). |
1692 if (frames_in_progress_ == 0) | 1691 if (frames_in_progress_ == 0) |
1693 return; | 1692 return; |
1694 frames_in_progress_--; | 1693 frames_in_progress_--; |
1695 if (frames_in_progress_ == 0) { | 1694 if (frames_in_progress_ == 0) { |
1696 DidStopLoadingIcons(); | 1695 DidStopLoadingIcons(); |
1697 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); | 1696 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); |
1698 } | 1697 } |
1699 } | 1698 } |
1700 | 1699 |
| 1700 void RenderViewImpl::AttachWebFrameWidget(blink::WebWidget* frame_widget) { |
| 1701 // The previous WebFrameWidget must already be detached by CloseForFrame(). |
| 1702 DCHECK(!frame_widget_); |
| 1703 frame_widget_ = frame_widget; |
| 1704 } |
| 1705 |
1701 void RenderViewImpl::SetZoomLevel(double zoom_level) { | 1706 void RenderViewImpl::SetZoomLevel(double zoom_level) { |
1702 webview()->setZoomLevel(zoom_level); | 1707 webview()->setZoomLevel(zoom_level); |
1703 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); | 1708 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); |
1704 } | 1709 } |
1705 | 1710 |
1706 void RenderViewImpl::didCancelCompositionOnSelectionChange() { | 1711 void RenderViewImpl::didCancelCompositionOnSelectionChange() { |
1707 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1712 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
1708 } | 1713 } |
1709 | 1714 |
1710 bool RenderViewImpl::handleCurrentKeyboardEvent() { | 1715 bool RenderViewImpl::handleCurrentKeyboardEvent() { |
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2941 // WebPluginDelegateProxy is responsible for figuring out if this event | 2946 // WebPluginDelegateProxy is responsible for figuring out if this event |
2942 // applies to it or not, so inform all the delegates. | 2947 // applies to it or not, so inform all the delegates. |
2943 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 2948 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
2944 for (plugin_it = plugin_delegates_.begin(); | 2949 for (plugin_it = plugin_delegates_.begin(); |
2945 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 2950 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
2946 (*plugin_it)->ImeCompositionCompleted(text, plugin_id); | 2951 (*plugin_it)->ImeCompositionCompleted(text, plugin_id); |
2947 } | 2952 } |
2948 } | 2953 } |
2949 #endif // OS_MACOSX | 2954 #endif // OS_MACOSX |
2950 | 2955 |
| 2956 void RenderViewImpl::CloseForFrame() { |
| 2957 DCHECK(frame_widget_); |
| 2958 frame_widget_->close(); |
| 2959 frame_widget_ = nullptr; |
| 2960 } |
| 2961 |
2951 void RenderViewImpl::Close() { | 2962 void RenderViewImpl::Close() { |
2952 // We need to grab a pointer to the doomed WebView before we destroy it. | 2963 // We need to grab a pointer to the doomed WebView before we destroy it. |
2953 WebView* doomed = webview(); | 2964 WebView* doomed = webview(); |
2954 RenderWidget::Close(); | 2965 RenderWidget::Close(); |
2955 g_view_map.Get().erase(doomed); | 2966 g_view_map.Get().erase(doomed); |
2956 g_routing_id_view_map.Get().erase(routing_id_); | 2967 g_routing_id_view_map.Get().erase(routing_id_); |
2957 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(routing_id_)); | 2968 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(routing_id_)); |
2958 } | 2969 } |
2959 | 2970 |
2960 void RenderViewImpl::DidHandleKeyEvent() { | 2971 void RenderViewImpl::DidHandleKeyEvent() { |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3685 std::vector<gfx::Size> sizes; | 3696 std::vector<gfx::Size> sizes; |
3686 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 3697 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
3687 if (!url.isEmpty()) | 3698 if (!url.isEmpty()) |
3688 urls.push_back( | 3699 urls.push_back( |
3689 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 3700 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
3690 } | 3701 } |
3691 SendUpdateFaviconURL(urls); | 3702 SendUpdateFaviconURL(urls); |
3692 } | 3703 } |
3693 | 3704 |
3694 } // namespace content | 3705 } // namespace content |
OLD | NEW |