Chromium Code Reviews| 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 = |
| 734 if (!item.isNull()) { | 732 PageStateToHistoryEntry(params.page_state, routing_id_); |
| 733 if (entry) { | |
| 735 // Ensure we didn't save the swapped out URL in UpdateState, since the | 734 // Ensure we didn't save the swapped out URL in UpdateState, since the |
| 736 // browser should never be telling us to navigate to swappedout://. | 735 // browser should never be telling us to navigate to swappedout://. |
| 737 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); | 736 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
| 738 render_view_->history_controller()->GoToItem(item, cache_policy); | 737 render_view_->history_controller()->GoToEntry(entry, cache_policy); |
| 739 } | 738 } |
| 740 } else if (!params.base_url_for_data_url.is_empty()) { | 739 } else if (!params.base_url_for_data_url.is_empty()) { |
| 741 // A loadData request with a specified base URL. | 740 // A loadData request with a specified base URL. |
| 742 std::string mime_type, charset, data; | 741 std::string mime_type, charset, data; |
| 743 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | 742 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
| 744 frame->loadData( | 743 frame->loadData( |
| 745 WebData(data.c_str(), data.length()), | 744 WebData(data.c_str(), data.length()), |
| 746 WebString::fromUTF8(mime_type), | 745 WebString::fromUTF8(mime_type), |
| 747 WebString::fromUTF8(charset), | 746 WebString::fromUTF8(charset), |
| 748 params.base_url_for_data_url, | 747 params.base_url_for_data_url, |
| (...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2116 // response as RunJavaScriptMessage. | 2115 // response as RunJavaScriptMessage. |
| 2117 base::string16 ignored_result; | 2116 base::string16 ignored_result; |
| 2118 render_view()->SendAndRunNestedMessageLoop( | 2117 render_view()->SendAndRunNestedMessageLoop( |
| 2119 new FrameHostMsg_RunBeforeUnloadConfirm( | 2118 new FrameHostMsg_RunBeforeUnloadConfirm( |
| 2120 routing_id_, frame_->document().url(), message, is_reload, | 2119 routing_id_, frame_->document().url(), message, is_reload, |
| 2121 &success, &ignored_result)); | 2120 &success, &ignored_result)); |
| 2122 return success; | 2121 return success; |
| 2123 } | 2122 } |
| 2124 | 2123 |
| 2125 void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) { | 2124 void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) { |
| 2126 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); | 2125 PageState state = HistoryEntryToPageState( |
| 2126 render_view_->history_controller()->GetCurrentEntry()); | |
| 2127 ContextMenuParams params = ContextMenuParamsBuilder::Build(data, state); | |
|
Charlie Reis
2014/04/28 16:29:00
Yeah, somehow we'll need to PageState for the fram
| |
| 2127 params.source_type = GetRenderWidget()->context_menu_source_type(); | 2128 params.source_type = GetRenderWidget()->context_menu_source_type(); |
| 2128 if (params.source_type == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { | 2129 if (params.source_type == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { |
| 2129 params.x = GetRenderWidget()->touch_editing_context_menu_location().x(); | 2130 params.x = GetRenderWidget()->touch_editing_context_menu_location().x(); |
| 2130 params.y = GetRenderWidget()->touch_editing_context_menu_location().y(); | 2131 params.y = GetRenderWidget()->touch_editing_context_menu_location().y(); |
| 2131 } | 2132 } |
| 2132 GetRenderWidget()->OnShowHostContextMenu(¶ms); | 2133 GetRenderWidget()->OnShowHostContextMenu(¶ms); |
| 2133 | 2134 |
| 2134 // Plugins, e.g. PDF, don't currently update the render view when their | 2135 // Plugins, e.g. PDF, don't currently update the render view when their |
| 2135 // selected text changes, but the context menu params do contain the updated | 2136 // selected text changes, but the context menu params do contain the updated |
| 2136 // selection. If that's the case, update the render view's state just prior | 2137 // selection. If that's the case, update the render view's state just prior |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2691 !response.isMultipartPayload() && (response.httpStatusCode() != 404); | 2692 !response.isMultipartPayload() && (response.httpStatusCode() != 404); |
| 2692 | 2693 |
| 2693 params.searchable_form_url = internal_data->searchable_form_url(); | 2694 params.searchable_form_url = internal_data->searchable_form_url(); |
| 2694 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 2695 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
| 2695 | 2696 |
| 2696 params.gesture = render_view_->navigation_gesture_; | 2697 params.gesture = render_view_->navigation_gesture_; |
| 2697 render_view_->navigation_gesture_ = NavigationGestureUnknown; | 2698 render_view_->navigation_gesture_ = NavigationGestureUnknown; |
| 2698 | 2699 |
| 2699 // Make navigation state a part of the DidCommitProvisionalLoad message so | 2700 // Make navigation state a part of the DidCommitProvisionalLoad message so |
| 2700 // that commited entry has it at all times. | 2701 // that commited entry has it at all times. |
| 2701 WebHistoryItem item = | 2702 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); |
| 2702 render_view_->history_controller()->GetCurrentItemForExport(); | 2703 if (entry) |
| 2703 if (item.isNull()) { | 2704 params.page_state = HistoryEntryToPageState(entry); |
| 2704 item.initialize(); | 2705 else |
| 2705 item.setURLString(request.url().spec().utf16()); | 2706 params.page_state = PageState::CreateFromURL(request.url()); |
| 2706 } | |
| 2707 params.page_state = HistoryItemToPageState(item); | |
| 2708 | 2707 |
| 2709 if (!frame->parent()) { | 2708 if (!frame->parent()) { |
| 2710 // Top-level navigation. | 2709 // Top-level navigation. |
| 2711 | 2710 |
| 2712 // Reset the zoom limits in case a plugin had changed them previously. This | 2711 // Reset the zoom limits in case a plugin had changed them previously. This |
| 2713 // will also call us back which will cause us to send a message to | 2712 // will also call us back which will cause us to send a message to |
| 2714 // update WebContentsImpl. | 2713 // update WebContentsImpl. |
| 2715 render_view_->webview()->zoomLimitsChanged( | 2714 render_view_->webview()->zoomLimitsChanged( |
| 2716 ZoomFactorToZoomLevel(kMinimumZoomFactor), | 2715 ZoomFactorToZoomLevel(kMinimumZoomFactor), |
| 2717 ZoomFactorToZoomLevel(kMaximumZoomFactor)); | 2716 ZoomFactorToZoomLevel(kMaximumZoomFactor)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2762 params.transition = static_cast<PageTransition>( | 2761 params.transition = static_cast<PageTransition>( |
| 2763 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT); | 2762 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT); |
| 2764 } else { | 2763 } else { |
| 2765 params.referrer = RenderViewImpl::GetReferrerFromRequest( | 2764 params.referrer = RenderViewImpl::GetReferrerFromRequest( |
| 2766 frame, ds->request()); | 2765 frame, ds->request()); |
| 2767 } | 2766 } |
| 2768 | 2767 |
| 2769 base::string16 method = request.httpMethod(); | 2768 base::string16 method = request.httpMethod(); |
| 2770 if (EqualsASCII(method, "POST")) { | 2769 if (EqualsASCII(method, "POST")) { |
| 2771 params.is_post = true; | 2770 params.is_post = true; |
| 2772 params.post_id = ExtractPostId(item); | 2771 params.post_id = ExtractPostId(entry->root()); |
| 2773 } | 2772 } |
| 2774 | 2773 |
| 2775 // Send the user agent override back. | 2774 // Send the user agent override back. |
| 2776 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); | 2775 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); |
| 2777 | 2776 |
| 2778 // Track the URL of the original request. We use the first entry of the | 2777 // Track the URL of the original request. We use the first entry of the |
| 2779 // redirect chain if it exists because the chain may have started in another | 2778 // redirect chain if it exists because the chain may have started in another |
| 2780 // process. | 2779 // process. |
| 2781 params.original_request_url = GetOriginalRequestURL(ds); | 2780 params.original_request_url = GetOriginalRequestURL(ds); |
| 2782 | 2781 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3166 selection_text_offset_ = offset; | 3165 selection_text_offset_ = offset; |
| 3167 selection_range_ = range; | 3166 selection_range_ = range; |
| 3168 // This IPC is dispatched by RenderWidetHost, so use its routing ID. | 3167 // This IPC is dispatched by RenderWidetHost, so use its routing ID. |
| 3169 Send(new ViewHostMsg_SelectionChanged( | 3168 Send(new ViewHostMsg_SelectionChanged( |
| 3170 GetRenderWidget()->routing_id(), text, offset, range)); | 3169 GetRenderWidget()->routing_id(), text, offset, range)); |
| 3171 } | 3170 } |
| 3172 GetRenderWidget()->UpdateSelectionBounds(); | 3171 GetRenderWidget()->UpdateSelectionBounds(); |
| 3173 } | 3172 } |
| 3174 | 3173 |
| 3175 } // namespace content | 3174 } // namespace content |
| OLD | NEW |