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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); | 1091 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); |
1092 bool is_main_frame = !frame_->parent(); | 1092 bool is_main_frame = !frame_->parent(); |
1093 | 1093 |
1094 // Only run unload if we're not swapped out yet, but send the ack either way. | 1094 // Only run unload if we're not swapped out yet, but send the ack either way. |
1095 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { | 1095 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { |
1096 // Swap this RenderFrame out so the frame can navigate to a page rendered by | 1096 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
1097 // a different process. This involves running the unload handler and | 1097 // a different process. This involves running the unload handler and |
1098 // clearing the page. We also allow this process to exit if there are no | 1098 // clearing the page. We also allow this process to exit if there are no |
1099 // other active RenderFrames in it. | 1099 // other active RenderFrames in it. |
1100 | 1100 |
1101 // Send an UpdateState message before we get swapped out. | 1101 // Send any pending page state messages before we get swapped out. |
1102 render_view_->SyncNavigationState(); | 1102 render_view_->FlushPageState(); |
1103 | 1103 |
1104 // If we need a proxy to replace this, create it now so its routing id is | 1104 // If we need a proxy to replace this, create it now so its routing id is |
1105 // registered for receiving IPC messages. | 1105 // registered for receiving IPC messages. |
1106 if (proxy_routing_id != MSG_ROUTING_NONE) { | 1106 if (proxy_routing_id != MSG_ROUTING_NONE) { |
1107 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this, | 1107 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this, |
1108 proxy_routing_id); | 1108 proxy_routing_id); |
1109 } | 1109 } |
1110 | 1110 |
1111 // Synchronously run the unload handler before sending the ACK. | 1111 // Synchronously run the unload handler before sending the ACK. |
1112 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support | 1112 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support |
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2246 | 2246 |
2247 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 2247 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
2248 RenderFrameProxy* proxy = | 2248 RenderFrameProxy* proxy = |
2249 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 2249 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
2250 CHECK(proxy); | 2250 CHECK(proxy); |
2251 proxy->web_frame()->swap(frame_); | 2251 proxy->web_frame()->swap(frame_); |
2252 proxy_routing_id_ = MSG_ROUTING_NONE; | 2252 proxy_routing_id_ = MSG_ROUTING_NONE; |
2253 } | 2253 } |
2254 | 2254 |
2255 // When we perform a new navigation, we need to update the last committed | 2255 // When we perform a new navigation, we need to update the last committed |
2256 // session history entry with state for the page we are leaving. Do this | 2256 // session history entry with any dirty page state for the page we are |
2257 // before updating the HistoryController state. | 2257 // leaving. Do this before updating the HistoryController state. |
2258 render_view_->UpdateSessionHistory(frame); | 2258 render_view_->FlushPageState(); |
2259 | 2259 |
2260 render_view_->history_controller()->UpdateForCommit(this, item, commit_type, | 2260 render_view_->history_controller()->UpdateForCommit(this, item, commit_type, |
2261 navigation_state->was_within_same_page()); | 2261 navigation_state->was_within_same_page()); |
2262 | 2262 |
2263 InternalDocumentStateData* internal_data = | 2263 InternalDocumentStateData* internal_data = |
2264 InternalDocumentStateData::FromDocumentState(document_state); | 2264 InternalDocumentStateData::FromDocumentState(document_state); |
2265 | 2265 |
2266 if (document_state->commit_load_time().is_null()) | 2266 if (document_state->commit_load_time().is_null()) |
2267 document_state->set_commit_load_time(Time::Now()); | 2267 document_state->set_commit_load_time(Time::Now()); |
2268 | 2268 |
2269 if (internal_data->must_reset_scroll_and_scale_state()) { | 2269 if (internal_data->must_reset_scroll_and_scale_state()) { |
2270 render_view_->webview()->resetScrollAndScaleState(); | 2270 render_view_->webview()->resetScrollAndScaleState(); |
2271 internal_data->set_must_reset_scroll_and_scale_state(false); | 2271 internal_data->set_must_reset_scroll_and_scale_state(false); |
2272 } | 2272 } |
2273 internal_data->set_use_error_page(false); | 2273 internal_data->set_use_error_page(false); |
2274 | 2274 |
2275 bool is_new_navigation = commit_type == blink::WebStandardCommit; | 2275 bool is_new_navigation = commit_type == blink::WebStandardCommit; |
2276 if (is_new_navigation) { | 2276 if (is_new_navigation) { |
2277 // We bump our Page ID to correspond with the new session history entry. | 2277 // We bump our Page ID to correspond with the new session history entry. |
2278 render_view_->page_id_ = render_view_->next_page_id_++; | 2278 render_view_->page_id_ = render_view_->next_page_id_++; |
2279 | 2279 |
2280 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since | 2280 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since we don't |
2281 // we don't want to forget the entry that was there, and since we will | 2281 // want to forget the entry that was there, and since we will never come |
2282 // never come back to kSwappedOutURL. Note that we have to call | 2282 // back to kSwappedOutURL. Note that we have to call FlushPageState and |
2283 // UpdateSessionHistory and update page_id_ even in this case, so that | 2283 // update page_id_ even in this case, so that the current entry gets a state |
2284 // the current entry gets a state update and so that we don't send a | 2284 // update and so that we don't send a state update to the wrong entry when |
2285 // state update to the wrong entry when we swap back in. | 2285 // we swap back in. |
2286 if (GetLoadingUrl() != GURL(kSwappedOutURL)) { | 2286 if (GetLoadingUrl() != GURL(kSwappedOutURL)) { |
2287 // Advance our offset in session history, applying the length limit. | 2287 // Advance our offset in session history, applying the length limit. |
2288 // There is now no forward history. | 2288 // There is now no forward history. |
2289 render_view_->history_list_offset_++; | 2289 render_view_->history_list_offset_++; |
2290 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) | 2290 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) |
2291 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; | 2291 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; |
2292 render_view_->history_list_length_ = | 2292 render_view_->history_list_length_ = |
2293 render_view_->history_list_offset_ + 1; | 2293 render_view_->history_list_offset_ + 1; |
2294 render_view_->history_page_ids_.resize( | 2294 render_view_->history_page_ids_.resize( |
2295 render_view_->history_list_length_, -1); | 2295 render_view_->history_list_length_, -1); |
2296 render_view_->history_page_ids_[render_view_->history_list_offset_] = | 2296 render_view_->history_page_ids_[render_view_->history_list_offset_] = |
2297 render_view_->page_id_; | 2297 render_view_->page_id_; |
2298 } | 2298 } |
2299 } else { | 2299 } else { |
2300 // Inspect the navigation_state on this frame to see if the navigation | 2300 // Inspect the navigation_state on this frame to see if the navigation |
2301 // corresponds to a session history navigation... Note: |frame| may or | 2301 // corresponds to a session history navigation... Note: |frame| may or |
2302 // may not be the toplevel frame, but for the case of capturing session | 2302 // may not be the toplevel frame, but for the case of capturing session |
2303 // history, the first committed frame suffices. We keep track of whether | 2303 // history, the first committed frame suffices. We keep track of whether |
2304 // we've seen this commit before so that only capture session history once | 2304 // we've seen this commit before so that only capture session history once |
2305 // per navigation. | 2305 // per navigation. |
2306 // | 2306 // |
2307 // Note that we need to check if the page ID changed. In the case of a | 2307 // Note that we need to check if the page ID changed. In the case of a |
2308 // reload, the page ID doesn't change, and UpdateSessionHistory gets the | 2308 // reload, the page ID doesn't change, and FlushPageState gets the previous |
2309 // previous URL and the current page ID, which would be wrong. | 2309 // URL and the current page ID, which would be wrong. |
2310 if (navigation_state->pending_page_id() != -1 && | 2310 if (navigation_state->pending_page_id() != -1 && |
2311 navigation_state->pending_page_id() != render_view_->page_id_ && | 2311 navigation_state->pending_page_id() != render_view_->page_id_ && |
2312 !navigation_state->request_committed()) { | 2312 !navigation_state->request_committed()) { |
2313 // This is a successful session history navigation! | 2313 // This is a successful session history navigation! |
2314 render_view_->page_id_ = navigation_state->pending_page_id(); | 2314 render_view_->page_id_ = navigation_state->pending_page_id(); |
2315 | 2315 |
2316 render_view_->history_list_offset_ = | 2316 render_view_->history_list_offset_ = |
2317 navigation_state->pending_history_list_offset(); | 2317 navigation_state->pending_history_list_offset(); |
2318 | 2318 |
2319 // If the history list is valid, our list of page IDs should be correct. | 2319 // If the history list is valid, our list of page IDs should be correct. |
(...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4147 | 4147 |
4148 #if defined(ENABLE_BROWSER_CDMS) | 4148 #if defined(ENABLE_BROWSER_CDMS) |
4149 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4149 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4150 if (!cdm_manager_) | 4150 if (!cdm_manager_) |
4151 cdm_manager_ = new RendererCdmManager(this); | 4151 cdm_manager_ = new RendererCdmManager(this); |
4152 return cdm_manager_; | 4152 return cdm_manager_; |
4153 } | 4153 } |
4154 #endif // defined(ENABLE_BROWSER_CDMS) | 4154 #endif // defined(ENABLE_BROWSER_CDMS) |
4155 | 4155 |
4156 } // namespace content | 4156 } // namespace content |
OLD | NEW |