| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "content/child/appcache/appcache_dispatcher.h" | 35 #include "content/child/appcache/appcache_dispatcher.h" |
| 36 #include "content/child/appcache/web_application_cache_host_impl.h" | 36 #include "content/child/appcache/web_application_cache_host_impl.h" |
| 37 #include "content/child/child_thread.h" | 37 #include "content/child/child_thread.h" |
| 38 #include "content/child/npapi/webplugin_delegate_impl.h" | 38 #include "content/child/npapi/webplugin_delegate_impl.h" |
| 39 #include "content/child/request_extra_data.h" | 39 #include "content/child/request_extra_data.h" |
| 40 #include "content/child/webmessageportchannel_impl.h" | 40 #include "content/child/webmessageportchannel_impl.h" |
| 41 #include "content/common/clipboard_messages.h" | 41 #include "content/common/clipboard_messages.h" |
| 42 #include "content/common/database_messages.h" | 42 #include "content/common/database_messages.h" |
| 43 #include "content/common/dom_storage/dom_storage_types.h" | 43 #include "content/common/dom_storage/dom_storage_types.h" |
| 44 #include "content/common/drag_messages.h" | 44 #include "content/common/drag_messages.h" |
| 45 #include "content/common/frame_messages.h" |
| 45 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 46 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 46 #include "content/common/input_messages.h" | 47 #include "content/common/input_messages.h" |
| 47 #include "content/common/java_bridge_messages.h" | 48 #include "content/common/java_bridge_messages.h" |
| 48 #include "content/common/pepper_messages.h" | 49 #include "content/common/pepper_messages.h" |
| 49 #include "content/common/socket_stream_handle_data.h" | 50 #include "content/common/socket_stream_handle_data.h" |
| 50 #include "content/common/ssl_status_serialization.h" | 51 #include "content/common/ssl_status_serialization.h" |
| 51 #include "content/common/view_messages.h" | 52 #include "content/common/view_messages.h" |
| 52 #include "content/public/common/bindings_policy.h" | 53 #include "content/public/common/bindings_policy.h" |
| 53 #include "content/public/common/content_client.h" | 54 #include "content/public/common/content_client.h" |
| 54 #include "content/public/common/content_constants.h" | 55 #include "content/public/common/content_constants.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 358 |
| 358 #if defined(OS_ANDROID) | 359 #if defined(OS_ANDROID) |
| 359 // Delay between tapping in content and launching the associated android intent. | 360 // Delay between tapping in content and launching the associated android intent. |
| 360 // Used to allow users see what has been recognized as content. | 361 // Used to allow users see what has been recognized as content. |
| 361 const size_t kContentIntentDelayMilliseconds = 700; | 362 const size_t kContentIntentDelayMilliseconds = 700; |
| 362 #endif | 363 #endif |
| 363 | 364 |
| 364 static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) = | 365 static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) = |
| 365 NULL; | 366 NULL; |
| 366 | 367 |
| 367 static bool IsReload(const ViewMsg_Navigate_Params& params) { | 368 // static |
| 369 bool RenderViewImpl::IsReload(const FrameMsg_Navigate_Params& params) { |
| 368 return | 370 return |
| 369 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || | 371 params.navigation_type == FrameMsg_Navigate_Type::RELOAD || |
| 370 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE || | 372 params.navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE || |
| 371 params.navigation_type == | 373 params.navigation_type == |
| 372 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; | 374 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
| 373 } | 375 } |
| 374 | 376 |
| 375 // static | 377 // static |
| 376 Referrer RenderViewImpl::GetReferrerFromRequest( | 378 Referrer RenderViewImpl::GetReferrerFromRequest( |
| 377 WebFrame* frame, | 379 WebFrame* frame, |
| 378 const WebURLRequest& request) { | 380 const WebURLRequest& request) { |
| 379 return Referrer(GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), | 381 return Referrer(GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 380 request.referrerPolicy()); | 382 request.referrerPolicy()); |
| 381 } | 383 } |
| 382 | 384 |
| 383 NOINLINE static void CrashIntentionally() { | |
| 384 // NOTE(shess): Crash directly rather than using NOTREACHED() so | |
| 385 // that the signature is easier to triage in crash reports. | |
| 386 volatile int* zero = NULL; | |
| 387 *zero = 0; | |
| 388 } | |
| 389 | |
| 390 #if defined(ADDRESS_SANITIZER) | |
| 391 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { | |
| 392 // NOTE(rogerm): We intentionally perform an invalid heap access here in | |
| 393 // order to trigger an Address Sanitizer (ASAN) error report. | |
| 394 static const char kCrashDomain[] = "crash"; | |
| 395 static const char kHeapOverflow[] = "/heap-overflow"; | |
| 396 static const char kHeapUnderflow[] = "/heap-underflow"; | |
| 397 static const char kUseAfterFree[] = "/use-after-free"; | |
| 398 static const int kArraySize = 5; | |
| 399 | |
| 400 if (!url.DomainIs(kCrashDomain, sizeof(kCrashDomain) - 1)) | |
| 401 return; | |
| 402 | |
| 403 if (!url.has_path()) | |
| 404 return; | |
| 405 | |
| 406 scoped_ptr<int[]> array(new int[kArraySize]); | |
| 407 std::string crash_type(url.path()); | |
| 408 int dummy = 0; | |
| 409 if (crash_type == kHeapOverflow) { | |
| 410 dummy = array[kArraySize]; | |
| 411 } else if (crash_type == kHeapUnderflow ) { | |
| 412 dummy = array[-1]; | |
| 413 } else if (crash_type == kUseAfterFree) { | |
| 414 int* dangling = array.get(); | |
| 415 array.reset(); | |
| 416 dummy = dangling[kArraySize / 2]; | |
| 417 } | |
| 418 | |
| 419 // Make sure the assignments to the dummy value aren't optimized away. | |
| 420 base::debug::Alias(&dummy); | |
| 421 } | |
| 422 #endif // ADDRESS_SANITIZER | |
| 423 | |
| 424 static void MaybeHandleDebugURL(const GURL& url) { | |
| 425 if (!url.SchemeIs(kChromeUIScheme)) | |
| 426 return; | |
| 427 if (url == GURL(kChromeUICrashURL)) { | |
| 428 CrashIntentionally(); | |
| 429 } else if (url == GURL(kChromeUIKillURL)) { | |
| 430 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); | |
| 431 } else if (url == GURL(kChromeUIHangURL)) { | |
| 432 for (;;) { | |
| 433 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | |
| 434 } | |
| 435 } else if (url == GURL(kChromeUIShorthangURL)) { | |
| 436 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | |
| 437 } | |
| 438 | |
| 439 #if defined(ADDRESS_SANITIZER) | |
| 440 MaybeTriggerAsanError(url); | |
| 441 #endif // ADDRESS_SANITIZER | |
| 442 } | |
| 443 | |
| 444 // Returns false unless this is a top-level navigation. | 385 // Returns false unless this is a top-level navigation. |
| 445 static bool IsTopLevelNavigation(WebFrame* frame) { | 386 static bool IsTopLevelNavigation(WebFrame* frame) { |
| 446 return frame->parent() == NULL; | 387 return frame->parent() == NULL; |
| 447 } | 388 } |
| 448 | 389 |
| 449 // Returns false unless this is a top-level navigation that crosses origins. | 390 // Returns false unless this is a top-level navigation that crosses origins. |
| 450 static bool IsNonLocalTopLevelNavigation(const GURL& url, | 391 static bool IsNonLocalTopLevelNavigation(const GURL& url, |
| 451 WebFrame* frame, | 392 WebFrame* frame, |
| 452 WebNavigationType type, | 393 WebNavigationType type, |
| 453 bool is_form_post) { | 394 bool is_form_post) { |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) | 1139 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) |
| 1199 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) | 1140 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) |
| 1200 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, | 1141 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, |
| 1201 OnScrollFocusedEditableNodeIntoRect) | 1142 OnScrollFocusedEditableNodeIntoRect) |
| 1202 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) | 1143 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) |
| 1203 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) | 1144 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) |
| 1204 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, | 1145 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, |
| 1205 OnSetEditCommandsForNextKeyEvent) | 1146 OnSetEditCommandsForNextKeyEvent) |
| 1206 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) | 1147 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) |
| 1207 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect) | 1148 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect) |
| 1208 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) | 1149 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) |
| 1209 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) | 1150 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
| 1210 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) | 1151 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) |
| 1211 IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName) | 1152 IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName) |
| 1212 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets, | 1153 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets, |
| 1213 OnSetEditableSelectionOffsets) | 1154 OnSetEditableSelectionOffsets) |
| 1214 IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText, | 1155 IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText, |
| 1215 OnSetCompositionFromExistingText) | 1156 OnSetCompositionFromExistingText) |
| 1216 IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete, | 1157 IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete, |
| 1217 OnExtendSelectionAndDelete) | 1158 OnExtendSelectionAndDelete) |
| 1218 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 1159 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 | 1251 |
| 1311 if (!msg_is_ok) { | 1252 if (!msg_is_ok) { |
| 1312 // The message had a handler, but its deserialization failed. | 1253 // The message had a handler, but its deserialization failed. |
| 1313 // Kill the renderer to avoid potential spoofing attacks. | 1254 // Kill the renderer to avoid potential spoofing attacks. |
| 1314 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; | 1255 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
| 1315 } | 1256 } |
| 1316 | 1257 |
| 1317 return handled; | 1258 return handled; |
| 1318 } | 1259 } |
| 1319 | 1260 |
| 1320 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { | 1261 void RenderViewImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { |
| 1321 MaybeHandleDebugURL(params.url); | |
| 1322 if (!webview()) | |
| 1323 return; | |
| 1324 | |
| 1325 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); | 1262 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); |
| 1326 | |
| 1327 bool is_reload = IsReload(params); | |
| 1328 WebURLRequest::CachePolicy cache_policy = | |
| 1329 WebURLRequest::UseProtocolCachePolicy; | |
| 1330 | |
| 1331 // If this is a stale back/forward (due to a recent navigation the browser | |
| 1332 // didn't know about), ignore it. | |
| 1333 if (IsBackForwardToStaleEntry(params, is_reload)) | |
| 1334 return; | |
| 1335 | |
| 1336 // Swap this renderer back in if necessary. | |
| 1337 if (is_swapped_out_) { | |
| 1338 // We marked the view as hidden when swapping the view out, so be sure to | |
| 1339 // reset the visibility state before navigating to the new URL. | |
| 1340 webview()->setVisibilityState(visibilityState(), false); | |
| 1341 | |
| 1342 // If this is an attempt to reload while we are swapped out, we should not | |
| 1343 // reload swappedout://, but the previous page, which is stored in | |
| 1344 // params.state. Setting is_reload to false will treat this like a back | |
| 1345 // navigation to accomplish that. | |
| 1346 is_reload = false; | |
| 1347 cache_policy = WebURLRequest::ReloadIgnoringCacheData; | |
| 1348 | |
| 1349 // We refresh timezone when a view is swapped in since timezone | |
| 1350 // can get out of sync when the system timezone is updated while | |
| 1351 // the view is swapped out. | |
| 1352 NotifyTimezoneChange(webview()->mainFrame()); | |
| 1353 | |
| 1354 SetSwappedOut(false); | |
| 1355 } | |
| 1356 | |
| 1357 if (params.should_clear_history_list) { | |
| 1358 CHECK_EQ(params.pending_history_list_offset, -1); | |
| 1359 CHECK_EQ(params.current_history_list_offset, -1); | |
| 1360 CHECK_EQ(params.current_history_list_length, 0); | |
| 1361 } | |
| 1362 history_list_offset_ = params.current_history_list_offset; | |
| 1363 history_list_length_ = params.current_history_list_length; | |
| 1364 if (history_list_length_ >= 0) | |
| 1365 history_page_ids_.resize(history_list_length_, -1); | |
| 1366 if (params.pending_history_list_offset >= 0 && | |
| 1367 params.pending_history_list_offset < history_list_length_) | |
| 1368 history_page_ids_[params.pending_history_list_offset] = params.page_id; | |
| 1369 | |
| 1370 GetContentClient()->SetActiveURL(params.url); | |
| 1371 | |
| 1372 WebFrame* frame = webview()->mainFrame(); | |
| 1373 if (!params.frame_to_navigate.empty()) { | |
| 1374 frame = webview()->findFrameByName( | |
| 1375 WebString::fromUTF8(params.frame_to_navigate)); | |
| 1376 CHECK(frame) << "Invalid frame name passed: " << params.frame_to_navigate; | |
| 1377 } | |
| 1378 | |
| 1379 if (is_reload && frame->currentHistoryItem().isNull()) { | |
| 1380 // We cannot reload if we do not have any history state. This happens, for | |
| 1381 // example, when recovering from a crash. | |
| 1382 is_reload = false; | |
| 1383 cache_policy = WebURLRequest::ReloadIgnoringCacheData; | |
| 1384 } | |
| 1385 | |
| 1386 pending_navigation_params_.reset(new ViewMsg_Navigate_Params(params)); | |
| 1387 | |
| 1388 // If we are reloading, then WebKit will use the history state of the current | |
| 1389 // page, so we should just ignore any given history state. Otherwise, if we | |
| 1390 // have history state, then we need to navigate to it, which corresponds to a | |
| 1391 // back/forward navigation event. | |
| 1392 if (is_reload) { | |
| 1393 bool reload_original_url = | |
| 1394 (params.navigation_type == | |
| 1395 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | |
| 1396 bool ignore_cache = (params.navigation_type == | |
| 1397 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | |
| 1398 | |
| 1399 if (reload_original_url) | |
| 1400 frame->reloadWithOverrideURL(params.url, true); | |
| 1401 else | |
| 1402 frame->reload(ignore_cache); | |
| 1403 } else if (params.page_state.IsValid()) { | |
| 1404 // We must know the page ID of the page we are navigating back to. | |
| 1405 DCHECK_NE(params.page_id, -1); | |
| 1406 WebHistoryItem item = PageStateToHistoryItem(params.page_state); | |
| 1407 if (!item.isNull()) { | |
| 1408 // Ensure we didn't save the swapped out URL in UpdateState, since the | |
| 1409 // browser should never be telling us to navigate to swappedout://. | |
| 1410 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); | |
| 1411 frame->loadHistoryItem(item, cache_policy); | |
| 1412 } | |
| 1413 } else if (!params.base_url_for_data_url.is_empty()) { | |
| 1414 // A loadData request with a specified base URL. | |
| 1415 std::string mime_type, charset, data; | |
| 1416 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | |
| 1417 frame->loadData( | |
| 1418 WebData(data.c_str(), data.length()), | |
| 1419 WebString::fromUTF8(mime_type), | |
| 1420 WebString::fromUTF8(charset), | |
| 1421 params.base_url_for_data_url, | |
| 1422 params.history_url_for_data_url, | |
| 1423 false); | |
| 1424 } else { | |
| 1425 CHECK(false) << | |
| 1426 "Invalid URL passed: " << params.url.possibly_invalid_spec(); | |
| 1427 } | |
| 1428 } else { | |
| 1429 // Navigate to the given URL. | |
| 1430 WebURLRequest request(params.url); | |
| 1431 | |
| 1432 // A session history navigation should have been accompanied by state. | |
| 1433 CHECK_EQ(params.page_id, -1); | |
| 1434 | |
| 1435 if (frame->isViewSourceModeEnabled()) | |
| 1436 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); | |
| 1437 | |
| 1438 if (params.referrer.url.is_valid()) { | |
| 1439 WebString referrer = WebSecurityPolicy::generateReferrerHeader( | |
| 1440 params.referrer.policy, | |
| 1441 params.url, | |
| 1442 WebString::fromUTF8(params.referrer.url.spec())); | |
| 1443 if (!referrer.isEmpty()) | |
| 1444 request.setHTTPReferrer(referrer, params.referrer.policy); | |
| 1445 } | |
| 1446 | |
| 1447 if (!params.extra_headers.empty()) { | |
| 1448 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), | |
| 1449 params.extra_headers.end(), "\n"); | |
| 1450 i.GetNext(); ) { | |
| 1451 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | |
| 1452 WebString::fromUTF8(i.values())); | |
| 1453 } | |
| 1454 } | |
| 1455 | |
| 1456 if (params.is_post) { | |
| 1457 request.setHTTPMethod(WebString::fromUTF8("POST")); | |
| 1458 | |
| 1459 // Set post data. | |
| 1460 WebHTTPBody http_body; | |
| 1461 http_body.initialize(); | |
| 1462 const char* data = NULL; | |
| 1463 if (params.browser_initiated_post_data.size()) { | |
| 1464 data = reinterpret_cast<const char*>( | |
| 1465 ¶ms.browser_initiated_post_data.front()); | |
| 1466 } | |
| 1467 http_body.appendData( | |
| 1468 WebData(data, params.browser_initiated_post_data.size())); | |
| 1469 request.setHTTPBody(http_body); | |
| 1470 } | |
| 1471 | |
| 1472 frame->loadRequest(request); | |
| 1473 | |
| 1474 // If this is a cross-process navigation, the browser process will send | |
| 1475 // along the proper navigation start value. | |
| 1476 if (!params.browser_navigation_start.is_null() && | |
| 1477 frame->provisionalDataSource()) { | |
| 1478 // browser_navigation_start is likely before this process existed, so we | |
| 1479 // can't use InterProcessTimeTicksConverter. Instead, the best we can do | |
| 1480 // is just ensure we don't report a bogus value in the future. | |
| 1481 base::TimeTicks navigation_start = std::min( | |
| 1482 base::TimeTicks::Now(), params.browser_navigation_start); | |
| 1483 double navigation_start_seconds = | |
| 1484 (navigation_start - base::TimeTicks()).InSecondsF(); | |
| 1485 frame->provisionalDataSource()->setNavigationStartTime( | |
| 1486 navigation_start_seconds); | |
| 1487 } | |
| 1488 } | |
| 1489 | |
| 1490 // In case LoadRequest failed before DidCreateDataSource was called. | |
| 1491 pending_navigation_params_.reset(); | |
| 1492 } | 1263 } |
| 1493 | 1264 |
| 1494 bool RenderViewImpl::IsBackForwardToStaleEntry( | 1265 bool RenderViewImpl::IsBackForwardToStaleEntry( |
| 1495 const ViewMsg_Navigate_Params& params, | 1266 const FrameMsg_Navigate_Params& params, |
| 1496 bool is_reload) { | 1267 bool is_reload) { |
| 1497 // Make sure this isn't a back/forward to an entry we have already cropped | 1268 // Make sure this isn't a back/forward to an entry we have already cropped |
| 1498 // or replaced from our history, before the browser knew about it. If so, | 1269 // or replaced from our history, before the browser knew about it. If so, |
| 1499 // a new navigation has committed in the mean time, and we can ignore this. | 1270 // a new navigation has committed in the mean time, and we can ignore this. |
| 1500 bool is_back_forward = !is_reload && params.page_state.IsValid(); | 1271 bool is_back_forward = !is_reload && params.page_state.IsValid(); |
| 1501 | 1272 |
| 1502 // Note: if the history_list_length_ is 0 for a back/forward, we must be | 1273 // Note: if the history_list_length_ is 0 for a back/forward, we must be |
| 1503 // restoring from a previous session. We'll update our state in OnNavigate. | 1274 // restoring from a previous session. We'll update our state in OnNavigate. |
| 1504 if (!is_back_forward || history_list_length_ <= 0) | 1275 if (!is_back_forward || history_list_length_ <= 0) |
| 1505 return false; | 1276 return false; |
| (...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3165 break; | 2936 break; |
| 3166 } | 2937 } |
| 3167 } | 2938 } |
| 3168 | 2939 |
| 3169 FOR_EACH_OBSERVER( | 2940 FOR_EACH_OBSERVER( |
| 3170 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); | 2941 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); |
| 3171 } | 2942 } |
| 3172 | 2943 |
| 3173 void RenderViewImpl::PopulateDocumentStateFromPending( | 2944 void RenderViewImpl::PopulateDocumentStateFromPending( |
| 3174 DocumentState* document_state) { | 2945 DocumentState* document_state) { |
| 3175 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); | 2946 const FrameMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
| 3176 document_state->set_request_time(params.request_time); | 2947 document_state->set_request_time(params.request_time); |
| 3177 | 2948 |
| 3178 InternalDocumentStateData* internal_data = | 2949 InternalDocumentStateData* internal_data = |
| 3179 InternalDocumentStateData::FromDocumentState(document_state); | 2950 InternalDocumentStateData::FromDocumentState(document_state); |
| 3180 | 2951 |
| 3181 if (!params.url.SchemeIs(kJavaScriptScheme) && | 2952 if (!params.url.SchemeIs(kJavaScriptScheme) && |
| 3182 params.navigation_type == ViewMsg_Navigate_Type::RESTORE) { | 2953 params.navigation_type == FrameMsg_Navigate_Type::RESTORE) { |
| 3183 // We're doing a load of a page that was restored from the last session. By | 2954 // We're doing a load of a page that was restored from the last session. By |
| 3184 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which | 2955 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
| 3185 // can result in stale data for pages that are set to expire. We explicitly | 2956 // can result in stale data for pages that are set to expire. We explicitly |
| 3186 // override that by setting the policy here so that as necessary we load | 2957 // override that by setting the policy here so that as necessary we load |
| 3187 // from the network. | 2958 // from the network. |
| 3188 // | 2959 // |
| 3189 // TODO(davidben): Remove this in favor of passing a cache policy to the | 2960 // TODO(davidben): Remove this in favor of passing a cache policy to the |
| 3190 // loadHistoryItem call in OnNavigate. That requires not overloading | 2961 // loadHistoryItem call in OnNavigate. That requires not overloading |
| 3191 // UseProtocolCachePolicy to mean both "normal load" and "determine cache | 2962 // UseProtocolCachePolicy to mean both "normal load" and "determine cache |
| 3192 // policy based on load type, etc". | 2963 // policy based on load type, etc". |
| 3193 internal_data->set_cache_policy_override( | 2964 internal_data->set_cache_policy_override( |
| 3194 WebURLRequest::UseProtocolCachePolicy); | 2965 WebURLRequest::UseProtocolCachePolicy); |
| 3195 } | 2966 } |
| 3196 | 2967 |
| 3197 if (IsReload(params)) | 2968 if (IsReload(params)) |
| 3198 document_state->set_load_type(DocumentState::RELOAD); | 2969 document_state->set_load_type(DocumentState::RELOAD); |
| 3199 else if (params.page_state.IsValid()) | 2970 else if (params.page_state.IsValid()) |
| 3200 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 2971 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
| 3201 else | 2972 else |
| 3202 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 2973 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
| 3203 | 2974 |
| 3204 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); | 2975 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); |
| 3205 internal_data->set_must_reset_scroll_and_scale_state( | 2976 internal_data->set_must_reset_scroll_and_scale_state( |
| 3206 params.navigation_type == | 2977 params.navigation_type == |
| 3207 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 2978 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
| 3208 document_state->set_can_load_local_resources(params.can_load_local_resources); | 2979 document_state->set_can_load_local_resources(params.can_load_local_resources); |
| 3209 } | 2980 } |
| 3210 | 2981 |
| 3211 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { | 2982 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { |
| 3212 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); | 2983 const FrameMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
| 3213 NavigationState* navigation_state = NULL; | 2984 NavigationState* navigation_state = NULL; |
| 3214 | 2985 |
| 3215 // A navigation resulting from loading a javascript URL should not be treated | 2986 // A navigation resulting from loading a javascript URL should not be treated |
| 3216 // as a browser initiated event. Instead, we want it to look as if the page | 2987 // as a browser initiated event. Instead, we want it to look as if the page |
| 3217 // initiated any load resulting from JS execution. | 2988 // initiated any load resulting from JS execution. |
| 3218 if (!params.url.SchemeIs(kJavaScriptScheme)) { | 2989 if (!params.url.SchemeIs(kJavaScriptScheme)) { |
| 3219 navigation_state = NavigationState::CreateBrowserInitiated( | 2990 navigation_state = NavigationState::CreateBrowserInitiated( |
| 3220 params.page_id, | 2991 params.page_id, |
| 3221 params.pending_history_list_offset, | 2992 params.pending_history_list_offset, |
| 3222 params.should_clear_history_list, | 2993 params.should_clear_history_list, |
| (...skipping 2554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5777 for (size_t i = 0; i < icon_urls.size(); i++) { | 5548 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 5778 WebURL url = icon_urls[i].iconURL(); | 5549 WebURL url = icon_urls[i].iconURL(); |
| 5779 if (!url.isEmpty()) | 5550 if (!url.isEmpty()) |
| 5780 urls.push_back(FaviconURL(url, | 5551 urls.push_back(FaviconURL(url, |
| 5781 ToFaviconType(icon_urls[i].iconType()))); | 5552 ToFaviconType(icon_urls[i].iconType()))); |
| 5782 } | 5553 } |
| 5783 SendUpdateFaviconURL(urls); | 5554 SendUpdateFaviconURL(urls); |
| 5784 } | 5555 } |
| 5785 | 5556 |
| 5786 } // namespace content | 5557 } // namespace content |
| OLD | NEW |