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

Side by Side Diff: trunk/src/content/renderer/render_view_impl.cc

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

Powered by Google App Engine
This is Rietveld 408576698