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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 session_storage_namespace_id_(params->session_storage_namespace_id), | 660 session_storage_namespace_id_(params->session_storage_namespace_id), |
661 next_snapshot_id_(0) { | 661 next_snapshot_id_(0) { |
662 } | 662 } |
663 | 663 |
664 void RenderViewImpl::Initialize(RenderViewImplParams* params) { | 664 void RenderViewImpl::Initialize(RenderViewImplParams* params) { |
665 routing_id_ = params->routing_id; | 665 routing_id_ = params->routing_id; |
666 surface_id_ = params->surface_id; | 666 surface_id_ = params->surface_id; |
667 if (params->opener_id != MSG_ROUTING_NONE && params->is_renderer_created) | 667 if (params->opener_id != MSG_ROUTING_NONE && params->is_renderer_created) |
668 opener_id_ = params->opener_id; | 668 opener_id_ = params->opener_id; |
669 | 669 |
| 670 LOG(ERROR) << "RV[" << this << "]::Initialize:" |
| 671 << " routing_id:" << routing_id_ |
| 672 << ", frame_routing_id:" << params->main_frame_routing_id; |
| 673 |
670 // Ensure we start with a valid next_page_id_ from the browser. | 674 // Ensure we start with a valid next_page_id_ from the browser. |
671 DCHECK_GE(next_page_id_, 0); | 675 DCHECK_GE(next_page_id_, 0); |
672 | 676 |
673 main_render_frame_.reset(RenderFrameImpl::Create( | 677 main_render_frame_.reset(RenderFrameImpl::Create( |
674 this, params->main_frame_routing_id)); | 678 this, params->main_frame_routing_id)); |
675 // The main frame WebLocalFrame object is closed by | 679 // The main frame WebLocalFrame object is closed by |
676 // RenderFrameImpl::frameDetached(). | 680 // RenderFrameImpl::frameDetached(). |
677 WebLocalFrame* web_frame = WebLocalFrame::create(main_render_frame_.get()); | 681 WebLocalFrame* web_frame = WebLocalFrame::create(main_render_frame_.get()); |
678 main_render_frame_->SetWebFrame(web_frame); | 682 main_render_frame_->SetWebFrame(web_frame); |
679 | 683 |
680 if (params->proxy_routing_id != MSG_ROUTING_NONE) { | |
681 CHECK(params->swapped_out); | |
682 RenderFrameProxy* proxy = | |
683 RenderFrameProxy::CreateFrameProxy(params->proxy_routing_id, | |
684 params->main_frame_routing_id); | |
685 main_render_frame_->set_render_frame_proxy(proxy); | |
686 } | |
687 | |
688 webwidget_ = WebView::create(this); | 684 webwidget_ = WebView::create(this); |
689 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); | 685 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); |
690 | 686 |
691 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 687 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
692 | 688 |
693 if (command_line.HasSwitch(switches::kStatsCollectionController)) | 689 if (command_line.HasSwitch(switches::kStatsCollectionController)) |
694 stats_collection_observer_.reset(new StatsCollectionObserver(this)); | 690 stats_collection_observer_.reset(new StatsCollectionObserver(this)); |
695 | 691 |
696 #if defined(OS_ANDROID) | 692 #if defined(OS_ANDROID) |
697 const std::string region_code = | 693 const std::string region_code = |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 webview()->settings()->setCompositedScrollingForFramesEnabled( | 733 webview()->settings()->setCompositedScrollingForFramesEnabled( |
738 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); | 734 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); |
739 webview()->settings()->setUseExpandedHeuristicsForGpuRasterization( | 735 webview()->settings()->setUseExpandedHeuristicsForGpuRasterization( |
740 ShouldUseExpandedHeuristicsForGpuRasterization()); | 736 ShouldUseExpandedHeuristicsForGpuRasterization()); |
741 | 737 |
742 ApplyWebPreferences(webkit_preferences_, webview()); | 738 ApplyWebPreferences(webkit_preferences_, webview()); |
743 | 739 |
744 webview()->settings()->setAllowConnectingInsecureWebSocket( | 740 webview()->settings()->setAllowConnectingInsecureWebSocket( |
745 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); | 741 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); |
746 | 742 |
747 webview()->setMainFrame(main_render_frame_->GetWebFrame()); | 743 RenderFrameProxy* proxy = NULL; |
| 744 if (params->proxy_routing_id != MSG_ROUTING_NONE) { |
| 745 CHECK(params->swapped_out); |
| 746 proxy = RenderFrameProxy::CreateProxyForFrame( |
| 747 params->proxy_routing_id, params->main_frame_routing_id); |
| 748 main_render_frame_->set_render_frame_proxy(proxy); |
| 749 } |
| 750 |
| 751 // In --site-per-process, just use the WebRemoteFrame as the main frame. |
| 752 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess) && |
| 753 proxy) { |
| 754 webview()->setMainFrame(proxy->GetWebFrame()); |
| 755 } else { |
| 756 webview()->setMainFrame(main_render_frame_->GetWebFrame()); |
| 757 } |
748 main_render_frame_->Initialize(); | 758 main_render_frame_->Initialize(); |
749 | 759 |
750 if (switches::IsTouchDragDropEnabled()) | 760 if (switches::IsTouchDragDropEnabled()) |
751 webview()->settings()->setTouchDragDropEnabled(true); | 761 webview()->settings()->setTouchDragDropEnabled(true); |
752 | 762 |
753 if (switches::IsTouchEditingEnabled()) | 763 if (switches::IsTouchEditingEnabled()) |
754 webview()->settings()->setTouchEditingEnabled(true); | 764 webview()->settings()->setTouchEditingEnabled(true); |
755 | 765 |
756 if (!params->frame_name.empty()) | 766 if (!params->frame_name.empty()) |
757 webview()->mainFrame()->setName(params->frame_name); | 767 webview()->mainFrame()->setName(params->frame_name); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 // If we have an opener_id but we weren't created by a renderer, then | 809 // If we have an opener_id but we weren't created by a renderer, then |
800 // it's the browser asking us to set our opener to another RenderView. | 810 // it's the browser asking us to set our opener to another RenderView. |
801 if (params->opener_id != MSG_ROUTING_NONE && !params->is_renderer_created) { | 811 if (params->opener_id != MSG_ROUTING_NONE && !params->is_renderer_created) { |
802 RenderViewImpl* opener_view = FromRoutingID(params->opener_id); | 812 RenderViewImpl* opener_view = FromRoutingID(params->opener_id); |
803 if (opener_view) | 813 if (opener_view) |
804 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); | 814 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); |
805 } | 815 } |
806 | 816 |
807 // If we are initially swapped out, navigate to kSwappedOutURL. | 817 // If we are initially swapped out, navigate to kSwappedOutURL. |
808 // This ensures we are in a unique origin that others cannot script. | 818 // This ensures we are in a unique origin that others cannot script. |
809 if (is_swapped_out_) | 819 if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame()) |
810 NavigateToSwappedOutURL(webview()->mainFrame()); | 820 NavigateToSwappedOutURL(webview()->mainFrame()); |
811 } | 821 } |
812 | 822 |
813 RenderViewImpl::~RenderViewImpl() { | 823 RenderViewImpl::~RenderViewImpl() { |
814 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); | 824 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); |
815 it != disambiguation_bitmaps_.end(); | 825 it != disambiguation_bitmaps_.end(); |
816 ++it) | 826 ++it) |
817 delete it->second; | 827 delete it->second; |
818 history_page_ids_.clear(); | 828 history_page_ids_.clear(); |
819 | 829 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 if (webview()) | 1042 if (webview()) |
1033 webview()->transferActiveWheelFlingAnimation(params); | 1043 webview()->transferActiveWheelFlingAnimation(params); |
1034 } | 1044 } |
1035 | 1045 |
1036 bool RenderViewImpl::HasIMETextFocus() { | 1046 bool RenderViewImpl::HasIMETextFocus() { |
1037 return GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; | 1047 return GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; |
1038 } | 1048 } |
1039 | 1049 |
1040 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { | 1050 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
1041 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 1051 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
1042 if (main_frame) | 1052 if (main_frame && main_frame->isWebLocalFrame()) |
1043 GetContentClient()->SetActiveURL(main_frame->document().url()); | 1053 GetContentClient()->SetActiveURL(main_frame->document().url()); |
1044 | 1054 |
1045 ObserverListBase<RenderViewObserver>::Iterator it(observers_); | 1055 ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
1046 RenderViewObserver* observer; | 1056 RenderViewObserver* observer; |
1047 while ((observer = it.GetNext()) != NULL) | 1057 while ((observer = it.GetNext()) != NULL) |
1048 if (observer->OnMessageReceived(message)) | 1058 if (observer->OnMessageReceived(message)) |
1049 return true; | 1059 return true; |
1050 | 1060 |
1051 bool handled = true; | 1061 bool handled = true; |
1052 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) | 1062 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 } | 1960 } |
1951 | 1961 |
1952 const std::string& RenderViewImpl::GetAcceptLanguages() const { | 1962 const std::string& RenderViewImpl::GetAcceptLanguages() const { |
1953 return renderer_preferences_.accept_languages; | 1963 return renderer_preferences_.accept_languages; |
1954 } | 1964 } |
1955 | 1965 |
1956 void RenderViewImpl::didCreateDataSource(WebLocalFrame* frame, | 1966 void RenderViewImpl::didCreateDataSource(WebLocalFrame* frame, |
1957 WebDataSource* ds) { | 1967 WebDataSource* ds) { |
1958 bool content_initiated = !pending_navigation_params_.get(); | 1968 bool content_initiated = !pending_navigation_params_.get(); |
1959 | 1969 |
| 1970 LOG(ERROR) << "RV[" << this << "]::didCreateDataSource:" |
| 1971 << " frame:" << frame |
| 1972 << " url:" << ds->request().url(); |
1960 // Make sure any previous redirect URLs end up in our new data source. | 1973 // Make sure any previous redirect URLs end up in our new data source. |
1961 if (pending_navigation_params_.get()) { | 1974 if (pending_navigation_params_.get()) { |
1962 for (std::vector<GURL>::const_iterator i = | 1975 for (std::vector<GURL>::const_iterator i = |
1963 pending_navigation_params_->redirects.begin(); | 1976 pending_navigation_params_->redirects.begin(); |
1964 i != pending_navigation_params_->redirects.end(); ++i) { | 1977 i != pending_navigation_params_->redirects.end(); ++i) { |
1965 ds->appendRedirect(*i); | 1978 ds->appendRedirect(*i); |
1966 } | 1979 } |
1967 } | 1980 } |
1968 | 1981 |
1969 DocumentState* document_state = DocumentState::FromDataSource(ds); | 1982 DocumentState* document_state = DocumentState::FromDataSource(ds); |
1970 if (!document_state) { | 1983 if (!document_state) { |
1971 document_state = new DocumentState; | 1984 document_state = new DocumentState; |
1972 ds->setExtraData(document_state); | 1985 ds->setExtraData(document_state); |
1973 if (!content_initiated) | 1986 if (!content_initiated) |
1974 PopulateDocumentStateFromPending(document_state); | 1987 PopulateDocumentStateFromPending(document_state); |
1975 } | 1988 } |
1976 | 1989 |
1977 // Carry over the user agent override flag, if it exists. | 1990 // Carry over the user agent override flag, if it exists. |
1978 if (content_initiated && webview() && webview()->mainFrame() && | 1991 LOG(ERROR) << "RV[" << this << "]::didCreateDataSource:" |
| 1992 << " frame:" << frame |
| 1993 << " mainFrame is local: " << webview()->mainFrame()->isWebLocalFrame(); |
| 1994 if (content_initiated && webview() && |
| 1995 webview()->mainFrame() && |
| 1996 webview()->mainFrame()->isWebLocalFrame() && |
1979 webview()->mainFrame()->dataSource()) { | 1997 webview()->mainFrame()->dataSource()) { |
1980 DocumentState* old_document_state = | 1998 DocumentState* old_document_state = |
1981 DocumentState::FromDataSource(webview()->mainFrame()->dataSource()); | 1999 DocumentState::FromDataSource(webview()->mainFrame()->dataSource()); |
1982 if (old_document_state) { | 2000 if (old_document_state) { |
1983 InternalDocumentStateData* internal_data = | 2001 InternalDocumentStateData* internal_data = |
1984 InternalDocumentStateData::FromDocumentState(document_state); | 2002 InternalDocumentStateData::FromDocumentState(document_state); |
1985 InternalDocumentStateData* old_internal_data = | 2003 InternalDocumentStateData* old_internal_data = |
1986 InternalDocumentStateData::FromDocumentState(old_document_state); | 2004 InternalDocumentStateData::FromDocumentState(old_document_state); |
1987 internal_data->set_is_overriding_user_agent( | 2005 internal_data->set_is_overriding_user_agent( |
1988 old_internal_data->is_overriding_user_agent()); | 2006 old_internal_data->is_overriding_user_agent()); |
(...skipping 15 matching lines...) Expand all Loading... |
2004 // page. We are early enough in the request process here that we | 2022 // page. We are early enough in the request process here that we |
2005 // can still see the DocumentState of the previous page and set | 2023 // can still see the DocumentState of the previous page and set |
2006 // this value appropriately. | 2024 // this value appropriately. |
2007 // TODO(gavinp): catch the important case of navigation in a new | 2025 // TODO(gavinp): catch the important case of navigation in a new |
2008 // renderer process. | 2026 // renderer process. |
2009 if (webview()) { | 2027 if (webview()) { |
2010 if (WebFrame* old_frame = webview()->mainFrame()) { | 2028 if (WebFrame* old_frame = webview()->mainFrame()) { |
2011 const WebURLRequest& original_request = ds->originalRequest(); | 2029 const WebURLRequest& original_request = ds->originalRequest(); |
2012 const GURL referrer( | 2030 const GURL referrer( |
2013 original_request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2031 original_request.httpHeaderField(WebString::fromUTF8("Referer"))); |
2014 if (!referrer.is_empty() && | 2032 if (!referrer.is_empty() && old_frame->isWebLocalFrame() && |
2015 DocumentState::FromDataSource( | 2033 DocumentState::FromDataSource( |
2016 old_frame->dataSource())->was_prefetcher()) { | 2034 old_frame->dataSource())->was_prefetcher()) { |
2017 for (; old_frame; old_frame = old_frame->traverseNext(false)) { | 2035 for (; old_frame; old_frame = old_frame->traverseNext(false)) { |
2018 WebDataSource* old_frame_ds = old_frame->dataSource(); | 2036 WebDataSource* old_frame_ds = old_frame->dataSource(); |
2019 if (old_frame_ds && referrer == GURL(old_frame_ds->request().url())) { | 2037 if (old_frame_ds && referrer == GURL(old_frame_ds->request().url())) { |
2020 document_state->set_was_referred_by_prefetcher(true); | 2038 document_state->set_was_referred_by_prefetcher(true); |
2021 break; | 2039 break; |
2022 } | 2040 } |
2023 } | 2041 } |
2024 } | 2042 } |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2351 if (!webview()) | 2369 if (!webview()) |
2352 return; | 2370 return; |
2353 SendUpdateState(history_controller_->GetCurrentEntry()); | 2371 SendUpdateState(history_controller_->GetCurrentEntry()); |
2354 } | 2372 } |
2355 | 2373 |
2356 blink::WebPlugin* RenderViewImpl::GetWebPluginForFind() { | 2374 blink::WebPlugin* RenderViewImpl::GetWebPluginForFind() { |
2357 if (!webview()) | 2375 if (!webview()) |
2358 return NULL; | 2376 return NULL; |
2359 | 2377 |
2360 WebFrame* main_frame = webview()->mainFrame(); | 2378 WebFrame* main_frame = webview()->mainFrame(); |
2361 if (main_frame->document().isPluginDocument()) | 2379 if (main_frame->isWebLocalFrame() && |
| 2380 main_frame->document().isPluginDocument()) |
2362 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); | 2381 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
2363 | 2382 |
2364 #if defined(ENABLE_PLUGINS) | 2383 #if defined(ENABLE_PLUGINS) |
2365 if (plugin_find_handler_) | 2384 if (plugin_find_handler_) |
2366 return plugin_find_handler_->container()->plugin(); | 2385 return plugin_find_handler_->container()->plugin(); |
2367 #endif | 2386 #endif |
2368 | 2387 |
2369 return NULL; | 2388 return NULL; |
2370 } | 2389 } |
2371 | 2390 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2856 } | 2875 } |
2857 #endif // defined(USE_DEFAULT_RENDER_THEME) | 2876 #endif // defined(USE_DEFAULT_RENDER_THEME) |
2858 | 2877 |
2859 if (RenderThreadImpl::current()) // Will be NULL during unit tests. | 2878 if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
2860 RenderThreadImpl::current()->SetFlingCurveParameters( | 2879 RenderThreadImpl::current()->SetFlingCurveParameters( |
2861 renderer_prefs.touchpad_fling_profile, | 2880 renderer_prefs.touchpad_fling_profile, |
2862 renderer_prefs.touchscreen_fling_profile); | 2881 renderer_prefs.touchscreen_fling_profile); |
2863 | 2882 |
2864 // If the zoom level for this page matches the old zoom default, and this | 2883 // If the zoom level for this page matches the old zoom default, and this |
2865 // is not a plugin, update the zoom level to match the new default. | 2884 // is not a plugin, update the zoom level to match the new default. |
2866 if (webview() && !webview()->mainFrame()->document().isPluginDocument() && | 2885 if (webview() && webview()->mainFrame()->isWebLocalFrame() && |
| 2886 !webview()->mainFrame()->document().isPluginDocument() && |
2867 !ZoomValuesEqual(old_zoom_level, | 2887 !ZoomValuesEqual(old_zoom_level, |
2868 renderer_preferences_.default_zoom_level) && | 2888 renderer_preferences_.default_zoom_level) && |
2869 ZoomValuesEqual(webview()->zoomLevel(), old_zoom_level)) { | 2889 ZoomValuesEqual(webview()->zoomLevel(), old_zoom_level)) { |
2870 webview()->setZoomLevel(renderer_preferences_.default_zoom_level); | 2890 webview()->setZoomLevel(renderer_preferences_.default_zoom_level); |
2871 zoomLevelChanged(); | 2891 zoomLevelChanged(); |
2872 } | 2892 } |
2873 | 2893 |
2874 if (webview() && | 2894 if (webview() && |
2875 old_accept_languages != renderer_preferences_.accept_languages) { | 2895 old_accept_languages != renderer_preferences_.accept_languages) { |
2876 webview()->acceptLanguagesChanged(); | 2896 webview()->acceptLanguagesChanged(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2958 webstring_paths, | 2978 webstring_paths, |
2959 local_directory_name.AsUTF16Unsafe()); | 2979 local_directory_name.AsUTF16Unsafe()); |
2960 } | 2980 } |
2961 | 2981 |
2962 void RenderViewImpl::OnSuppressDialogsUntilSwapOut() { | 2982 void RenderViewImpl::OnSuppressDialogsUntilSwapOut() { |
2963 // Don't show any more dialogs until we finish OnSwapOut. | 2983 // Don't show any more dialogs until we finish OnSwapOut. |
2964 suppress_dialogs_until_swap_out_ = true; | 2984 suppress_dialogs_until_swap_out_ = true; |
2965 } | 2985 } |
2966 | 2986 |
2967 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { | 2987 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { |
| 2988 LOG(ERROR) << "RV[" << this << "]::NavigateToSwappedOutURL: " << is_swapped_ou
t_; |
2968 // We use loadRequest instead of loadHTMLString because the former commits | 2989 // We use loadRequest instead of loadHTMLString because the former commits |
2969 // synchronously. Otherwise a new navigation can interrupt the navigation | 2990 // synchronously. Otherwise a new navigation can interrupt the navigation |
2970 // to kSwappedOutURL. If that happens to be to the page we had been | 2991 // to kSwappedOutURL. If that happens to be to the page we had been |
2971 // showing, then WebKit will never send a commit and we'll be left spinning. | 2992 // showing, then WebKit will never send a commit and we'll be left spinning. |
2972 // TODO(creis): Until we move this to RenderFrame, we may call this from a | 2993 // TODO(creis): Until we move this to RenderFrame, we may call this from a |
2973 // swapped out RenderFrame while our own is_swapped_out_ is false. | 2994 // swapped out RenderFrame while our own is_swapped_out_ is false. |
2974 RenderFrameImpl* rf = RenderFrameImpl::FromWebFrame(frame); | 2995 RenderFrameImpl* rf = RenderFrameImpl::FromWebFrame(frame); |
2975 CHECK(is_swapped_out_ || rf->is_swapped_out()); | 2996 CHECK(is_swapped_out_ || rf->is_swapped_out()); |
2976 GURL swappedOutURL(kSwappedOutURL); | 2997 GURL swappedOutURL(kSwappedOutURL); |
2977 WebURLRequest request(swappedOutURL); | 2998 WebURLRequest request(swappedOutURL); |
2978 frame->loadRequest(request); | 2999 if (frame->isWebLocalFrame()) |
| 3000 frame->loadRequest(request); |
2979 } | 3001 } |
2980 | 3002 |
2981 void RenderViewImpl::OnClosePage() { | 3003 void RenderViewImpl::OnClosePage() { |
2982 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); | 3004 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); |
2983 // TODO(creis): We'd rather use webview()->Close() here, but that currently | 3005 // TODO(creis): We'd rather use webview()->Close() here, but that currently |
2984 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs | 3006 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
2985 // in the onunload handler from appearing. For now, we're bypassing that and | 3007 // in the onunload handler from appearing. For now, we're bypassing that and |
2986 // calling the FrameLoader's CloseURL method directly. This should be | 3008 // calling the FrameLoader's CloseURL method directly. This should be |
2987 // revisited to avoid having two ways to close a page. Having a single way | 3009 // revisited to avoid having two ways to close a page. Having a single way |
2988 // to close that can run onunload is also useful for fixing | 3010 // to close that can run onunload is also useful for fixing |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3070 (*i)->ViewFlushedPaint(); | 3092 (*i)->ViewFlushedPaint(); |
3071 } | 3093 } |
3072 #endif | 3094 #endif |
3073 | 3095 |
3074 // If the RenderWidget is closing down then early-exit, otherwise we'll crash. | 3096 // If the RenderWidget is closing down then early-exit, otherwise we'll crash. |
3075 // See crbug.com/112921. | 3097 // See crbug.com/112921. |
3076 if (!webview()) | 3098 if (!webview()) |
3077 return; | 3099 return; |
3078 | 3100 |
3079 WebFrame* main_frame = webview()->mainFrame(); | 3101 WebFrame* main_frame = webview()->mainFrame(); |
| 3102 for (WebFrame* frame = main_frame; frame; frame = frame->traverseNext(false))
{ |
| 3103 if (frame->isWebLocalFrame()) |
| 3104 main_frame = frame; |
| 3105 } |
3080 | 3106 |
3081 // If we have a provisional frame we are between the start and commit stages | 3107 // If we have a provisional frame we are between the start and commit stages |
3082 // of loading and we don't want to save stats. | 3108 // of loading and we don't want to save stats. |
3083 if (!main_frame->provisionalDataSource()) { | 3109 if (!main_frame->provisionalDataSource()) { |
3084 WebDataSource* ds = main_frame->dataSource(); | 3110 WebDataSource* ds = main_frame->dataSource(); |
3085 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3111 DocumentState* document_state = DocumentState::FromDataSource(ds); |
3086 InternalDocumentStateData* data = | 3112 InternalDocumentStateData* data = |
3087 InternalDocumentStateData::FromDocumentState(document_state); | 3113 InternalDocumentStateData::FromDocumentState(document_state); |
3088 if (data->did_first_visually_non_empty_layout() && | 3114 if (data->did_first_visually_non_empty_layout() && |
3089 !data->did_first_visually_non_empty_paint()) { | 3115 !data->did_first_visually_non_empty_paint()) { |
3090 data->set_did_first_visually_non_empty_paint(true); | 3116 data->set_did_first_visually_non_empty_paint(true); |
3091 Send(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_)); | 3117 Send(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_)); |
3092 } | 3118 } |
3093 | 3119 |
3094 // TODO(jar): The following code should all be inside a method, probably in | 3120 // TODO(jar): The following code should all be inside a method, probably in |
3095 // NavigatorState. | 3121 // NavigatorState. |
3096 Time now = Time::Now(); | 3122 Time now = Time::Now(); |
3097 if (document_state->first_paint_time().is_null()) { | 3123 if (document_state->first_paint_time().is_null()) { |
3098 document_state->set_first_paint_time(now); | 3124 document_state->set_first_paint_time(now); |
3099 } | 3125 } |
3100 if (document_state->first_paint_after_load_time().is_null() && | 3126 if (document_state->first_paint_after_load_time().is_null() && |
3101 !document_state->finish_load_time().is_null()) { | 3127 !document_state->finish_load_time().is_null()) { |
3102 document_state->set_first_paint_after_load_time(now); | 3128 document_state->set_first_paint_after_load_time(now); |
3103 } | 3129 } |
3104 } | 3130 } |
3105 } | 3131 } |
3106 | 3132 |
3107 gfx::Vector2d RenderViewImpl::GetScrollOffset() { | 3133 gfx::Vector2d RenderViewImpl::GetScrollOffset() { |
3108 WebSize scroll_offset = webview()->mainFrame()->scrollOffset(); | 3134 WebFrame* main_frame = webview()->mainFrame(); |
| 3135 for (WebFrame* frame = main_frame; frame; frame = frame->traverseNext(false))
{ |
| 3136 if (frame->isWebLocalFrame()) |
| 3137 main_frame = frame; |
| 3138 } |
| 3139 |
| 3140 WebSize scroll_offset = main_frame->scrollOffset(); |
3109 return gfx::Vector2d(scroll_offset.width, scroll_offset.height); | 3141 return gfx::Vector2d(scroll_offset.width, scroll_offset.height); |
3110 } | 3142 } |
3111 | 3143 |
3112 void RenderViewImpl::OnClearFocusedElement() { | 3144 void RenderViewImpl::OnClearFocusedElement() { |
3113 if (webview()) | 3145 if (webview()) |
3114 webview()->clearFocusedElement(); | 3146 webview()->clearFocusedElement(); |
3115 } | 3147 } |
3116 | 3148 |
3117 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { | 3149 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
3118 if (webview()) | 3150 if (webview()) |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3302 for (plugin_it = plugin_delegates_.begin(); | 3334 for (plugin_it = plugin_delegates_.begin(); |
3303 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 3335 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
3304 (*plugin_it)->SetContainerVisibility(true); | 3336 (*plugin_it)->SetContainerVisibility(true); |
3305 } | 3337 } |
3306 #endif // OS_MACOSX | 3338 #endif // OS_MACOSX |
3307 #endif // ENABLE_PLUGINS | 3339 #endif // ENABLE_PLUGINS |
3308 } | 3340 } |
3309 | 3341 |
3310 GURL RenderViewImpl::GetURLForGraphicsContext3D() { | 3342 GURL RenderViewImpl::GetURLForGraphicsContext3D() { |
3311 DCHECK(webview()); | 3343 DCHECK(webview()); |
3312 if (webview()->mainFrame()) | 3344 if (webview()->mainFrame()->isWebLocalFrame()) |
3313 return GURL(webview()->mainFrame()->document().url()); | 3345 return GURL(webview()->mainFrame()->document().url()); |
3314 else | 3346 else |
3315 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); | 3347 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); |
3316 } | 3348 } |
3317 | 3349 |
3318 void RenderViewImpl::OnSetFocus(bool enable) { | 3350 void RenderViewImpl::OnSetFocus(bool enable) { |
3319 RenderWidget::OnSetFocus(enable); | 3351 RenderWidget::OnSetFocus(enable); |
3320 | 3352 |
3321 #if defined(ENABLE_PLUGINS) | 3353 #if defined(ENABLE_PLUGINS) |
3322 if (webview() && webview()->isActive()) { | 3354 if (webview() && webview()->isActive()) { |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4013 std::vector<gfx::Size> sizes; | 4045 std::vector<gfx::Size> sizes; |
4014 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4046 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4015 if (!url.isEmpty()) | 4047 if (!url.isEmpty()) |
4016 urls.push_back( | 4048 urls.push_back( |
4017 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4049 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4018 } | 4050 } |
4019 SendUpdateFaviconURL(urls); | 4051 SendUpdateFaviconURL(urls); |
4020 } | 4052 } |
4021 | 4053 |
4022 } // namespace content | 4054 } // namespace content |
OLD | NEW |