OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 // CommitNavigation IPC, and then back to the browser again in the | 497 // CommitNavigation IPC, and then back to the browser again in the |
498 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. | 498 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. |
499 base::TimeTicks ui_timestamp = | 499 base::TimeTicks ui_timestamp = |
500 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); | 500 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); |
501 FrameMsg_UILoadMetricsReportType::Value report_type = | 501 FrameMsg_UILoadMetricsReportType::Value report_type = |
502 static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 502 static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
503 request->inputPerfMetricReportPolicy()); | 503 request->inputPerfMetricReportPolicy()); |
504 return CommonNavigationParams( | 504 return CommonNavigationParams( |
505 request->url(), referrer, extra_data->transition_type(), | 505 request->url(), referrer, extra_data->transition_type(), |
506 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, | 506 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, |
507 ui_timestamp, report_type, GURL(), GURL()); | 507 ui_timestamp, report_type, GURL(), GURL(), LOFI_UNSPECIFIED); |
508 } | 508 } |
509 | 509 |
510 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) | 510 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) |
511 media::Context3D GetSharedMainThreadContext3D() { | 511 media::Context3D GetSharedMainThreadContext3D() { |
512 cc::ContextProvider* provider = | 512 cc::ContextProvider* provider = |
513 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 513 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
514 if (!provider) | 514 if (!provider) |
515 return media::Context3D(); | 515 return media::Context3D(); |
516 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 516 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
517 } | 517 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 #endif | 734 #endif |
735 has_played_media_(false), | 735 has_played_media_(false), |
736 devtools_agent_(nullptr), | 736 devtools_agent_(nullptr), |
737 geolocation_dispatcher_(NULL), | 737 geolocation_dispatcher_(NULL), |
738 push_messaging_dispatcher_(NULL), | 738 push_messaging_dispatcher_(NULL), |
739 presentation_dispatcher_(NULL), | 739 presentation_dispatcher_(NULL), |
740 screen_orientation_dispatcher_(NULL), | 740 screen_orientation_dispatcher_(NULL), |
741 manifest_manager_(NULL), | 741 manifest_manager_(NULL), |
742 accessibility_mode_(AccessibilityModeOff), | 742 accessibility_mode_(AccessibilityModeOff), |
743 renderer_accessibility_(NULL), | 743 renderer_accessibility_(NULL), |
| 744 is_using_lofi_(false), |
744 weak_factory_(this) { | 745 weak_factory_(this) { |
745 std::pair<RoutingIDFrameMap::iterator, bool> result = | 746 std::pair<RoutingIDFrameMap::iterator, bool> result = |
746 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 747 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
747 CHECK(result.second) << "Inserting a duplicate item."; | 748 CHECK(result.second) << "Inserting a duplicate item."; |
748 | 749 |
749 RenderThread::Get()->AddRoute(routing_id_, this); | 750 RenderThread::Get()->AddRoute(routing_id_, this); |
750 | 751 |
751 render_view_->RegisterRenderFrame(this); | 752 render_view_->RegisterRenderFrame(this); |
752 | 753 |
753 // Everything below subclasses RenderFrameObserver and is automatically | 754 // Everything below subclasses RenderFrameObserver and is automatically |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 std::make_pair(web_frame, this)); | 809 std::make_pair(web_frame, this)); |
809 CHECK(result.second) << "Inserting a duplicate item."; | 810 CHECK(result.second) << "Inserting a duplicate item."; |
810 | 811 |
811 frame_ = web_frame; | 812 frame_ = web_frame; |
812 } | 813 } |
813 | 814 |
814 void RenderFrameImpl::Initialize() { | 815 void RenderFrameImpl::Initialize() { |
815 is_main_frame_ = !frame_->parent(); | 816 is_main_frame_ = !frame_->parent(); |
816 is_local_root_ = is_main_frame_ || frame_->parent()->isWebRemoteFrame(); | 817 is_local_root_ = is_main_frame_ || frame_->parent()->isWebRemoteFrame(); |
817 | 818 |
| 819 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( |
| 820 frame_->parent()); |
| 821 if (parent_frame) |
| 822 is_using_lofi_ = parent_frame->IsUsingLoFi(); |
| 823 |
818 bool is_tracing = false; | 824 bool is_tracing = false; |
819 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing); | 825 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing); |
820 if (is_tracing) { | 826 if (is_tracing) { |
821 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); | 827 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); |
822 TRACE_EVENT2("navigation", "RenderFrameImpl::Initialize", | 828 TRACE_EVENT2("navigation", "RenderFrameImpl::Initialize", |
823 "id", routing_id_, | 829 "id", routing_id_, |
824 "parent", parent_id); | 830 "parent", parent_id); |
825 } | 831 } |
826 | 832 |
827 #if defined(ENABLE_PLUGINS) | 833 #if defined(ENABLE_PLUGINS) |
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2026 ServiceRegistryJsWrapper::kModuleName, | 2032 ServiceRegistryJsWrapper::kModuleName, |
2027 ServiceRegistryJsWrapper::Create(isolate, &service_registry_).ToV8()); | 2033 ServiceRegistryJsWrapper::Create(isolate, &service_registry_).ToV8()); |
2028 } | 2034 } |
2029 | 2035 |
2030 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, | 2036 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, |
2031 const std::string& message) { | 2037 const std::string& message) { |
2032 if (devtools_agent_) | 2038 if (devtools_agent_) |
2033 devtools_agent_->AddMessageToConsole(level, message); | 2039 devtools_agent_->AddMessageToConsole(level, message); |
2034 } | 2040 } |
2035 | 2041 |
| 2042 bool RenderFrameImpl::IsUsingLoFi() const { |
| 2043 return is_using_lofi_; |
| 2044 } |
| 2045 |
2036 // blink::WebFrameClient implementation ---------------------------------------- | 2046 // blink::WebFrameClient implementation ---------------------------------------- |
2037 | 2047 |
2038 blink::WebPlugin* RenderFrameImpl::createPlugin( | 2048 blink::WebPlugin* RenderFrameImpl::createPlugin( |
2039 blink::WebLocalFrame* frame, | 2049 blink::WebLocalFrame* frame, |
2040 const blink::WebPluginParams& params) { | 2050 const blink::WebPluginParams& params) { |
2041 DCHECK_EQ(frame_, frame); | 2051 DCHECK_EQ(frame_, frame); |
2042 blink::WebPlugin* plugin = NULL; | 2052 blink::WebPlugin* plugin = NULL; |
2043 if (GetContentClient()->renderer()->OverrideCreatePlugin( | 2053 if (GetContentClient()->renderer()->OverrideCreatePlugin( |
2044 this, frame, params, &plugin)) { | 2054 this, frame, params, &plugin)) { |
2045 return plugin; | 2055 return plugin; |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2721 const blink::WebHistoryItem& item, | 2731 const blink::WebHistoryItem& item, |
2722 blink::WebHistoryCommitType commit_type) { | 2732 blink::WebHistoryCommitType commit_type) { |
2723 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", | 2733 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", |
2724 "id", routing_id_, | 2734 "id", routing_id_, |
2725 "url", GetLoadingUrl().possibly_invalid_spec()); | 2735 "url", GetLoadingUrl().possibly_invalid_spec()); |
2726 DCHECK(!frame_ || frame_ == frame); | 2736 DCHECK(!frame_ || frame_ == frame); |
2727 DocumentState* document_state = | 2737 DocumentState* document_state = |
2728 DocumentState::FromDataSource(frame->dataSource()); | 2738 DocumentState::FromDataSource(frame->dataSource()); |
2729 NavigationStateImpl* navigation_state = | 2739 NavigationStateImpl* navigation_state = |
2730 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 2740 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 2741 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse( |
| 2742 frame->dataSource()->response()); |
| 2743 is_using_lofi_ = extra_data && extra_data->is_using_lofi(); |
2731 | 2744 |
2732 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 2745 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
2733 RenderFrameProxy* proxy = | 2746 RenderFrameProxy* proxy = |
2734 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 2747 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
2735 CHECK(proxy); | 2748 CHECK(proxy); |
2736 proxy->web_frame()->swap(frame_); | 2749 proxy->web_frame()->swap(frame_); |
2737 proxy_routing_id_ = MSG_ROUTING_NONE; | 2750 proxy_routing_id_ = MSG_ROUTING_NONE; |
2738 | 2751 |
2739 // If this is the main frame going from a remote frame to a local frame, | 2752 // If this is the main frame going from a remote frame to a local frame, |
2740 // it needs to set RenderViewImpl's pointer for the main frame to itself | 2753 // it needs to set RenderViewImpl's pointer for the main frame to itself |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3381 extra_data->set_allow_download( | 3394 extra_data->set_allow_download( |
3382 navigation_state->common_params().allow_download); | 3395 navigation_state->common_params().allow_download); |
3383 extra_data->set_transition_type(transition_type); | 3396 extra_data->set_transition_type(transition_type); |
3384 extra_data->set_should_replace_current_entry(should_replace_current_entry); | 3397 extra_data->set_should_replace_current_entry(should_replace_current_entry); |
3385 extra_data->set_transferred_request_child_id( | 3398 extra_data->set_transferred_request_child_id( |
3386 navigation_state->start_params().transferred_request_child_id); | 3399 navigation_state->start_params().transferred_request_child_id); |
3387 extra_data->set_transferred_request_request_id( | 3400 extra_data->set_transferred_request_request_id( |
3388 navigation_state->start_params().transferred_request_request_id); | 3401 navigation_state->start_params().transferred_request_request_id); |
3389 extra_data->set_service_worker_provider_id(provider_id); | 3402 extra_data->set_service_worker_provider_id(provider_id); |
3390 extra_data->set_stream_override(stream_override.Pass()); | 3403 extra_data->set_stream_override(stream_override.Pass()); |
| 3404 // TODO(megjablon): Set the navigation params for single image loads to |
| 3405 // LOFI_OFF and remove the dependency on ReloadBypassingCache. |
| 3406 if (request.cachePolicy() == WebURLRequest::ReloadBypassingCache) |
| 3407 extra_data->set_lofi_state(LOFI_OFF); |
| 3408 else if (is_main_frame_ && !navigation_state->request_committed()) |
| 3409 extra_data->set_lofi_state(navigation_state->common_params().lofi_state); |
| 3410 else |
| 3411 extra_data->set_lofi_state(is_using_lofi_ ? LOFI_ON : LOFI_OFF); |
3391 request.setExtraData(extra_data); | 3412 request.setExtraData(extra_data); |
3392 | 3413 |
3393 // TODO(creis): Update prefetching to work with out-of-process iframes. | 3414 // TODO(creis): Update prefetching to work with out-of-process iframes. |
3394 WebFrame* top_frame = frame->top(); | 3415 WebFrame* top_frame = frame->top(); |
3395 if (top_frame && top_frame->isWebLocalFrame()) { | 3416 if (top_frame && top_frame->isWebLocalFrame()) { |
3396 DocumentState* top_document_state = | 3417 DocumentState* top_document_state = |
3397 DocumentState::FromDataSource(top_frame->dataSource()); | 3418 DocumentState::FromDataSource(top_frame->dataSource()); |
3398 if (top_document_state) { | 3419 if (top_document_state) { |
3399 // TODO(gavinp): separate out prefetching and prerender field trials | 3420 // TODO(gavinp): separate out prefetching and prerender field trials |
3400 // if the rel=prerender rel type is sticking around. | 3421 // if the rel=prerender rel type is sticking around. |
(...skipping 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5208 mojo::ServiceProviderPtr service_provider; | 5229 mojo::ServiceProviderPtr service_provider; |
5209 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 5230 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
5210 request->url = mojo::String::From(url); | 5231 request->url = mojo::String::From(url); |
5211 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), | 5232 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), |
5212 nullptr, nullptr, | 5233 nullptr, nullptr, |
5213 base::Bind(&OnGotContentHandlerID)); | 5234 base::Bind(&OnGotContentHandlerID)); |
5214 return service_provider.Pass(); | 5235 return service_provider.Pass(); |
5215 } | 5236 } |
5216 | 5237 |
5217 } // namespace content | 5238 } // namespace content |
OLD | NEW |