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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 GetContentClient()->SetActiveURL(params.url); | 693 GetContentClient()->SetActiveURL(params.url); |
694 | 694 |
695 WebFrame* frame = frame_; | 695 WebFrame* frame = frame_; |
696 if (!params.frame_to_navigate.empty()) { | 696 if (!params.frame_to_navigate.empty()) { |
697 // TODO(nasko): Move this lookup to the browser process. | 697 // TODO(nasko): Move this lookup to the browser process. |
698 frame = render_view_->webview()->findFrameByName( | 698 frame = render_view_->webview()->findFrameByName( |
699 WebString::fromUTF8(params.frame_to_navigate)); | 699 WebString::fromUTF8(params.frame_to_navigate)); |
700 CHECK(frame) << "Invalid frame name passed: " << params.frame_to_navigate; | 700 CHECK(frame) << "Invalid frame name passed: " << params.frame_to_navigate; |
701 } | 701 } |
702 | 702 |
703 WebHistoryItem item = | 703 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { |
704 render_view_->history_controller()->GetCurrentItemForExport(); | |
705 if (is_reload && item.isNull()) { | |
706 // We cannot reload if we do not have any history state. This happens, for | 704 // We cannot reload if we do not have any history state. This happens, for |
707 // example, when recovering from a crash. | 705 // example, when recovering from a crash. |
708 is_reload = false; | 706 is_reload = false; |
709 cache_policy = WebURLRequest::ReloadIgnoringCacheData; | 707 cache_policy = WebURLRequest::ReloadIgnoringCacheData; |
710 } | 708 } |
711 | 709 |
712 render_view_->pending_navigation_params_.reset( | 710 render_view_->pending_navigation_params_.reset( |
713 new FrameMsg_Navigate_Params(params)); | 711 new FrameMsg_Navigate_Params(params)); |
714 | 712 |
715 // If we are reloading, then WebKit will use the history state of the current | 713 // If we are reloading, then WebKit will use the history state of the current |
716 // page, so we should just ignore any given history state. Otherwise, if we | 714 // page, so we should just ignore any given history state. Otherwise, if we |
717 // have history state, then we need to navigate to it, which corresponds to a | 715 // have history state, then we need to navigate to it, which corresponds to a |
718 // back/forward navigation event. | 716 // back/forward navigation event. |
719 if (is_reload) { | 717 if (is_reload) { |
720 bool reload_original_url = | 718 bool reload_original_url = |
721 (params.navigation_type == | 719 (params.navigation_type == |
722 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 720 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
723 bool ignore_cache = (params.navigation_type == | 721 bool ignore_cache = (params.navigation_type == |
724 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 722 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
725 | 723 |
726 if (reload_original_url) | 724 if (reload_original_url) |
727 frame->reloadWithOverrideURL(params.url, true); | 725 frame->reloadWithOverrideURL(params.url, true); |
728 else | 726 else |
729 frame->reload(ignore_cache); | 727 frame->reload(ignore_cache); |
730 } else if (params.page_state.IsValid()) { | 728 } else if (params.page_state.IsValid()) { |
731 // We must know the page ID of the page we are navigating back to. | 729 // We must know the page ID of the page we are navigating back to. |
732 DCHECK_NE(params.page_id, -1); | 730 DCHECK_NE(params.page_id, -1); |
733 WebHistoryItem item = PageStateToHistoryItem(params.page_state); | 731 HistoryEntry* entry = PageStateToHistoryEntry(params.page_state); |
734 if (!item.isNull()) { | 732 if (entry) { |
735 // Ensure we didn't save the swapped out URL in UpdateState, since the | 733 // Ensure we didn't save the swapped out URL in UpdateState, since the |
736 // browser should never be telling us to navigate to swappedout://. | 734 // browser should never be telling us to navigate to swappedout://. |
737 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); | 735 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
738 render_view_->history_controller()->GoToItem(item, cache_policy); | 736 render_view_->history_controller()->GoToEntry(entry, cache_policy); |
739 } | 737 } |
740 } else if (!params.base_url_for_data_url.is_empty()) { | 738 } else if (!params.base_url_for_data_url.is_empty()) { |
741 // A loadData request with a specified base URL. | 739 // A loadData request with a specified base URL. |
742 std::string mime_type, charset, data; | 740 std::string mime_type, charset, data; |
743 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | 741 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
744 frame->loadData( | 742 frame->loadData( |
745 WebData(data.c_str(), data.length()), | 743 WebData(data.c_str(), data.length()), |
746 WebString::fromUTF8(mime_type), | 744 WebString::fromUTF8(mime_type), |
747 WebString::fromUTF8(charset), | 745 WebString::fromUTF8(charset), |
748 params.base_url_for_data_url, | 746 params.base_url_for_data_url, |
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2706 !response.isMultipartPayload() && (response.httpStatusCode() != 404); | 2704 !response.isMultipartPayload() && (response.httpStatusCode() != 404); |
2707 | 2705 |
2708 params.searchable_form_url = internal_data->searchable_form_url(); | 2706 params.searchable_form_url = internal_data->searchable_form_url(); |
2709 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 2707 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
2710 | 2708 |
2711 params.gesture = render_view_->navigation_gesture_; | 2709 params.gesture = render_view_->navigation_gesture_; |
2712 render_view_->navigation_gesture_ = NavigationGestureUnknown; | 2710 render_view_->navigation_gesture_ = NavigationGestureUnknown; |
2713 | 2711 |
2714 // Make navigation state a part of the DidCommitProvisionalLoad message so | 2712 // Make navigation state a part of the DidCommitProvisionalLoad message so |
2715 // that commited entry has it at all times. | 2713 // that commited entry has it at all times. |
2716 WebHistoryItem item = | 2714 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); |
2717 render_view_->history_controller()->GetCurrentItemForExport(); | 2715 if (entry) |
2718 if (item.isNull()) { | 2716 params.page_state = HistoryEntryToPageState(entry); |
2719 item.initialize(); | 2717 else |
2720 item.setURLString(request.url().spec().utf16()); | 2718 params.page_state = PageState::CreateFromURL(request.url()); |
2721 } | |
2722 params.page_state = HistoryItemToPageState(item); | |
2723 | 2719 |
2724 if (!frame->parent()) { | 2720 if (!frame->parent()) { |
2725 // Top-level navigation. | 2721 // Top-level navigation. |
2726 | 2722 |
2727 // Reset the zoom limits in case a plugin had changed them previously. This | 2723 // Reset the zoom limits in case a plugin had changed them previously. This |
2728 // will also call us back which will cause us to send a message to | 2724 // will also call us back which will cause us to send a message to |
2729 // update WebContentsImpl. | 2725 // update WebContentsImpl. |
2730 render_view_->webview()->zoomLimitsChanged( | 2726 render_view_->webview()->zoomLimitsChanged( |
2731 ZoomFactorToZoomLevel(kMinimumZoomFactor), | 2727 ZoomFactorToZoomLevel(kMinimumZoomFactor), |
2732 ZoomFactorToZoomLevel(kMaximumZoomFactor)); | 2728 ZoomFactorToZoomLevel(kMaximumZoomFactor)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2777 params.transition = static_cast<PageTransition>( | 2773 params.transition = static_cast<PageTransition>( |
2778 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT); | 2774 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT); |
2779 } else { | 2775 } else { |
2780 params.referrer = RenderViewImpl::GetReferrerFromRequest( | 2776 params.referrer = RenderViewImpl::GetReferrerFromRequest( |
2781 frame, ds->request()); | 2777 frame, ds->request()); |
2782 } | 2778 } |
2783 | 2779 |
2784 base::string16 method = request.httpMethod(); | 2780 base::string16 method = request.httpMethod(); |
2785 if (EqualsASCII(method, "POST")) { | 2781 if (EqualsASCII(method, "POST")) { |
2786 params.is_post = true; | 2782 params.is_post = true; |
2787 params.post_id = ExtractPostId(item); | 2783 params.post_id = ExtractPostId(entry->root()); |
2788 } | 2784 } |
2789 | 2785 |
2790 // Send the user agent override back. | 2786 // Send the user agent override back. |
2791 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); | 2787 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); |
2792 | 2788 |
2793 // Track the URL of the original request. We use the first entry of the | 2789 // Track the URL of the original request. We use the first entry of the |
2794 // redirect chain if it exists because the chain may have started in another | 2790 // redirect chain if it exists because the chain may have started in another |
2795 // process. | 2791 // process. |
2796 params.original_request_url = GetOriginalRequestURL(ds); | 2792 params.original_request_url = GetOriginalRequestURL(ds); |
2797 | 2793 |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3181 selection_text_offset_ = offset; | 3177 selection_text_offset_ = offset; |
3182 selection_range_ = range; | 3178 selection_range_ = range; |
3183 // This IPC is dispatched by RenderWidetHost, so use its routing ID. | 3179 // This IPC is dispatched by RenderWidetHost, so use its routing ID. |
3184 Send(new ViewHostMsg_SelectionChanged( | 3180 Send(new ViewHostMsg_SelectionChanged( |
3185 GetRenderWidget()->routing_id(), text, offset, range)); | 3181 GetRenderWidget()->routing_id(), text, offset, range)); |
3186 } | 3182 } |
3187 GetRenderWidget()->UpdateSelectionBounds(); | 3183 GetRenderWidget()->UpdateSelectionBounds(); |
3188 } | 3184 } |
3189 | 3185 |
3190 } // namespace content | 3186 } // namespace content |
OLD | NEW |