Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 248013003: Remove WebHistoryItem child usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove the routing ids from serialization Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 !response.isMultipartPayload() && (response.httpStatusCode() != 404); 2701 !response.isMultipartPayload() && (response.httpStatusCode() != 404);
2704 2702
2705 params.searchable_form_url = internal_data->searchable_form_url(); 2703 params.searchable_form_url = internal_data->searchable_form_url();
2706 params.searchable_form_encoding = internal_data->searchable_form_encoding(); 2704 params.searchable_form_encoding = internal_data->searchable_form_encoding();
2707 2705
2708 params.gesture = render_view_->navigation_gesture_; 2706 params.gesture = render_view_->navigation_gesture_;
2709 render_view_->navigation_gesture_ = NavigationGestureUnknown; 2707 render_view_->navigation_gesture_ = NavigationGestureUnknown;
2710 2708
2711 // Make navigation state a part of the DidCommitProvisionalLoad message so 2709 // Make navigation state a part of the DidCommitProvisionalLoad message so
2712 // that commited entry has it at all times. 2710 // that commited entry has it at all times.
2713 WebHistoryItem item = 2711 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry();
2714 render_view_->history_controller()->GetCurrentItemForExport(); 2712 if (entry)
2715 if (item.isNull()) { 2713 params.page_state = HistoryEntryToPageState(entry);
2716 item.initialize(); 2714 else
2717 item.setURLString(request.url().spec().utf16()); 2715 params.page_state = PageState::CreateFromURL(request.url());
2718 }
2719 params.page_state = HistoryItemToPageState(item);
2720 2716
2721 if (!frame->parent()) { 2717 if (!frame->parent()) {
2722 // Top-level navigation. 2718 // Top-level navigation.
2723 2719
2724 // Reset the zoom limits in case a plugin had changed them previously. This 2720 // Reset the zoom limits in case a plugin had changed them previously. This
2725 // will also call us back which will cause us to send a message to 2721 // will also call us back which will cause us to send a message to
2726 // update WebContentsImpl. 2722 // update WebContentsImpl.
2727 render_view_->webview()->zoomLimitsChanged( 2723 render_view_->webview()->zoomLimitsChanged(
2728 ZoomFactorToZoomLevel(kMinimumZoomFactor), 2724 ZoomFactorToZoomLevel(kMinimumZoomFactor),
2729 ZoomFactorToZoomLevel(kMaximumZoomFactor)); 2725 ZoomFactorToZoomLevel(kMaximumZoomFactor));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2774 params.transition = static_cast<PageTransition>( 2770 params.transition = static_cast<PageTransition>(
2775 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT); 2771 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT);
2776 } else { 2772 } else {
2777 params.referrer = RenderViewImpl::GetReferrerFromRequest( 2773 params.referrer = RenderViewImpl::GetReferrerFromRequest(
2778 frame, ds->request()); 2774 frame, ds->request());
2779 } 2775 }
2780 2776
2781 base::string16 method = request.httpMethod(); 2777 base::string16 method = request.httpMethod();
2782 if (EqualsASCII(method, "POST")) { 2778 if (EqualsASCII(method, "POST")) {
2783 params.is_post = true; 2779 params.is_post = true;
2784 params.post_id = ExtractPostId(item); 2780 params.post_id = ExtractPostId(entry->root());
2785 } 2781 }
2786 2782
2787 // Send the user agent override back. 2783 // Send the user agent override back.
2788 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); 2784 params.is_overriding_user_agent = internal_data->is_overriding_user_agent();
2789 2785
2790 // Track the URL of the original request. We use the first entry of the 2786 // Track the URL of the original request. We use the first entry of the
2791 // redirect chain if it exists because the chain may have started in another 2787 // redirect chain if it exists because the chain may have started in another
2792 // process. 2788 // process.
2793 params.original_request_url = GetOriginalRequestURL(ds); 2789 params.original_request_url = GetOriginalRequestURL(ds);
2794 2790
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
3178 selection_text_offset_ = offset; 3174 selection_text_offset_ = offset;
3179 selection_range_ = range; 3175 selection_range_ = range;
3180 // This IPC is dispatched by RenderWidetHost, so use its routing ID. 3176 // This IPC is dispatched by RenderWidetHost, so use its routing ID.
3181 Send(new ViewHostMsg_SelectionChanged( 3177 Send(new ViewHostMsg_SelectionChanged(
3182 GetRenderWidget()->routing_id(), text, offset, range)); 3178 GetRenderWidget()->routing_id(), text, offset, range));
3183 } 3179 }
3184 GetRenderWidget()->UpdateSelectionBounds(); 3180 GetRenderWidget()->UpdateSelectionBounds();
3185 } 3181 }
3186 3182
3187 } // namespace content 3183 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698