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 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 original_request.httpHeaderField(WebString::fromUTF8("Referer"))), | 1444 original_request.httpHeaderField(WebString::fromUTF8("Referer"))), |
1445 GetReferrerPolicyFromRequest(frame, original_request)); | 1445 GetReferrerPolicyFromRequest(frame, original_request)); |
1446 } | 1446 } |
1447 | 1447 |
1448 string16 method = request.httpMethod(); | 1448 string16 method = request.httpMethod(); |
1449 if (EqualsASCII(method, "POST")) { | 1449 if (EqualsASCII(method, "POST")) { |
1450 params.is_post = true; | 1450 params.is_post = true; |
1451 params.post_id = ExtractPostId(item); | 1451 params.post_id = ExtractPostId(item); |
1452 } | 1452 } |
1453 | 1453 |
| 1454 // Send the user agent override back. |
| 1455 params.is_overriding_user_agent = |
| 1456 document_state->is_overriding_user_agent(); |
| 1457 |
1454 // Save some histogram data so we can compute the average memory used per | 1458 // Save some histogram data so we can compute the average memory used per |
1455 // page load of the glyphs. | 1459 // page load of the glyphs. |
1456 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", | 1460 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
1457 webkit_glue::GetGlyphPageCount()); | 1461 webkit_glue::GetGlyphPageCount()); |
1458 | 1462 |
1459 // This message needs to be sent before any of allowScripts(), | 1463 // This message needs to be sent before any of allowScripts(), |
1460 // allowImages(), allowPlugins() is called for the new page, so that when | 1464 // allowImages(), allowPlugins() is called for the new page, so that when |
1461 // these functions send a ViewHostMsg_ContentBlocked message, it arrives | 1465 // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
1462 // after the ViewHostMsg_FrameNavigate message. | 1466 // after the ViewHostMsg_FrameNavigate message. |
1463 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); | 1467 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2729 bool content_initiated = !pending_navigation_params_.get(); | 2733 bool content_initiated = !pending_navigation_params_.get(); |
2730 | 2734 |
2731 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2735 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2732 if (!document_state) { | 2736 if (!document_state) { |
2733 document_state = new DocumentState; | 2737 document_state = new DocumentState; |
2734 ds->setExtraData(document_state); | 2738 ds->setExtraData(document_state); |
2735 if (!content_initiated) | 2739 if (!content_initiated) |
2736 PopulateDocumentStateFromPending(document_state); | 2740 PopulateDocumentStateFromPending(document_state); |
2737 } | 2741 } |
2738 | 2742 |
| 2743 // Carry over the user agent override flag, if it exists. |
| 2744 if (content_initiated && webview() && webview()->mainFrame() && |
| 2745 webview()->mainFrame()->dataSource()) { |
| 2746 DocumentState* old_document_state = |
| 2747 DocumentState::FromDataSource(webview()->mainFrame()->dataSource()); |
| 2748 if (old_document_state) { |
| 2749 document_state->set_is_overriding_user_agent( |
| 2750 old_document_state->is_overriding_user_agent()); |
| 2751 } |
| 2752 } |
| 2753 |
2739 // The rest of RenderView assumes that a WebDataSource will always have a | 2754 // The rest of RenderView assumes that a WebDataSource will always have a |
2740 // non-null NavigationState. | 2755 // non-null NavigationState. |
2741 if (content_initiated) | 2756 if (content_initiated) |
2742 document_state->set_navigation_state( | 2757 document_state->set_navigation_state( |
2743 NavigationState::CreateContentInitiated()); | 2758 NavigationState::CreateContentInitiated()); |
2744 else { | 2759 else { |
2745 document_state->set_navigation_state(CreateNavigationStateFromPending()); | 2760 document_state->set_navigation_state(CreateNavigationStateFromPending()); |
2746 pending_navigation_params_.reset(); | 2761 pending_navigation_params_.reset(); |
2747 } | 2762 } |
2748 | 2763 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2812 } | 2827 } |
2813 | 2828 |
2814 if (IsReload(params)) | 2829 if (IsReload(params)) |
2815 document_state->set_load_type(DocumentState::RELOAD); | 2830 document_state->set_load_type(DocumentState::RELOAD); |
2816 else if (!params.state.empty()) | 2831 else if (!params.state.empty()) |
2817 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 2832 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
2818 else | 2833 else |
2819 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 2834 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
2820 | 2835 |
2821 document_state->set_referrer_policy(params.referrer.policy); | 2836 document_state->set_referrer_policy(params.referrer.policy); |
| 2837 document_state->set_is_overriding_user_agent(params.is_overriding_user_agent); |
2822 } | 2838 } |
2823 | 2839 |
2824 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { | 2840 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { |
2825 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); | 2841 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
2826 NavigationState* navigation_state = NULL; | 2842 NavigationState* navigation_state = NULL; |
2827 | 2843 |
2828 // A navigation resulting from loading a javascript URL should not be treated | 2844 // A navigation resulting from loading a javascript URL should not be treated |
2829 // as a browser initiated event. Instead, we want it to look as if the page | 2845 // as a browser initiated event. Instead, we want it to look as if the page |
2830 // initiated any load resulting from JS execution. | 2846 // initiated any load resulting from JS execution. |
2831 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { | 2847 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3707 | 3723 |
3708 Send(new ViewHostMsg_RouteMessageEvent(routing_id_, params)); | 3724 Send(new ViewHostMsg_RouteMessageEvent(routing_id_, params)); |
3709 return true; | 3725 return true; |
3710 } | 3726 } |
3711 | 3727 |
3712 void RenderViewImpl::willOpenSocketStream( | 3728 void RenderViewImpl::willOpenSocketStream( |
3713 WebSocketStreamHandle* handle) { | 3729 WebSocketStreamHandle* handle) { |
3714 SocketStreamHandleData::AddToHandle(handle, routing_id_); | 3730 SocketStreamHandleData::AddToHandle(handle, routing_id_); |
3715 } | 3731 } |
3716 | 3732 |
| 3733 WebKit::WebString RenderViewImpl::userAgentOverride( |
| 3734 WebKit::WebFrame* frame, |
| 3735 const WebKit::WebURL& url) { |
| 3736 if (!webview() || !webview()->mainFrame() || |
| 3737 renderer_preferences_.user_agent_override.empty()) { |
| 3738 return WebKit::WebString(); |
| 3739 } |
| 3740 |
| 3741 // If we're in the middle of committing a load, the data source we need |
| 3742 // will still be provisional. |
| 3743 WebFrame* main_frame = webview()->mainFrame(); |
| 3744 WebDataSource* data_source = NULL; |
| 3745 if (main_frame->provisionalDataSource()) |
| 3746 data_source = main_frame->provisionalDataSource(); |
| 3747 else |
| 3748 data_source = main_frame->dataSource(); |
| 3749 |
| 3750 DocumentState* document_state = |
| 3751 data_source ? DocumentState::FromDataSource(data_source) : NULL; |
| 3752 if (document_state && document_state->is_overriding_user_agent()) |
| 3753 return WebString::fromUTF8(renderer_preferences_.user_agent_override); |
| 3754 else |
| 3755 return WebKit::WebString(); |
| 3756 } |
| 3757 |
3717 // WebKit::WebPageSerializerClient implementation ------------------------------ | 3758 // WebKit::WebPageSerializerClient implementation ------------------------------ |
3718 | 3759 |
3719 void RenderViewImpl::didSerializeDataForFrame( | 3760 void RenderViewImpl::didSerializeDataForFrame( |
3720 const WebURL& frame_url, | 3761 const WebURL& frame_url, |
3721 const WebCString& data, | 3762 const WebCString& data, |
3722 WebPageSerializerClient::PageSerializationStatus status) { | 3763 WebPageSerializerClient::PageSerializationStatus status) { |
3723 Send(new ViewHostMsg_SendSerializedHtmlData( | 3764 Send(new ViewHostMsg_SendSerializedHtmlData( |
3724 routing_id(), | 3765 routing_id(), |
3725 frame_url, | 3766 frame_url, |
3726 data.data(), | 3767 data.data(), |
(...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5650 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5691 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
5651 return !!RenderThreadImpl::current()->compositor_thread(); | 5692 return !!RenderThreadImpl::current()->compositor_thread(); |
5652 } | 5693 } |
5653 | 5694 |
5654 void RenderViewImpl::OnJavaBridgeInit() { | 5695 void RenderViewImpl::OnJavaBridgeInit() { |
5655 DCHECK(!java_bridge_dispatcher_); | 5696 DCHECK(!java_bridge_dispatcher_); |
5656 #if defined(ENABLE_JAVA_BRIDGE) | 5697 #if defined(ENABLE_JAVA_BRIDGE) |
5657 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); | 5698 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); |
5658 #endif | 5699 #endif |
5659 } | 5700 } |
OLD | NEW |