| 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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 params.disposition = NavigationPolicyToDisposition(policy); | 1572 params.disposition = NavigationPolicyToDisposition(policy); |
| 1569 if (!request.isNull()) { | 1573 if (!request.isNull()) { |
| 1570 params.target_url = request.url(); | 1574 params.target_url = request.url(); |
| 1571 params.referrer = GetReferrerFromRequest(creator, request); | 1575 params.referrer = GetReferrerFromRequest(creator, request); |
| 1572 } | 1576 } |
| 1573 params.features = features; | 1577 params.features = features; |
| 1574 | 1578 |
| 1575 for (size_t i = 0; i < features.additionalFeatures.size(); ++i) | 1579 for (size_t i = 0; i < features.additionalFeatures.size(); ++i) |
| 1576 params.additional_features.push_back(features.additionalFeatures[i]); | 1580 params.additional_features.push_back(features.additionalFeatures[i]); |
| 1577 | 1581 |
| 1578 int32 routing_id = MSG_ROUTING_NONE; | 1582 ViewHostMsg_CreateWindow_Reply reply; |
| 1579 int32 main_frame_routing_id = MSG_ROUTING_NONE; | 1583 RenderThread::Get()->Send(new ViewHostMsg_CreateWindow(params, &reply)); |
| 1580 int64 cloned_session_storage_namespace_id = 0; | 1584 if (reply.route_id == MSG_ROUTING_NONE) |
| 1581 | |
| 1582 RenderThread::Get()->Send( | |
| 1583 new ViewHostMsg_CreateWindow(params, &routing_id, &main_frame_routing_id, | |
| 1584 &cloned_session_storage_namespace_id)); | |
| 1585 if (routing_id == MSG_ROUTING_NONE) | |
| 1586 return NULL; | 1585 return NULL; |
| 1587 | 1586 |
| 1588 WebUserGestureIndicator::consumeUserGesture(); | 1587 WebUserGestureIndicator::consumeUserGesture(); |
| 1589 | 1588 |
| 1590 // While this view may be a background extension page, it can spawn a visible | 1589 // While this view may be a background extension page, it can spawn a visible |
| 1591 // render view. So we just assume that the new one is not another background | 1590 // render view. So we just assume that the new one is not another background |
| 1592 // page instead of passing on our own value. | 1591 // page instead of passing on our own value. |
| 1593 // TODO(vangelis): Can we tell if the new view will be a background page? | 1592 // TODO(vangelis): Can we tell if the new view will be a background page? |
| 1594 bool never_visible = false; | 1593 bool never_visible = false; |
| 1595 | 1594 |
| 1596 ViewMsg_Resize_Params initial_size = ViewMsg_Resize_Params(); | 1595 ViewMsg_Resize_Params initial_size = ViewMsg_Resize_Params(); |
| 1597 initial_size.screen_info = screen_info_; | 1596 initial_size.screen_info = screen_info_; |
| 1598 | 1597 |
| 1599 // The initial hidden state for the RenderViewImpl here has to match what the | 1598 // The initial hidden state for the RenderViewImpl here has to match what the |
| 1600 // browser will eventually decide for the given disposition. Since we have to | 1599 // browser will eventually decide for the given disposition. Since we have to |
| 1601 // return from this call synchronously, we just have to make our best guess | 1600 // return from this call synchronously, we just have to make our best guess |
| 1602 // and rely on the browser sending a WasHidden / WasShown message if it | 1601 // and rely on the browser sending a WasHidden / WasShown message if it |
| 1603 // disagrees. | 1602 // disagrees. |
| 1604 ViewMsg_New_Params view_params; | 1603 ViewMsg_New_Params view_params; |
| 1605 | 1604 |
| 1606 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); | 1605 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); |
| 1607 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); | 1606 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); |
| 1608 DCHECK_EQ(routing_id_, creator_frame->render_view()->GetRoutingID()); | 1607 DCHECK_EQ(routing_id_, creator_frame->render_view()->GetRoutingID()); |
| 1609 | 1608 |
| 1610 view_params.window_was_created_with_opener = true; | 1609 view_params.window_was_created_with_opener = true; |
| 1611 view_params.renderer_preferences = renderer_preferences_; | 1610 view_params.renderer_preferences = renderer_preferences_; |
| 1612 view_params.web_preferences = webkit_preferences_; | 1611 view_params.web_preferences = webkit_preferences_; |
| 1613 view_params.view_id = routing_id; | 1612 view_params.view_id = reply.route_id; |
| 1614 view_params.main_frame_routing_id = main_frame_routing_id; | 1613 view_params.main_frame_routing_id = reply.main_frame_route_id; |
| 1614 view_params.main_frame_widget_routing_id = reply.main_frame_widget_route_id; |
| 1615 view_params.session_storage_namespace_id = | 1615 view_params.session_storage_namespace_id = |
| 1616 cloned_session_storage_namespace_id; | 1616 reply.cloned_session_storage_namespace_id; |
| 1617 view_params.swapped_out = false; | 1617 view_params.swapped_out = false; |
| 1618 // WebCore will take care of setting the correct name. | 1618 // WebCore will take care of setting the correct name. |
| 1619 view_params.replicated_frame_state = FrameReplicationState(); | 1619 view_params.replicated_frame_state = FrameReplicationState(); |
| 1620 view_params.proxy_routing_id = MSG_ROUTING_NONE; | |
| 1621 view_params.hidden = (params.disposition == NEW_BACKGROUND_TAB); | 1620 view_params.hidden = (params.disposition == NEW_BACKGROUND_TAB); |
| 1622 view_params.never_visible = never_visible; | 1621 view_params.never_visible = never_visible; |
| 1623 view_params.next_page_id = 1; | 1622 view_params.next_page_id = 1; |
| 1624 view_params.initial_size = initial_size; | 1623 view_params.initial_size = initial_size; |
| 1625 view_params.enable_auto_resize = false; | 1624 view_params.enable_auto_resize = false; |
| 1626 view_params.min_size = gfx::Size(); | 1625 view_params.min_size = gfx::Size(); |
| 1627 view_params.max_size = gfx::Size(); | 1626 view_params.max_size = gfx::Size(); |
| 1628 | 1627 |
| 1629 RenderViewImpl* view = | 1628 RenderViewImpl* view = |
| 1630 RenderViewImpl::Create(compositor_deps_, view_params, true); | 1629 RenderViewImpl::Create(compositor_deps_, view_params, true); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 // calls DidStopLoading() without a matching DidStartLoading(). | 1688 // calls DidStopLoading() without a matching DidStartLoading(). |
| 1690 if (frames_in_progress_ == 0) | 1689 if (frames_in_progress_ == 0) |
| 1691 return; | 1690 return; |
| 1692 frames_in_progress_--; | 1691 frames_in_progress_--; |
| 1693 if (frames_in_progress_ == 0) { | 1692 if (frames_in_progress_ == 0) { |
| 1694 DidStopLoadingIcons(); | 1693 DidStopLoadingIcons(); |
| 1695 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); | 1694 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); |
| 1696 } | 1695 } |
| 1697 } | 1696 } |
| 1698 | 1697 |
| 1698 void RenderViewImpl::AttachWebFrameWidget(blink::WebWidget* frame_widget) { |
| 1699 // The previous WebFrameWidget must already be detached by CloseForFrame(). |
| 1700 DCHECK(!frame_widget_); |
| 1701 frame_widget_ = frame_widget; |
| 1702 } |
| 1703 |
| 1699 void RenderViewImpl::SetZoomLevel(double zoom_level) { | 1704 void RenderViewImpl::SetZoomLevel(double zoom_level) { |
| 1700 webview()->setZoomLevel(zoom_level); | 1705 webview()->setZoomLevel(zoom_level); |
| 1701 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); | 1706 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); |
| 1702 } | 1707 } |
| 1703 | 1708 |
| 1704 void RenderViewImpl::didCancelCompositionOnSelectionChange() { | 1709 void RenderViewImpl::didCancelCompositionOnSelectionChange() { |
| 1705 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1710 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| 1706 } | 1711 } |
| 1707 | 1712 |
| 1708 bool RenderViewImpl::handleCurrentKeyboardEvent() { | 1713 bool RenderViewImpl::handleCurrentKeyboardEvent() { |
| (...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2939 // WebPluginDelegateProxy is responsible for figuring out if this event | 2944 // WebPluginDelegateProxy is responsible for figuring out if this event |
| 2940 // applies to it or not, so inform all the delegates. | 2945 // applies to it or not, so inform all the delegates. |
| 2941 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 2946 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 2942 for (plugin_it = plugin_delegates_.begin(); | 2947 for (plugin_it = plugin_delegates_.begin(); |
| 2943 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 2948 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 2944 (*plugin_it)->ImeCompositionCompleted(text, plugin_id); | 2949 (*plugin_it)->ImeCompositionCompleted(text, plugin_id); |
| 2945 } | 2950 } |
| 2946 } | 2951 } |
| 2947 #endif // OS_MACOSX | 2952 #endif // OS_MACOSX |
| 2948 | 2953 |
| 2954 void RenderViewImpl::CloseForFrame() { |
| 2955 DCHECK(frame_widget_); |
| 2956 frame_widget_->close(); |
| 2957 frame_widget_ = nullptr; |
| 2958 } |
| 2959 |
| 2949 void RenderViewImpl::Close() { | 2960 void RenderViewImpl::Close() { |
| 2950 // We need to grab a pointer to the doomed WebView before we destroy it. | 2961 // We need to grab a pointer to the doomed WebView before we destroy it. |
| 2951 WebView* doomed = webview(); | 2962 WebView* doomed = webview(); |
| 2952 RenderWidget::Close(); | 2963 RenderWidget::Close(); |
| 2953 g_view_map.Get().erase(doomed); | 2964 g_view_map.Get().erase(doomed); |
| 2954 g_routing_id_view_map.Get().erase(routing_id_); | 2965 g_routing_id_view_map.Get().erase(routing_id_); |
| 2955 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(routing_id_)); | 2966 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(routing_id_)); |
| 2956 } | 2967 } |
| 2957 | 2968 |
| 2958 void RenderViewImpl::DidHandleKeyEvent() { | 2969 void RenderViewImpl::DidHandleKeyEvent() { |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3686 std::vector<gfx::Size> sizes; | 3697 std::vector<gfx::Size> sizes; |
| 3687 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 3698 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 3688 if (!url.isEmpty()) | 3699 if (!url.isEmpty()) |
| 3689 urls.push_back( | 3700 urls.push_back( |
| 3690 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 3701 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 3691 } | 3702 } |
| 3692 SendUpdateFaviconURL(urls); | 3703 SendUpdateFaviconURL(urls); |
| 3693 } | 3704 } |
| 3694 | 3705 |
| 3695 } // namespace content | 3706 } // namespace content |
| OLD | NEW |