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

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

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

Powered by Google App Engine
This is Rietveld 408576698