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

Side by Side Diff: Source/WebCore/loader/HistoryController.cpp

Issue 13861033: Remove Apple's unused implementation of private browsing from WebCore (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // 1) Back/forward: The m_currentItem is part of this mechanism. 353 // 1) Back/forward: The m_currentItem is part of this mechanism.
354 // 2) Global history: Handled by the client. 354 // 2) Global history: Handled by the client.
355 // 3) Visited links: Handled by the PageGroup. 355 // 3) Visited links: Handled by the PageGroup.
356 356
357 void HistoryController::updateForStandardLoad(HistoryUpdateType updateType) 357 void HistoryController::updateForStandardLoad(HistoryUpdateType updateType)
358 { 358 {
359 LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s ", m_frame->loader()->documentLoader()->url().string().ascii().data()); 359 LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s ", m_frame->loader()->documentLoader()->url().string().ascii().data());
360 360
361 FrameLoader* frameLoader = m_frame->loader(); 361 FrameLoader* frameLoader = m_frame->loader();
362 362
363 Settings* settings = m_frame->settings();
364 bool needPrivacy = !settings || settings->privateBrowsingEnabled();
365 const KURL& historyURL = frameLoader->documentLoader()->urlForHistory(); 363 const KURL& historyURL = frameLoader->documentLoader()->urlForHistory();
366 364
367 if (!frameLoader->documentLoader()->isClientRedirect()) { 365 if (!frameLoader->documentLoader()->isClientRedirect()) {
368 if (!historyURL.isEmpty()) { 366 if (!historyURL.isEmpty()) {
369 if (updateType != UpdateAllExceptBackForwardList) 367 if (updateType != UpdateAllExceptBackForwardList)
370 updateBackForwardListClippedAtTarget(true); 368 updateBackForwardListClippedAtTarget(true);
371 if (!needPrivacy) { 369 frameLoader->client()->updateGlobalHistory();
372 frameLoader->client()->updateGlobalHistory(); 370 frameLoader->documentLoader()->setDidCreateGlobalHistoryEntry(true);
373 frameLoader->documentLoader()->setDidCreateGlobalHistoryEntry(tr ue); 371 if (frameLoader->documentLoader()->unreachableURL().isEmpty())
374 if (frameLoader->documentLoader()->unreachableURL().isEmpty()) 372 frameLoader->client()->updateGlobalHistoryRedirectLinks();
375 frameLoader->client()->updateGlobalHistoryRedirectLinks();
376 }
377 373
378 m_frame->loader()->client()->updateGlobalHistoryItemForPage(); 374 m_frame->loader()->client()->updateGlobalHistoryItemForPage();
379 } 375 }
380 } else { 376 } else {
381 // The client redirect replaces the current history item. 377 // The client redirect replaces the current history item.
382 updateCurrentItem(); 378 updateCurrentItem();
383 } 379 }
384 380
385 if (!historyURL.isEmpty() && !needPrivacy) { 381 if (!historyURL.isEmpty()) {
386 if (Page* page = m_frame->page()) 382 if (Page* page = m_frame->page())
387 addVisitedLink(page, historyURL); 383 addVisitedLink(page, historyURL);
388 384
389 if (!frameLoader->documentLoader()->didCreateGlobalHistoryEntry() && fra meLoader->documentLoader()->unreachableURL().isEmpty() && !m_frame->document()-> url().isEmpty()) 385 if (!frameLoader->documentLoader()->didCreateGlobalHistoryEntry() && fra meLoader->documentLoader()->unreachableURL().isEmpty() && !m_frame->document()-> url().isEmpty())
390 frameLoader->client()->updateGlobalHistoryRedirectLinks(); 386 frameLoader->client()->updateGlobalHistoryRedirectLinks();
391 } 387 }
392 } 388 }
393 389
394 void HistoryController::updateForRedirectWithLockedBackForwardList() 390 void HistoryController::updateForRedirectWithLockedBackForwardList()
395 { 391 {
396 #if !LOG_DISABLED 392 #if !LOG_DISABLED
397 if (m_frame->loader()->documentLoader()) 393 if (m_frame->loader()->documentLoader())
398 LOG(History, "WebCoreHistory: Updating History for redirect load in fram e %s", m_frame->loader()->documentLoader()->title().string().utf8().data()); 394 LOG(History, "WebCoreHistory: Updating History for redirect load in fram e %s", m_frame->loader()->documentLoader()->title().string().utf8().data());
399 #endif 395 #endif
400 396
401 Settings* settings = m_frame->settings();
402 bool needPrivacy = !settings || settings->privateBrowsingEnabled();
403 const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory( ); 397 const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory( );
404 398
405 if (m_frame->loader()->documentLoader()->isClientRedirect()) { 399 if (m_frame->loader()->documentLoader()->isClientRedirect()) {
406 if (!m_currentItem && !m_frame->tree()->parent()) { 400 if (!m_currentItem && !m_frame->tree()->parent()) {
407 if (!historyURL.isEmpty()) { 401 if (!historyURL.isEmpty()) {
408 updateBackForwardListClippedAtTarget(true); 402 updateBackForwardListClippedAtTarget(true);
409 if (!needPrivacy) { 403 m_frame->loader()->client()->updateGlobalHistory();
410 m_frame->loader()->client()->updateGlobalHistory(); 404 m_frame->loader()->documentLoader()->setDidCreateGlobalHistoryEn try(true);
411 m_frame->loader()->documentLoader()->setDidCreateGlobalHisto ryEntry(true); 405 if (m_frame->loader()->documentLoader()->unreachableURL().isEmpt y())
412 if (m_frame->loader()->documentLoader()->unreachableURL().is Empty()) 406 m_frame->loader()->client()->updateGlobalHistoryRedirectLink s();
413 m_frame->loader()->client()->updateGlobalHistoryRedirect Links();
414 }
415 407
416 m_frame->loader()->client()->updateGlobalHistoryItemForPage(); 408 m_frame->loader()->client()->updateGlobalHistoryItemForPage();
417 } 409 }
418 } 410 }
419 // The client redirect replaces the current history item. 411 // The client redirect replaces the current history item.
420 updateCurrentItem(); 412 updateCurrentItem();
421 } else { 413 } else {
422 Frame* parentFrame = m_frame->tree()->parent(); 414 Frame* parentFrame = m_frame->tree()->parent();
423 if (parentFrame && parentFrame->loader()->history()->m_currentItem) 415 if (parentFrame && parentFrame->loader()->history()->m_currentItem)
424 parentFrame->loader()->history()->m_currentItem->setChildItem(create Item()); 416 parentFrame->loader()->history()->m_currentItem->setChildItem(create Item());
425 } 417 }
426 418
427 if (!historyURL.isEmpty() && !needPrivacy) { 419 if (!historyURL.isEmpty()) {
428 if (Page* page = m_frame->page()) 420 if (Page* page = m_frame->page())
429 addVisitedLink(page, historyURL); 421 addVisitedLink(page, historyURL);
430 422
431 if (!m_frame->loader()->documentLoader()->didCreateGlobalHistoryEntry() && m_frame->loader()->documentLoader()->unreachableURL().isEmpty() && !m_frame-> document()->url().isEmpty()) 423 if (!m_frame->loader()->documentLoader()->didCreateGlobalHistoryEntry() && m_frame->loader()->documentLoader()->unreachableURL().isEmpty() && !m_frame-> document()->url().isEmpty())
432 m_frame->loader()->client()->updateGlobalHistoryRedirectLinks(); 424 m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
433 } 425 }
434 } 426 }
435 427
436 void HistoryController::updateForClientRedirect() 428 void HistoryController::updateForClientRedirect()
437 { 429 {
438 #if !LOG_DISABLED 430 #if !LOG_DISABLED
439 if (m_frame->loader()->documentLoader()) 431 if (m_frame->loader()->documentLoader())
440 LOG(History, "WebCoreHistory: Updating History for client redirect in fr ame %s", m_frame->loader()->documentLoader()->title().string().utf8().data()); 432 LOG(History, "WebCoreHistory: Updating History for client redirect in fr ame %s", m_frame->loader()->documentLoader()->title().string().utf8().data());
441 #endif 433 #endif
442 434
443 // Clear out form data so we don't try to restore it into the incoming page. Must happen after 435 // Clear out form data so we don't try to restore it into the incoming page. Must happen after
444 // webcore has closed the URL and saved away the form state. 436 // webcore has closed the URL and saved away the form state.
445 if (m_currentItem) { 437 if (m_currentItem) {
446 m_currentItem->clearDocumentState(); 438 m_currentItem->clearDocumentState();
447 m_currentItem->clearScrollPoint(); 439 m_currentItem->clearScrollPoint();
448 } 440 }
449 441
450 Settings* settings = m_frame->settings();
451 bool needPrivacy = !settings || settings->privateBrowsingEnabled();
452 const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory( ); 442 const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory( );
453 443
454 if (!historyURL.isEmpty() && !needPrivacy) { 444 if (!historyURL.isEmpty()) {
455 if (Page* page = m_frame->page()) 445 if (Page* page = m_frame->page())
456 addVisitedLink(page, historyURL); 446 addVisitedLink(page, historyURL);
457 } 447 }
458 } 448 }
459 449
460 void HistoryController::updateForCommit() 450 void HistoryController::updateForCommit()
461 { 451 {
462 FrameLoader* frameLoader = m_frame->loader(); 452 FrameLoader* frameLoader = m_frame->loader();
463 #if !LOG_DISABLED 453 #if !LOG_DISABLED
464 if (frameLoader->documentLoader()) 454 if (frameLoader->documentLoader())
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // Iterate over the rest of the tree 523 // Iterate over the rest of the tree
534 for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tre e()->nextSibling()) 524 for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tre e()->nextSibling())
535 child->loader()->history()->recursiveUpdateForCommit(); 525 child->loader()->history()->recursiveUpdateForCommit();
536 } 526 }
537 527
538 void HistoryController::updateForSameDocumentNavigation() 528 void HistoryController::updateForSameDocumentNavigation()
539 { 529 {
540 if (m_frame->document()->url().isEmpty()) 530 if (m_frame->document()->url().isEmpty())
541 return; 531 return;
542 532
543 Settings* settings = m_frame->settings();
544 if (!settings || settings->privateBrowsingEnabled())
545 return;
546
547 Page* page = m_frame->page(); 533 Page* page = m_frame->page();
548 if (!page) 534 if (!page)
549 return; 535 return;
550 536
551 addVisitedLink(page, m_frame->document()->url()); 537 addVisitedLink(page, m_frame->document()->url());
552 page->mainFrame()->loader()->history()->recursiveUpdateForSameDocumentNaviga tion(); 538 page->mainFrame()->loader()->history()->recursiveUpdateForSameDocumentNaviga tion();
553 539
554 if (m_currentItem) { 540 if (m_currentItem) {
555 m_currentItem->setURL(m_frame->document()->url()); 541 m_currentItem->setURL(m_frame->document()->url());
556 m_frame->loader()->client()->updateGlobalHistory(); 542 m_frame->loader()->client()->updateGlobalHistory();
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 RefPtr<HistoryItem> topItem = page->mainFrame()->loader()->history()->create ItemTree(m_frame, false); 848 RefPtr<HistoryItem> topItem = page->mainFrame()->loader()->history()->create ItemTree(m_frame, false);
863 849
864 // Override data in the current item (created by createItemTree) to reflect 850 // Override data in the current item (created by createItemTree) to reflect
865 // the pushState() arguments. 851 // the pushState() arguments.
866 m_currentItem->setTitle(title); 852 m_currentItem->setTitle(title);
867 m_currentItem->setStateObject(stateObject); 853 m_currentItem->setStateObject(stateObject);
868 m_currentItem->setURLString(urlString); 854 m_currentItem->setURLString(urlString);
869 855
870 page->backForward()->addItem(topItem.release()); 856 page->backForward()->addItem(topItem.release());
871 857
872 Settings* settings = m_frame->settings();
873 if (!settings || settings->privateBrowsingEnabled())
874 return;
875
876 addVisitedLink(page, KURL(ParsedURLString, urlString)); 858 addVisitedLink(page, KURL(ParsedURLString, urlString));
877 m_frame->loader()->client()->updateGlobalHistory(); 859 m_frame->loader()->client()->updateGlobalHistory();
878 860
879 } 861 }
880 862
881 void HistoryController::replaceState(PassRefPtr<SerializedScriptValue> stateObje ct, const String& title, const String& urlString) 863 void HistoryController::replaceState(PassRefPtr<SerializedScriptValue> stateObje ct, const String& title, const String& urlString)
882 { 864 {
883 if (!m_currentItem) 865 if (!m_currentItem)
884 return; 866 return;
885 867
886 if (!urlString.isEmpty()) 868 if (!urlString.isEmpty())
887 m_currentItem->setURLString(urlString); 869 m_currentItem->setURLString(urlString);
888 m_currentItem->setTitle(title); 870 m_currentItem->setTitle(title);
889 m_currentItem->setStateObject(stateObject); 871 m_currentItem->setStateObject(stateObject);
890 m_currentItem->setFormData(0); 872 m_currentItem->setFormData(0);
891 m_currentItem->setFormContentType(String()); 873 m_currentItem->setFormContentType(String());
892 874
893 Settings* settings = m_frame->settings();
894 if (!settings || settings->privateBrowsingEnabled())
895 return;
896
897 ASSERT(m_frame->page()); 875 ASSERT(m_frame->page());
898 addVisitedLink(m_frame->page(), KURL(ParsedURLString, urlString)); 876 addVisitedLink(m_frame->page(), KURL(ParsedURLString, urlString));
899 m_frame->loader()->client()->updateGlobalHistory(); 877 m_frame->loader()->client()->updateGlobalHistory();
900 } 878 }
901 879
902 } // namespace WebCore 880 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698