| 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" | |
| 46 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 45 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 47 #include "content/common/input_messages.h" | 46 #include "content/common/input_messages.h" |
| 48 #include "content/common/java_bridge_messages.h" | 47 #include "content/common/java_bridge_messages.h" |
| 49 #include "content/common/pepper_messages.h" | 48 #include "content/common/pepper_messages.h" |
| 50 #include "content/common/socket_stream_handle_data.h" | 49 #include "content/common/socket_stream_handle_data.h" |
| 51 #include "content/common/ssl_status_serialization.h" | 50 #include "content/common/ssl_status_serialization.h" |
| 52 #include "content/common/view_messages.h" | 51 #include "content/common/view_messages.h" |
| 53 #include "content/public/common/bindings_policy.h" | 52 #include "content/public/common/bindings_policy.h" |
| 54 #include "content/public/common/content_client.h" | 53 #include "content/public/common/content_client.h" |
| 55 #include "content/public/common/content_constants.h" | 54 #include "content/public/common/content_constants.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 354 |
| 356 #if defined(OS_ANDROID) | 355 #if defined(OS_ANDROID) |
| 357 // Delay between tapping in content and launching the associated android intent. | 356 // Delay between tapping in content and launching the associated android intent. |
| 358 // Used to allow users see what has been recognized as content. | 357 // Used to allow users see what has been recognized as content. |
| 359 const size_t kContentIntentDelayMilliseconds = 700; | 358 const size_t kContentIntentDelayMilliseconds = 700; |
| 360 #endif | 359 #endif |
| 361 | 360 |
| 362 static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) = | 361 static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) = |
| 363 NULL; | 362 NULL; |
| 364 | 363 |
| 365 // static | 364 static bool IsReload(const ViewMsg_Navigate_Params& params) { |
| 366 bool RenderViewImpl::IsReload(const FrameMsg_Navigate_Params& params) { | |
| 367 return | 365 return |
| 368 params.navigation_type == FrameMsg_Navigate_Type::RELOAD || | 366 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
| 369 params.navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE || | 367 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE || |
| 370 params.navigation_type == | 368 params.navigation_type == |
| 371 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; | 369 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
| 372 } | 370 } |
| 373 | 371 |
| 374 // static | 372 // static |
| 375 Referrer RenderViewImpl::GetReferrerFromRequest( | 373 Referrer RenderViewImpl::GetReferrerFromRequest( |
| 376 WebFrame* frame, | 374 WebFrame* frame, |
| 377 const WebURLRequest& request) { | 375 const WebURLRequest& request) { |
| 378 return Referrer(GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), | 376 return Referrer(GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 379 request.referrerPolicy()); | 377 request.referrerPolicy()); |
| 380 } | 378 } |
| 381 | 379 |
| 380 NOINLINE static void CrashIntentionally() { |
| 381 // NOTE(shess): Crash directly rather than using NOTREACHED() so |
| 382 // that the signature is easier to triage in crash reports. |
| 383 volatile int* zero = NULL; |
| 384 *zero = 0; |
| 385 } |
| 386 |
| 387 #if defined(ADDRESS_SANITIZER) |
| 388 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { |
| 389 // NOTE(rogerm): We intentionally perform an invalid heap access here in |
| 390 // order to trigger an Address Sanitizer (ASAN) error report. |
| 391 static const char kCrashDomain[] = "crash"; |
| 392 static const char kHeapOverflow[] = "/heap-overflow"; |
| 393 static const char kHeapUnderflow[] = "/heap-underflow"; |
| 394 static const char kUseAfterFree[] = "/use-after-free"; |
| 395 static const int kArraySize = 5; |
| 396 |
| 397 if (!url.DomainIs(kCrashDomain, sizeof(kCrashDomain) - 1)) |
| 398 return; |
| 399 |
| 400 if (!url.has_path()) |
| 401 return; |
| 402 |
| 403 scoped_ptr<int[]> array(new int[kArraySize]); |
| 404 std::string crash_type(url.path()); |
| 405 int dummy = 0; |
| 406 if (crash_type == kHeapOverflow) { |
| 407 dummy = array[kArraySize]; |
| 408 } else if (crash_type == kHeapUnderflow ) { |
| 409 dummy = array[-1]; |
| 410 } else if (crash_type == kUseAfterFree) { |
| 411 int* dangling = array.get(); |
| 412 array.reset(); |
| 413 dummy = dangling[kArraySize / 2]; |
| 414 } |
| 415 |
| 416 // Make sure the assignments to the dummy value aren't optimized away. |
| 417 base::debug::Alias(&dummy); |
| 418 } |
| 419 #endif // ADDRESS_SANITIZER |
| 420 |
| 421 static void MaybeHandleDebugURL(const GURL& url) { |
| 422 if (!url.SchemeIs(kChromeUIScheme)) |
| 423 return; |
| 424 if (url == GURL(kChromeUICrashURL)) { |
| 425 CrashIntentionally(); |
| 426 } else if (url == GURL(kChromeUIKillURL)) { |
| 427 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); |
| 428 } else if (url == GURL(kChromeUIHangURL)) { |
| 429 for (;;) { |
| 430 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
| 431 } |
| 432 } else if (url == GURL(kChromeUIShorthangURL)) { |
| 433 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
| 434 } |
| 435 |
| 436 #if defined(ADDRESS_SANITIZER) |
| 437 MaybeTriggerAsanError(url); |
| 438 #endif // ADDRESS_SANITIZER |
| 439 } |
| 440 |
| 382 // Returns false unless this is a top-level navigation. | 441 // Returns false unless this is a top-level navigation. |
| 383 static bool IsTopLevelNavigation(WebFrame* frame) { | 442 static bool IsTopLevelNavigation(WebFrame* frame) { |
| 384 return frame->parent() == NULL; | 443 return frame->parent() == NULL; |
| 385 } | 444 } |
| 386 | 445 |
| 387 // Returns false unless this is a top-level navigation that crosses origins. | 446 // Returns false unless this is a top-level navigation that crosses origins. |
| 388 static bool IsNonLocalTopLevelNavigation(const GURL& url, | 447 static bool IsNonLocalTopLevelNavigation(const GURL& url, |
| 389 WebFrame* frame, | 448 WebFrame* frame, |
| 390 WebNavigationType type, | 449 WebNavigationType type, |
| 391 bool is_form_post) { | 450 bool is_form_post) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 410 blink::WebFrame* opener = frame->opener(); | 469 blink::WebFrame* opener = frame->opener(); |
| 411 if (!opener) | 470 if (!opener) |
| 412 return true; | 471 return true; |
| 413 | 472 |
| 414 if (url.GetOrigin() != GURL(opener->document().url()).GetOrigin()) | 473 if (url.GetOrigin() != GURL(opener->document().url()).GetOrigin()) |
| 415 return true; | 474 return true; |
| 416 } | 475 } |
| 417 return false; | 476 return false; |
| 418 } | 477 } |
| 419 | 478 |
| 420 // static | 479 static void NotifyTimezoneChange(blink::WebFrame* frame) { |
| 421 void RenderViewImpl::NotifyTimezoneChange(blink::WebFrame* frame) { | |
| 422 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 480 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
| 423 v8::Context::Scope context_scope(frame->mainWorldScriptContext()); | 481 v8::Context::Scope context_scope(frame->mainWorldScriptContext()); |
| 424 v8::Date::DateTimeConfigurationChangeNotification(v8::Isolate::GetCurrent()); | 482 v8::Date::DateTimeConfigurationChangeNotification(v8::Isolate::GetCurrent()); |
| 425 blink::WebFrame* child = frame->firstChild(); | 483 blink::WebFrame* child = frame->firstChild(); |
| 426 for (; child; child = child->nextSibling()) | 484 for (; child; child = child->nextSibling()) |
| 427 NotifyTimezoneChange(child); | 485 NotifyTimezoneChange(child); |
| 428 } | 486 } |
| 429 | 487 |
| 430 static WindowOpenDisposition NavigationPolicyToDisposition( | 488 static WindowOpenDisposition NavigationPolicyToDisposition( |
| 431 WebNavigationPolicy policy) { | 489 WebNavigationPolicy policy) { |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) | 1191 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) |
| 1134 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) | 1192 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) |
| 1135 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, | 1193 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, |
| 1136 OnScrollFocusedEditableNodeIntoRect) | 1194 OnScrollFocusedEditableNodeIntoRect) |
| 1137 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) | 1195 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) |
| 1138 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) | 1196 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) |
| 1139 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, | 1197 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, |
| 1140 OnSetEditCommandsForNextKeyEvent) | 1198 OnSetEditCommandsForNextKeyEvent) |
| 1141 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) | 1199 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) |
| 1142 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect) | 1200 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect) |
| 1143 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) | 1201 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
| 1144 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) | 1202 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
| 1145 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) | 1203 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) |
| 1146 IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName) | 1204 IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName) |
| 1147 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets, | 1205 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets, |
| 1148 OnSetEditableSelectionOffsets) | 1206 OnSetEditableSelectionOffsets) |
| 1149 IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText, | 1207 IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText, |
| 1150 OnSetCompositionFromExistingText) | 1208 OnSetCompositionFromExistingText) |
| 1151 IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete, | 1209 IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete, |
| 1152 OnExtendSelectionAndDelete) | 1210 OnExtendSelectionAndDelete) |
| 1153 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 1211 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 | 1303 |
| 1246 if (!msg_is_ok) { | 1304 if (!msg_is_ok) { |
| 1247 // The message had a handler, but its deserialization failed. | 1305 // The message had a handler, but its deserialization failed. |
| 1248 // Kill the renderer to avoid potential spoofing attacks. | 1306 // Kill the renderer to avoid potential spoofing attacks. |
| 1249 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; | 1307 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
| 1250 } | 1308 } |
| 1251 | 1309 |
| 1252 return handled; | 1310 return handled; |
| 1253 } | 1311 } |
| 1254 | 1312 |
| 1255 void RenderViewImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { | 1313 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
| 1314 MaybeHandleDebugURL(params.url); |
| 1315 if (!webview()) |
| 1316 return; |
| 1317 |
| 1256 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); | 1318 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); |
| 1319 |
| 1320 bool is_reload = IsReload(params); |
| 1321 WebURLRequest::CachePolicy cache_policy = |
| 1322 WebURLRequest::UseProtocolCachePolicy; |
| 1323 |
| 1324 // If this is a stale back/forward (due to a recent navigation the browser |
| 1325 // didn't know about), ignore it. |
| 1326 if (IsBackForwardToStaleEntry(params, is_reload)) |
| 1327 return; |
| 1328 |
| 1329 // Swap this renderer back in if necessary. |
| 1330 if (is_swapped_out_) { |
| 1331 // We marked the view as hidden when swapping the view out, so be sure to |
| 1332 // reset the visibility state before navigating to the new URL. |
| 1333 webview()->setVisibilityState(visibilityState(), false); |
| 1334 |
| 1335 // If this is an attempt to reload while we are swapped out, we should not |
| 1336 // reload swappedout://, but the previous page, which is stored in |
| 1337 // params.state. Setting is_reload to false will treat this like a back |
| 1338 // navigation to accomplish that. |
| 1339 is_reload = false; |
| 1340 cache_policy = WebURLRequest::ReloadIgnoringCacheData; |
| 1341 |
| 1342 // We refresh timezone when a view is swapped in since timezone |
| 1343 // can get out of sync when the system timezone is updated while |
| 1344 // the view is swapped out. |
| 1345 NotifyTimezoneChange(webview()->mainFrame()); |
| 1346 |
| 1347 SetSwappedOut(false); |
| 1348 } |
| 1349 |
| 1350 if (params.should_clear_history_list) { |
| 1351 CHECK_EQ(params.pending_history_list_offset, -1); |
| 1352 CHECK_EQ(params.current_history_list_offset, -1); |
| 1353 CHECK_EQ(params.current_history_list_length, 0); |
| 1354 } |
| 1355 history_list_offset_ = params.current_history_list_offset; |
| 1356 history_list_length_ = params.current_history_list_length; |
| 1357 if (history_list_length_ >= 0) |
| 1358 history_page_ids_.resize(history_list_length_, -1); |
| 1359 if (params.pending_history_list_offset >= 0 && |
| 1360 params.pending_history_list_offset < history_list_length_) |
| 1361 history_page_ids_[params.pending_history_list_offset] = params.page_id; |
| 1362 |
| 1363 GetContentClient()->SetActiveURL(params.url); |
| 1364 |
| 1365 WebFrame* frame = webview()->mainFrame(); |
| 1366 if (!params.frame_to_navigate.empty()) { |
| 1367 frame = webview()->findFrameByName( |
| 1368 WebString::fromUTF8(params.frame_to_navigate)); |
| 1369 CHECK(frame) << "Invalid frame name passed: " << params.frame_to_navigate; |
| 1370 } |
| 1371 |
| 1372 if (is_reload && frame->currentHistoryItem().isNull()) { |
| 1373 // We cannot reload if we do not have any history state. This happens, for |
| 1374 // example, when recovering from a crash. |
| 1375 is_reload = false; |
| 1376 cache_policy = WebURLRequest::ReloadIgnoringCacheData; |
| 1377 } |
| 1378 |
| 1379 pending_navigation_params_.reset(new ViewMsg_Navigate_Params(params)); |
| 1380 |
| 1381 // If we are reloading, then WebKit will use the history state of the current |
| 1382 // page, so we should just ignore any given history state. Otherwise, if we |
| 1383 // have history state, then we need to navigate to it, which corresponds to a |
| 1384 // back/forward navigation event. |
| 1385 if (is_reload) { |
| 1386 bool reload_original_url = |
| 1387 (params.navigation_type == |
| 1388 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
| 1389 bool ignore_cache = (params.navigation_type == |
| 1390 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
| 1391 |
| 1392 if (reload_original_url) |
| 1393 frame->reloadWithOverrideURL(params.url, true); |
| 1394 else |
| 1395 frame->reload(ignore_cache); |
| 1396 } else if (params.page_state.IsValid()) { |
| 1397 // We must know the page ID of the page we are navigating back to. |
| 1398 DCHECK_NE(params.page_id, -1); |
| 1399 WebHistoryItem item = PageStateToHistoryItem(params.page_state); |
| 1400 if (!item.isNull()) { |
| 1401 // Ensure we didn't save the swapped out URL in UpdateState, since the |
| 1402 // browser should never be telling us to navigate to swappedout://. |
| 1403 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); |
| 1404 frame->loadHistoryItem(item, cache_policy); |
| 1405 } |
| 1406 } else if (!params.base_url_for_data_url.is_empty()) { |
| 1407 // A loadData request with a specified base URL. |
| 1408 std::string mime_type, charset, data; |
| 1409 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
| 1410 frame->loadData( |
| 1411 WebData(data.c_str(), data.length()), |
| 1412 WebString::fromUTF8(mime_type), |
| 1413 WebString::fromUTF8(charset), |
| 1414 params.base_url_for_data_url, |
| 1415 params.history_url_for_data_url, |
| 1416 false); |
| 1417 } else { |
| 1418 CHECK(false) << |
| 1419 "Invalid URL passed: " << params.url.possibly_invalid_spec(); |
| 1420 } |
| 1421 } else { |
| 1422 // Navigate to the given URL. |
| 1423 WebURLRequest request(params.url); |
| 1424 |
| 1425 // A session history navigation should have been accompanied by state. |
| 1426 CHECK_EQ(params.page_id, -1); |
| 1427 |
| 1428 if (frame->isViewSourceModeEnabled()) |
| 1429 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); |
| 1430 |
| 1431 if (params.referrer.url.is_valid()) { |
| 1432 WebString referrer = WebSecurityPolicy::generateReferrerHeader( |
| 1433 params.referrer.policy, |
| 1434 params.url, |
| 1435 WebString::fromUTF8(params.referrer.url.spec())); |
| 1436 if (!referrer.isEmpty()) |
| 1437 request.setHTTPReferrer(referrer, params.referrer.policy); |
| 1438 } |
| 1439 |
| 1440 if (!params.extra_headers.empty()) { |
| 1441 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), |
| 1442 params.extra_headers.end(), "\n"); |
| 1443 i.GetNext(); ) { |
| 1444 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
| 1445 WebString::fromUTF8(i.values())); |
| 1446 } |
| 1447 } |
| 1448 |
| 1449 if (params.is_post) { |
| 1450 request.setHTTPMethod(WebString::fromUTF8("POST")); |
| 1451 |
| 1452 // Set post data. |
| 1453 WebHTTPBody http_body; |
| 1454 http_body.initialize(); |
| 1455 const char* data = NULL; |
| 1456 if (params.browser_initiated_post_data.size()) { |
| 1457 data = reinterpret_cast<const char*>( |
| 1458 ¶ms.browser_initiated_post_data.front()); |
| 1459 } |
| 1460 http_body.appendData( |
| 1461 WebData(data, params.browser_initiated_post_data.size())); |
| 1462 request.setHTTPBody(http_body); |
| 1463 } |
| 1464 |
| 1465 frame->loadRequest(request); |
| 1466 |
| 1467 // If this is a cross-process navigation, the browser process will send |
| 1468 // along the proper navigation start value. |
| 1469 if (!params.browser_navigation_start.is_null() && |
| 1470 frame->provisionalDataSource()) { |
| 1471 // browser_navigation_start is likely before this process existed, so we |
| 1472 // can't use InterProcessTimeTicksConverter. Instead, the best we can do |
| 1473 // is just ensure we don't report a bogus value in the future. |
| 1474 base::TimeTicks navigation_start = std::min( |
| 1475 base::TimeTicks::Now(), params.browser_navigation_start); |
| 1476 double navigation_start_seconds = |
| 1477 (navigation_start - base::TimeTicks()).InSecondsF(); |
| 1478 frame->provisionalDataSource()->setNavigationStartTime( |
| 1479 navigation_start_seconds); |
| 1480 } |
| 1481 } |
| 1482 |
| 1483 // In case LoadRequest failed before DidCreateDataSource was called. |
| 1484 pending_navigation_params_.reset(); |
| 1257 } | 1485 } |
| 1258 | 1486 |
| 1259 bool RenderViewImpl::IsBackForwardToStaleEntry( | 1487 bool RenderViewImpl::IsBackForwardToStaleEntry( |
| 1260 const FrameMsg_Navigate_Params& params, | 1488 const ViewMsg_Navigate_Params& params, |
| 1261 bool is_reload) { | 1489 bool is_reload) { |
| 1262 // Make sure this isn't a back/forward to an entry we have already cropped | 1490 // Make sure this isn't a back/forward to an entry we have already cropped |
| 1263 // or replaced from our history, before the browser knew about it. If so, | 1491 // or replaced from our history, before the browser knew about it. If so, |
| 1264 // a new navigation has committed in the mean time, and we can ignore this. | 1492 // a new navigation has committed in the mean time, and we can ignore this. |
| 1265 bool is_back_forward = !is_reload && params.page_state.IsValid(); | 1493 bool is_back_forward = !is_reload && params.page_state.IsValid(); |
| 1266 | 1494 |
| 1267 // Note: if the history_list_length_ is 0 for a back/forward, we must be | 1495 // Note: if the history_list_length_ is 0 for a back/forward, we must be |
| 1268 // restoring from a previous session. We'll update our state in OnNavigate. | 1496 // restoring from a previous session. We'll update our state in OnNavigate. |
| 1269 if (!is_back_forward || history_list_length_ <= 0) | 1497 if (!is_back_forward || history_list_length_ <= 0) |
| 1270 return false; | 1498 return false; |
| (...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2910 break; | 3138 break; |
| 2911 } | 3139 } |
| 2912 } | 3140 } |
| 2913 | 3141 |
| 2914 FOR_EACH_OBSERVER( | 3142 FOR_EACH_OBSERVER( |
| 2915 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); | 3143 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); |
| 2916 } | 3144 } |
| 2917 | 3145 |
| 2918 void RenderViewImpl::PopulateDocumentStateFromPending( | 3146 void RenderViewImpl::PopulateDocumentStateFromPending( |
| 2919 DocumentState* document_state) { | 3147 DocumentState* document_state) { |
| 2920 const FrameMsg_Navigate_Params& params = *pending_navigation_params_.get(); | 3148 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
| 2921 document_state->set_request_time(params.request_time); | 3149 document_state->set_request_time(params.request_time); |
| 2922 | 3150 |
| 2923 InternalDocumentStateData* internal_data = | 3151 InternalDocumentStateData* internal_data = |
| 2924 InternalDocumentStateData::FromDocumentState(document_state); | 3152 InternalDocumentStateData::FromDocumentState(document_state); |
| 2925 | 3153 |
| 2926 if (!params.url.SchemeIs(kJavaScriptScheme) && | 3154 if (!params.url.SchemeIs(kJavaScriptScheme) && |
| 2927 params.navigation_type == FrameMsg_Navigate_Type::RESTORE) { | 3155 params.navigation_type == ViewMsg_Navigate_Type::RESTORE) { |
| 2928 // We're doing a load of a page that was restored from the last session. By | 3156 // We're doing a load of a page that was restored from the last session. By |
| 2929 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which | 3157 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
| 2930 // can result in stale data for pages that are set to expire. We explicitly | 3158 // can result in stale data for pages that are set to expire. We explicitly |
| 2931 // override that by setting the policy here so that as necessary we load | 3159 // override that by setting the policy here so that as necessary we load |
| 2932 // from the network. | 3160 // from the network. |
| 2933 // | 3161 // |
| 2934 // TODO(davidben): Remove this in favor of passing a cache policy to the | 3162 // TODO(davidben): Remove this in favor of passing a cache policy to the |
| 2935 // loadHistoryItem call in OnNavigate. That requires not overloading | 3163 // loadHistoryItem call in OnNavigate. That requires not overloading |
| 2936 // UseProtocolCachePolicy to mean both "normal load" and "determine cache | 3164 // UseProtocolCachePolicy to mean both "normal load" and "determine cache |
| 2937 // policy based on load type, etc". | 3165 // policy based on load type, etc". |
| 2938 internal_data->set_cache_policy_override( | 3166 internal_data->set_cache_policy_override( |
| 2939 WebURLRequest::UseProtocolCachePolicy); | 3167 WebURLRequest::UseProtocolCachePolicy); |
| 2940 } | 3168 } |
| 2941 | 3169 |
| 2942 if (IsReload(params)) | 3170 if (IsReload(params)) |
| 2943 document_state->set_load_type(DocumentState::RELOAD); | 3171 document_state->set_load_type(DocumentState::RELOAD); |
| 2944 else if (params.page_state.IsValid()) | 3172 else if (params.page_state.IsValid()) |
| 2945 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 3173 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
| 2946 else | 3174 else |
| 2947 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 3175 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
| 2948 | 3176 |
| 2949 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); | 3177 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); |
| 2950 internal_data->set_must_reset_scroll_and_scale_state( | 3178 internal_data->set_must_reset_scroll_and_scale_state( |
| 2951 params.navigation_type == | 3179 params.navigation_type == |
| 2952 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 3180 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
| 2953 document_state->set_can_load_local_resources(params.can_load_local_resources); | 3181 document_state->set_can_load_local_resources(params.can_load_local_resources); |
| 2954 } | 3182 } |
| 2955 | 3183 |
| 2956 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { | 3184 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { |
| 2957 const FrameMsg_Navigate_Params& params = *pending_navigation_params_.get(); | 3185 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
| 2958 NavigationState* navigation_state = NULL; | 3186 NavigationState* navigation_state = NULL; |
| 2959 | 3187 |
| 2960 // A navigation resulting from loading a javascript URL should not be treated | 3188 // A navigation resulting from loading a javascript URL should not be treated |
| 2961 // as a browser initiated event. Instead, we want it to look as if the page | 3189 // as a browser initiated event. Instead, we want it to look as if the page |
| 2962 // initiated any load resulting from JS execution. | 3190 // initiated any load resulting from JS execution. |
| 2963 if (!params.url.SchemeIs(kJavaScriptScheme)) { | 3191 if (!params.url.SchemeIs(kJavaScriptScheme)) { |
| 2964 navigation_state = NavigationState::CreateBrowserInitiated( | 3192 navigation_state = NavigationState::CreateBrowserInitiated( |
| 2965 params.page_id, | 3193 params.page_id, |
| 2966 params.pending_history_list_offset, | 3194 params.pending_history_list_offset, |
| 2967 params.should_clear_history_list, | 3195 params.should_clear_history_list, |
| (...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5523 for (size_t i = 0; i < icon_urls.size(); i++) { | 5751 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 5524 WebURL url = icon_urls[i].iconURL(); | 5752 WebURL url = icon_urls[i].iconURL(); |
| 5525 if (!url.isEmpty()) | 5753 if (!url.isEmpty()) |
| 5526 urls.push_back(FaviconURL(url, | 5754 urls.push_back(FaviconURL(url, |
| 5527 ToFaviconType(icon_urls[i].iconType()))); | 5755 ToFaviconType(icon_urls[i].iconType()))); |
| 5528 } | 5756 } |
| 5529 SendUpdateFaviconURL(urls); | 5757 SendUpdateFaviconURL(urls); |
| 5530 } | 5758 } |
| 5531 | 5759 |
| 5532 } // namespace content | 5760 } // namespace content |
| OLD | NEW |