mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 723005 - Remove all checks for global privacy status in history-related code, and add them to callers when appropriate. r=mak sr=gavin
This commit is contained in:
parent
5faa109e12
commit
03a47e15d5
@ -290,7 +290,7 @@ var PlacesCommandHook = {
|
||||
title, null, [descAnno]);
|
||||
PlacesUtils.transactionManager.doTransaction(txn);
|
||||
// Set the character-set
|
||||
if (charset)
|
||||
if (charset && !PrivateBrowsingUtils.isWindowPrivate(aBrowser.contentWindow))
|
||||
PlacesUtils.history.setCharsetForURI(uri, charset);
|
||||
itemId = PlacesUtils.getMostRecentBookmarkForURI(uri);
|
||||
}
|
||||
@ -685,7 +685,8 @@ HistoryMenu.prototype = {
|
||||
_onCommand: function HM__onCommand(aEvent) {
|
||||
let placesNode = aEvent.target._placesNode;
|
||||
if (placesNode) {
|
||||
PlacesUIUtils.markPageAsTyped(placesNode.uri);
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(window))
|
||||
PlacesUIUtils.markPageAsTyped(placesNode.uri);
|
||||
openUILink(placesNode.uri, aEvent, { ignoreAlt: true });
|
||||
}
|
||||
}
|
||||
|
@ -3486,7 +3486,8 @@ function FillHistoryMenu(aParent) {
|
||||
}
|
||||
|
||||
function addToUrlbarHistory(aUrlToAdd) {
|
||||
if (aUrlToAdd &&
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(window) &&
|
||||
aUrlToAdd &&
|
||||
!aUrlToAdd.contains(" ") &&
|
||||
!/[\x00-\x1F]/.test(aUrlToAdd))
|
||||
PlacesUIUtils.markPageAsTyped(aUrlToAdd);
|
||||
@ -5359,7 +5360,8 @@ function contentAreaClick(event, isPanelClick)
|
||||
// pages loaded in frames are embed visits and lost with the session, while
|
||||
// visits across frames should be preserved.
|
||||
try {
|
||||
PlacesUIUtils.markPageAsFollowedLink(href);
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(window))
|
||||
PlacesUIUtils.markPageAsFollowedLink(href);
|
||||
} catch (ex) { /* Skip invalid URIs. */ }
|
||||
}
|
||||
|
||||
@ -5483,7 +5485,8 @@ function BrowserSetForcedCharacterSet(aCharset)
|
||||
{
|
||||
gBrowser.docShell.charset = aCharset;
|
||||
// Save the forced character-set
|
||||
PlacesUtils.history.setCharsetForURI(gBrowser.currentURI, aCharset);
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(window))
|
||||
PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, aCharset);
|
||||
BrowserCharsetReload();
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,10 @@
|
||||
* been performed by the dialog.
|
||||
*/
|
||||
|
||||
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
||||
const BOOKMARK_ITEM = 0;
|
||||
const BOOKMARK_FOLDER = 1;
|
||||
const LIVEMARK_CONTAINER = 2;
|
||||
@ -567,7 +571,7 @@ var BookmarkPropertiesPanel = {
|
||||
}
|
||||
|
||||
//XXX TODO: this should be in a transaction!
|
||||
if (this._charSet)
|
||||
if (this._charSet && !PrivateBrowsingUtils.isWindowPrivate(window))
|
||||
PlacesUtils.history.setCharsetForURI(this._uri, this._charSet);
|
||||
|
||||
let createTxn = new PlacesCreateBookmarkTransaction(this._uri,
|
||||
|
@ -16,6 +16,9 @@ Cu.import("resource://gre/modules/Services.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
|
||||
Cu.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
return PlacesUtils;
|
||||
@ -537,17 +540,6 @@ this.PlacesUIUtils = {
|
||||
if (!aItemsToOpen.length)
|
||||
return;
|
||||
|
||||
var urls = [];
|
||||
for (var i = 0; i < aItemsToOpen.length; i++) {
|
||||
var item = aItemsToOpen[i];
|
||||
if (item.isBookmark)
|
||||
this.markPageAsFollowedBookmark(item.uri);
|
||||
else
|
||||
this.markPageAsTyped(item.uri);
|
||||
|
||||
urls.push(item.uri);
|
||||
}
|
||||
|
||||
// Prefer the caller window if it's a browser window, otherwise use
|
||||
// the top browser window.
|
||||
var browserWindow = null;
|
||||
@ -555,6 +547,18 @@ this.PlacesUIUtils = {
|
||||
aWindow && aWindow.document.documentElement.getAttribute("windowtype") == "navigator:browser" ?
|
||||
aWindow : this._getTopBrowserWin();
|
||||
|
||||
var urls = [];
|
||||
for (let item of aItemsToOpen) {
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(browserWindow)) {
|
||||
if (item.isBookmark)
|
||||
this.markPageAsFollowedBookmark(item.uri);
|
||||
else
|
||||
this.markPageAsTyped(item.uri);
|
||||
}
|
||||
|
||||
urls.push(item.uri);
|
||||
}
|
||||
|
||||
// whereToOpenLink doesn't return "window" when there's no browser window
|
||||
// open (Bug 630255).
|
||||
var where = browserWindow ?
|
||||
@ -634,10 +638,12 @@ this.PlacesUIUtils = {
|
||||
this.checkURLSecurity(aNode, aWindow)) {
|
||||
let isBookmark = PlacesUtils.nodeIsBookmark(aNode);
|
||||
|
||||
if (isBookmark)
|
||||
this.markPageAsFollowedBookmark(aNode.uri);
|
||||
else
|
||||
this.markPageAsTyped(aNode.uri);
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
|
||||
if (isBookmark)
|
||||
this.markPageAsFollowedBookmark(aNode.uri);
|
||||
else
|
||||
this.markPageAsTyped(aNode.uri);
|
||||
}
|
||||
|
||||
// Check whether the node is a bookmark which should be opened as
|
||||
// a web panel
|
||||
|
@ -38,44 +38,6 @@ function do_test()
|
||||
{
|
||||
do_check_eq(PlacesUtils.history.getPageTitle(TEST_URI), TITLE_1);
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
let place = {
|
||||
uri: TEST_URI,
|
||||
title: TITLE_2,
|
||||
visits: [{
|
||||
visitDate: Date.now() * 2000,
|
||||
transitionType: Ci.nsINavHistoryService.TRANSITION_LINK
|
||||
}]
|
||||
};
|
||||
|
||||
PlacesUtils.asyncHistory.updatePlaces(place, {
|
||||
handleError: function (aResultCode) {
|
||||
// We expect this error in Private Browsing mode.
|
||||
do_check_eq(aResultCode, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
},
|
||||
handleResult: function () do_throw("Unexpected success adding visit."),
|
||||
handleCompletion: function () afterAddSecondVisit()
|
||||
});
|
||||
}
|
||||
|
||||
function afterAddSecondVisit()
|
||||
{
|
||||
do_check_eq(PlacesUtils.history.getPageTitle(TEST_URI), TITLE_1);
|
||||
|
||||
pb.privateBrowsingEnabled = false;
|
||||
|
||||
do_check_eq(PlacesUtils.history.getPageTitle(TEST_URI), TITLE_1);
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
PlacesUtils.bhistory.setPageTitle(TEST_URI, TITLE_2);
|
||||
do_check_eq(PlacesUtils.history.getPageTitle(TEST_URI), TITLE_1);
|
||||
|
||||
pb.privateBrowsingEnabled = false;
|
||||
|
||||
do_check_eq(PlacesUtils.history.getPageTitle(TEST_URI), TITLE_1);
|
||||
|
||||
waitForClearHistory(do_test_finished);
|
||||
}
|
||||
}
|
||||
|
@ -5334,7 +5334,8 @@ nsDocShell::SetTitle(const PRUnichar * aTitle)
|
||||
treeOwnerAsWin->SetTitle(aTitle);
|
||||
}
|
||||
|
||||
if (mCurrentURI && mLoadType != LOAD_ERROR_PAGE && mUseGlobalHistory) {
|
||||
if (mCurrentURI && mLoadType != LOAD_ERROR_PAGE && mUseGlobalHistory &&
|
||||
!mInPrivateBrowsing) {
|
||||
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
||||
if (history) {
|
||||
history->SetURITitle(mCurrentURI, mTitle);
|
||||
@ -8918,7 +8919,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
|
||||
/* Set the title for the Global History entry for this anchor url.
|
||||
*/
|
||||
if (mUseGlobalHistory) {
|
||||
if (mUseGlobalHistory && !mInPrivateBrowsing) {
|
||||
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
||||
if (history) {
|
||||
history->SetURITitle(aURI, mTitle);
|
||||
@ -10263,7 +10264,7 @@ nsDocShell::AddState(nsIVariant *aData, const nsAString& aTitle,
|
||||
|
||||
// AddURIVisit doesn't set the title for the new URI in global history,
|
||||
// so do that here.
|
||||
if (mUseGlobalHistory) {
|
||||
if (mUseGlobalHistory && !mInPrivateBrowsing) {
|
||||
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
||||
if (history) {
|
||||
history->SetURITitle(newURI, mTitle);
|
||||
@ -11082,7 +11083,7 @@ nsDocShell::AddURIVisit(nsIURI* aURI,
|
||||
|
||||
// Only content-type docshells save URI visits. Also don't do
|
||||
// anything here if we're not supposed to use global history.
|
||||
if (mItemType != typeContent || !mUseGlobalHistory) {
|
||||
if (mItemType != typeContent || !mUseGlobalHistory || mInPrivateBrowsing) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,10 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsNetCID.h"
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
#include "nsIPrivateBrowsingService.h"
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// nsDownloadHistory
|
||||
@ -29,6 +33,20 @@ nsDownloadHistory::AddDownload(nsIURI *aSource,
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSource);
|
||||
|
||||
#if !(defined(MOZ_PER_WINDOW_PRIVATE_BROWSING)) && defined(DEBUG)
|
||||
// This code makes sure that in global private browsing mode, the flag
|
||||
// passed to us matches the global PB mode. This can be removed when
|
||||
// per-window private browsing has been turned on.
|
||||
nsCOMPtr<nsIPrivateBrowsingService> pbService =
|
||||
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
|
||||
if (pbService) {
|
||||
bool inPrivateBrowsing = false;
|
||||
if (NS_SUCCEEDED(pbService->GetPrivateBrowsingEnabled(&inPrivateBrowsing))) {
|
||||
MOZ_ASSERT(!inPrivateBrowsing, "Shouldn't be adding any download history in PB mode");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIGlobalHistory2> history =
|
||||
do_GetService("@mozilla.org/browser/global-history;2");
|
||||
if (!history)
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
interface nsIAutoCompletePopup;
|
||||
|
||||
[scriptable, uuid(f5eddd39-f8e0-43b7-bc3d-03623f595e52)]
|
||||
[scriptable, uuid(fadb2bb9-3e2e-4ca0-b0e0-0982b8dda9dc)]
|
||||
interface nsIAutoCompleteInput : nsISupports
|
||||
{
|
||||
/*
|
||||
@ -140,4 +140,11 @@ interface nsIAutoCompleteInput : nsISupports
|
||||
* TRUE: should consume; FALSE: should dispatch.
|
||||
*/
|
||||
readonly attribute boolean consumeRollupEvent;
|
||||
|
||||
/*
|
||||
* Indicates whether this input is in a "private browsing" context.
|
||||
* nsIAutoCompleteSearches for these inputs should not persist any data to disk
|
||||
* (such as a history database).
|
||||
*/
|
||||
readonly attribute boolean inPrivateContext;
|
||||
};
|
||||
|
@ -2460,7 +2460,7 @@ nsDownload::OnProgressChange64(nsIWebProgress *aWebProgress,
|
||||
|
||||
// If we have a MIME info, we know that exthandler has already added this to
|
||||
// the history, but if we do not, we'll have to add it ourselves.
|
||||
if (!mMIMEInfo) {
|
||||
if (!mMIMEInfo && !mPrivate) {
|
||||
nsCOMPtr<nsIDownloadHistory> dh =
|
||||
do_GetService(NS_DOWNLOADHISTORY_CONTRACTID);
|
||||
if (dh)
|
||||
|
@ -455,7 +455,7 @@ AsyncFetchAndSetIconForPage::start(nsIURI* aFaviconURI,
|
||||
NS_ENSURE_TRUE(navHistory, NS_ERROR_OUT_OF_MEMORY);
|
||||
rv = navHistory->CanAddURI(aPageURI, &canAddToHistory);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
page.canAddToHistory = !!canAddToHistory;
|
||||
page.canAddToHistory = !!canAddToHistory && aFaviconLoadType != nsIFaviconService::FAVICON_LOAD_PRIVATE;
|
||||
|
||||
IconData icon;
|
||||
|
||||
|
@ -673,8 +673,7 @@ BookmarkImporter.prototype = {
|
||||
// case neither the favicon URI nor the favicon data will be saved. If the
|
||||
// bookmark is visited again later, the URI and data will be fetched.
|
||||
PlacesUtils.favicons.replaceFaviconDataFromDataURL(faviconURI, aData);
|
||||
PlacesUtils.favicons.setAndFetchFaviconForPage(aPageURI, faviconURI, false,
|
||||
PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE);
|
||||
PlacesUtils.favicons.setAndFetchFaviconForPage(aPageURI, faviconURI, false, PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,10 @@
|
||||
#include "nsIRandomGenerator.h"
|
||||
#endif
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
#include "nsIPrivateBrowsingService.h"
|
||||
#endif
|
||||
|
||||
// The length of guids that are used by history and bookmarks.
|
||||
#define GUID_LENGTH 12
|
||||
|
||||
@ -412,5 +416,22 @@ AsyncStatementTelemetryTimer::HandleCompletion(uint16_t aReason)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
EnsureNotGlobalPrivateBrowsing()
|
||||
{
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// This code makes sure that certain code is not invoked when global private
|
||||
// browsing is enabled.
|
||||
nsCOMPtr<nsIPrivateBrowsingService> pbService =
|
||||
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
|
||||
if (pbService) {
|
||||
bool inPrivateBrowsing = false;
|
||||
if (NS_SUCCEEDED(pbService->GetPrivateBrowsingEnabled(&inPrivateBrowsing))) {
|
||||
MOZ_ASSERT(!inPrivateBrowsing);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace places
|
||||
} // namespace mozilla
|
||||
|
@ -264,6 +264,11 @@ private:
|
||||
const TimeStamp mStart;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to abort if global private browsing is in use.
|
||||
*/
|
||||
void EnsureNotGlobalPrivateBrowsing();
|
||||
|
||||
} // namespace places
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "Helpers.h"
|
||||
#include "PlaceInfo.h"
|
||||
#include "VisitInfo.h"
|
||||
#include "nsPlacesMacros.h"
|
||||
|
||||
#include "mozilla/storage.h"
|
||||
#include "mozilla/dom/Link.h"
|
||||
@ -2066,6 +2067,8 @@ History::AddDownload(nsIURI* aSource, nsIURI* aReferrer,
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ENSURE_ARG(aSource);
|
||||
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
if (mShuttingDown) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1402,8 +1402,9 @@ this.PlacesUtils = {
|
||||
if (tags.length)
|
||||
this.tagging.tagURI(this._uri(aData.uri), tags);
|
||||
}
|
||||
if (aData.charset)
|
||||
this.history.setCharsetForURI(this._uri(aData.uri), aData.charset);
|
||||
if (aData.charset) {
|
||||
this.history.setCharsetForURI(this._uri(aData.uri), aData.charset);
|
||||
}
|
||||
if (aData.uri.substr(0, 6) == "place:")
|
||||
searchIds.push(id);
|
||||
if (aData.icon) {
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "sampler.h"
|
||||
|
||||
#include "nsNetCID.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
#define ENSURE_ANNO_TYPE(_type, _statement) \
|
||||
@ -284,8 +286,7 @@ nsAnnotationService::SetPageAnnotationString(nsIURI* aURI,
|
||||
{
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
if (InPrivateBrowsingMode())
|
||||
return NS_OK;
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
nsresult rv = SetAnnotationStringInternal(aURI, 0, aName, aValue,
|
||||
aFlags, aExpiration);
|
||||
@ -359,8 +360,7 @@ nsAnnotationService::SetPageAnnotationInt32(nsIURI* aURI,
|
||||
{
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
if (InPrivateBrowsingMode())
|
||||
return NS_OK;
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
nsresult rv = SetAnnotationInt32Internal(aURI, 0, aName, aValue,
|
||||
aFlags, aExpiration);
|
||||
@ -434,8 +434,7 @@ nsAnnotationService::SetPageAnnotationInt64(nsIURI* aURI,
|
||||
{
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
if (InPrivateBrowsingMode())
|
||||
return NS_OK;
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
nsresult rv = SetAnnotationInt64Internal(aURI, 0, aName, aValue,
|
||||
aFlags, aExpiration);
|
||||
@ -509,8 +508,7 @@ nsAnnotationService::SetPageAnnotationDouble(nsIURI* aURI,
|
||||
{
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
if (InPrivateBrowsingMode())
|
||||
return NS_OK;
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
nsresult rv = SetAnnotationDoubleInternal(aURI, 0, aName, aValue,
|
||||
aFlags, aExpiration);
|
||||
@ -591,8 +589,7 @@ nsAnnotationService::SetPageAnnotationBinary(nsIURI* aURI,
|
||||
{
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
if (InPrivateBrowsingMode())
|
||||
return NS_OK;
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
nsresult rv = SetAnnotationBinaryInternal(aURI, 0, aName, aData, aDataLen,
|
||||
aMimeType, aFlags, aExpiration);
|
||||
@ -1498,8 +1495,7 @@ nsAnnotationService::CopyPageAnnotations(nsIURI* aSourceURI,
|
||||
NS_ENSURE_ARG(aSourceURI);
|
||||
NS_ENSURE_ARG(aDestURI);
|
||||
|
||||
if (InPrivateBrowsingMode())
|
||||
return NS_OK;
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
mozStorageTransaction transaction(mDB->MainConn(), false);
|
||||
|
||||
@ -1828,14 +1824,6 @@ nsAnnotationService::StartGetAnnotation(nsIURI* aURI,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
nsAnnotationService::InPrivateBrowsingMode() const
|
||||
{
|
||||
nsNavHistory* history = nsNavHistory::GetHistoryService();
|
||||
return history && history->InPrivateBrowsingMode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This does most of the setup work needed to set an annotation, except for
|
||||
* binding the the actual value and MIME type and executing the statement.
|
||||
|
@ -135,8 +135,6 @@ protected:
|
||||
int64_t aItemId,
|
||||
const nsACString& aName);
|
||||
|
||||
bool InPrivateBrowsingMode() const;
|
||||
|
||||
public:
|
||||
nsresult GetPagesWithAnnotationCOMArray(const nsACString& aName,
|
||||
nsCOMArray<nsIURI>* _results);
|
||||
|
@ -191,6 +191,8 @@ nsFaviconService::SetFaviconUrlForPage(nsIURI* aPageURI, nsIURI* aFaviconURI)
|
||||
NS_ENSURE_ARG(aPageURI);
|
||||
NS_ENSURE_ARG(aFaviconURI);
|
||||
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
// If we are about to expire all favicons, don't bother setting a new one.
|
||||
if (mFaviconsExpirationRunning) {
|
||||
return NS_OK;
|
||||
@ -199,10 +201,6 @@ nsFaviconService::SetFaviconUrlForPage(nsIURI* aPageURI, nsIURI* aFaviconURI)
|
||||
nsNavHistory* history = nsNavHistory::GetHistoryService();
|
||||
NS_ENSURE_TRUE(history, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (history->InPrivateBrowsingMode()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
int64_t iconId = -1;
|
||||
bool hasData = false;
|
||||
|
@ -263,7 +263,6 @@ nsNavHistory::nsNavHistory()
|
||||
, mHistoryEnabled(true)
|
||||
, mNumVisitsForFrecency(10)
|
||||
, mTagsFolder(-1)
|
||||
, mInPrivateBrowsing(PRIVATEBROWSING_NOTINITED)
|
||||
, mHasHistoryEntries(-1)
|
||||
, mCanNotify(true)
|
||||
, mCacheObservers("history-observers")
|
||||
@ -316,7 +315,6 @@ nsNavHistory::Init()
|
||||
if (obsSvc) {
|
||||
(void)obsSvc->AddObserver(this, TOPIC_PLACES_CONNECTION_CLOSED, true);
|
||||
(void)obsSvc->AddObserver(this, TOPIC_IDLE_DAILY, true);
|
||||
(void)obsSvc->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, true);
|
||||
#ifdef MOZ_XUL
|
||||
(void)obsSvc->AddObserver(this, TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING, true);
|
||||
#endif
|
||||
@ -1224,7 +1222,7 @@ nsNavHistory::CanAddURI(nsIURI* aURI, bool* canAdd)
|
||||
NS_ENSURE_ARG(aURI);
|
||||
NS_ENSURE_ARG_POINTER(canAdd);
|
||||
|
||||
// If history is disabled (included privatebrowsing), don't add any entry.
|
||||
// If history is disabled, don't add any entry.
|
||||
if (IsHistoryDisabled()) {
|
||||
*canAdd = false;
|
||||
return NS_OK;
|
||||
@ -3429,7 +3427,6 @@ nsNavHistory::IsVisited(nsIURI *aURI, bool *_retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// nsNavHistory::SetPageTitle
|
||||
//
|
||||
// This sets the page title.
|
||||
@ -3448,9 +3445,7 @@ nsNavHistory::SetPageTitle(nsIURI* aURI,
|
||||
NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
// Don't update the page title inside the private browsing mode.
|
||||
if (InPrivateBrowsingMode())
|
||||
return NS_OK;
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
// if aTitle is empty we want to clear the previous title.
|
||||
// We don't want to set it to an empty string, but to a NULL value,
|
||||
@ -3672,6 +3667,15 @@ nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
if (!input)
|
||||
return NS_OK;
|
||||
|
||||
// If the source is a private window, don't add any input history.
|
||||
bool isPrivate;
|
||||
nsresult rv = input->GetInPrivateContext(&isPrivate);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (isPrivate)
|
||||
return NS_OK;
|
||||
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
nsCOMPtr<nsIAutoCompletePopup> popup;
|
||||
input->GetPopup(getter_AddRefs(popup));
|
||||
if (!popup)
|
||||
@ -3684,7 +3688,7 @@ nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
|
||||
// Don't bother if the popup is closed
|
||||
bool open;
|
||||
nsresult rv = popup->GetPopupOpen(&open);
|
||||
rv = popup->GetPopupOpen(&open);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!open)
|
||||
return NS_OK;
|
||||
@ -3709,15 +3713,6 @@ nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
(void)DecayFrecency();
|
||||
}
|
||||
|
||||
else if (strcmp(aTopic, NS_PRIVATE_BROWSING_SWITCH_TOPIC) == 0) {
|
||||
if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_ENTER).Equals(aData)) {
|
||||
mInPrivateBrowsing = true;
|
||||
}
|
||||
else if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_LEAVE).Equals(aData)) {
|
||||
mInPrivateBrowsing = false;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -5088,9 +5083,7 @@ nsresult
|
||||
nsNavHistory::AutoCompleteFeedback(int32_t aIndex,
|
||||
nsIAutoCompleteController *aController)
|
||||
{
|
||||
// We do not track user choices in the location bar in private browsing mode.
|
||||
if (InPrivateBrowsingMode())
|
||||
return NS_OK;
|
||||
ENSURE_NOT_PRIVATE_BROWSING;
|
||||
|
||||
nsCOMPtr<mozIStorageAsyncStatement> stmt = mDB->GetAsyncStatement(
|
||||
"INSERT OR REPLACE INTO moz_inputhistory "
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsPIPlacesHistoryListenersNotifier.h"
|
||||
#include "nsIBrowserHistory.h"
|
||||
#include "nsINavBookmarksService.h"
|
||||
#include "nsIPrivateBrowsingService.h"
|
||||
#include "nsIFaviconService.h"
|
||||
|
||||
#include "nsIObserverService.h"
|
||||
@ -37,10 +36,6 @@
|
||||
#define QUERYUPDATE_COMPLEX_WITH_BOOKMARKS 3
|
||||
#define QUERYUPDATE_HOST 4
|
||||
|
||||
// This magic number specified an uninitialized value for the
|
||||
// mInPrivateBrowsing member
|
||||
#define PRIVATEBROWSING_NOTINITED (bool(0xffffffff))
|
||||
|
||||
// Clamp title and URL to generously large, but not too large, length.
|
||||
// See bug 319004 for details.
|
||||
#define URI_LENGTH_MAX 65536
|
||||
@ -204,7 +199,7 @@ public:
|
||||
|
||||
// Returns whether history is enabled or not.
|
||||
bool IsHistoryDisabled() {
|
||||
return !mHistoryEnabled || InPrivateBrowsingMode();
|
||||
return !mHistoryEnabled;
|
||||
}
|
||||
|
||||
// Constants for the columns returned by the above statement.
|
||||
@ -294,21 +289,6 @@ public:
|
||||
nsCOMArray<nsNavHistoryQuery>* aQueries,
|
||||
nsNavHistoryQueryOptions** aOptions);
|
||||
|
||||
// Returns true if we are currently in private browsing mode
|
||||
bool InPrivateBrowsingMode()
|
||||
{
|
||||
if (mInPrivateBrowsing == PRIVATEBROWSING_NOTINITED) {
|
||||
mInPrivateBrowsing = false;
|
||||
nsCOMPtr<nsIPrivateBrowsingService> pbs =
|
||||
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
|
||||
if (pbs) {
|
||||
pbs->GetPrivateBrowsingEnabled(&mInPrivateBrowsing);
|
||||
}
|
||||
}
|
||||
|
||||
return mInPrivateBrowsing;
|
||||
}
|
||||
|
||||
typedef nsDataHashtable<nsCStringHashKey, nsCString> StringHash;
|
||||
|
||||
/**
|
||||
@ -618,8 +598,6 @@ protected:
|
||||
|
||||
int64_t mTagsFolder;
|
||||
|
||||
bool mInPrivateBrowsing;
|
||||
|
||||
int8_t mHasHistoryEntries;
|
||||
|
||||
// Used to enable and disable the observer notifications
|
||||
|
@ -37,3 +37,9 @@
|
||||
} \
|
||||
return _sInstance; \
|
||||
}
|
||||
|
||||
#if !defined(MOZ_PER_WINDOW_PRIVATE_BROWSING) || !defined(DEBUG)
|
||||
# define ENSURE_NOT_PRIVATE_BROWSING /* nothing */
|
||||
#else
|
||||
# define ENSURE_NOT_PRIVATE_BROWSING EnsureNotPrivateBrowsing()
|
||||
#endif
|
||||
|
@ -17,6 +17,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_bug646422.js \
|
||||
browser_bug680727.js \
|
||||
browser_colorAnalyzer.js \
|
||||
browser_favicon_privatebrowsing.js \
|
||||
browser_notfound.js \
|
||||
browser_redirect.js \
|
||||
browser_visituri.js \
|
||||
@ -46,6 +47,8 @@ MOCHITEST_FILES = \
|
||||
visituri/redirect_twice.sjs \
|
||||
visituri/redirect_once.sjs \
|
||||
visituri/final.html \
|
||||
favicon-normal32.png \
|
||||
favicon.html \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -0,0 +1,49 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* One-time DOMContentLoaded callback.
|
||||
*/
|
||||
function waitForLoad(callback)
|
||||
{
|
||||
gTab.linkedBrowser.addEventListener("load", function()
|
||||
{
|
||||
gTab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
callback();
|
||||
}, true);
|
||||
}
|
||||
|
||||
let gTab;
|
||||
function test()
|
||||
{
|
||||
if (!("@mozilla.org/privatebrowsing;1" in Cc)) {
|
||||
todo(false, "PB service is not available, bail out");
|
||||
return;
|
||||
}
|
||||
|
||||
gTab = gBrowser.selectedTab = gBrowser.addTab();
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
const pageURI ="http://example.org/tests/toolkit/components/places/tests/browser/favicon.html";
|
||||
content.location.href = pageURI;
|
||||
waitForLoad(function()
|
||||
{
|
||||
PlacesUtils.favicons.getFaviconURLForPage(
|
||||
NetUtil.newURI(pageURI),
|
||||
function(uri, dataLen, data, mimeType) {
|
||||
is(uri, null, "no result should be found");
|
||||
gBrowser.removeCurrentTab();
|
||||
pb.privateBrowsingEnabled = false;
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
BIN
toolkit/components/places/tests/browser/favicon-normal32.png
Normal file
BIN
toolkit/components/places/tests/browser/favicon-normal32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 344 B |
13
toolkit/components/places/tests/browser/favicon.html
Normal file
13
toolkit/components/places/tests/browser/favicon.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<link rel="shortcut icon" href="http://example.org/tests/toolkit/components/places/tests/browser/favicon-normal32.png">
|
||||
</head>
|
||||
<body>
|
||||
OK we're done!
|
||||
</body>
|
||||
</html>
|
@ -55,6 +55,7 @@ let nonvisited_URIs = ["http://www.google.ca/typed/",
|
||||
"http://www.google.it/framed-link/",
|
||||
"http://www.google.com.tr/redirect-permanent/",
|
||||
"http://www.google.de/redirect-temporary/"];
|
||||
|
||||
/**
|
||||
* Function fills history, one for each transition type.
|
||||
*/
|
||||
@ -73,25 +74,6 @@ function fill_history_visitedURI() {
|
||||
}, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function fills history, one for each transition type.
|
||||
* second batch of history items
|
||||
*/
|
||||
function fill_history_nonvisitedURI() {
|
||||
PlacesUtils.history.runInBatchMode({
|
||||
runBatched: function (aUserData) {
|
||||
add_visit(nonvisited_URIs[0], PlacesUtils.history.TRANSITION_TYPED);
|
||||
add_visit(nonvisited_URIs[1], PlacesUtils.history.TRANSITION_BOOKMARK);
|
||||
add_visit(nonvisited_URIs[2], PlacesUtils.history.TRANSITION_LINK);
|
||||
add_visit(nonvisited_URIs[3], PlacesUtils.history.TRANSITION_DOWNLOAD);
|
||||
add_visit(nonvisited_URIs[4], PlacesUtils.history.TRANSITION_EMBED);
|
||||
add_visit(nonvisited_URIs[5], PlacesUtils.history.TRANSITION_FRAMED_LINK);
|
||||
add_visit(nonvisited_URIs[6], PlacesUtils.history.TRANSITION_REDIRECT_PERMANENT);
|
||||
add_visit(nonvisited_URIs[7], PlacesUtils.history.TRANSITION_REDIRECT_TEMPORARY);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
// Initial batch of history items (7) + Bookmark_A (1)
|
||||
// This number should not change after tests enter private browsing
|
||||
// it will be set to 10 with the addition of Bookmark-B during private
|
||||
@ -197,25 +179,10 @@ function run_test() {
|
||||
// Enter Private Browsing Mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
// History items should not retrievable by isVisited
|
||||
visited_URIs.forEach(function (visited_uri) {
|
||||
do_check_false(PlacesUtils.bhistory.isVisited(uri(visited_uri)));
|
||||
});
|
||||
|
||||
// Check if Bookmark-A has been visited, should be false
|
||||
do_check_false(is_bookmark_A_altered());
|
||||
|
||||
// Add a second set of history items during private browsing mode
|
||||
// should not be viewed/stored or in any way retrievable
|
||||
fill_history_nonvisitedURI();
|
||||
nonvisited_URIs.forEach(function (nonvisited_uri) {
|
||||
do_check_false(!!page_in_database(nonvisited_uri));
|
||||
do_check_false(PlacesUtils.bhistory.isVisited(uri(nonvisited_uri)));
|
||||
});
|
||||
|
||||
// We attempted to add another 7 new entries, but we still have 7 history entries
|
||||
// and 1 history entry, Bookmark-A.
|
||||
// Private browsing blocked the entry of the new history entries
|
||||
// We still have 7 history entries and 1 history entry, Bookmark-A.
|
||||
check_placesItem_Count();
|
||||
|
||||
// Check if Bookmark-A is still accessible
|
||||
|
@ -124,41 +124,6 @@ add_test(function test_dh_addDownload_referrer()
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function test_dh_addDownload_privateBrowsing()
|
||||
{
|
||||
if (!("@mozilla.org/privatebrowsing;1" in Cc)) {
|
||||
do_log_info("Private Browsing service is not available, bail out.");
|
||||
run_next_test();
|
||||
return;
|
||||
}
|
||||
|
||||
waitForOnVisit(function DHAD_onVisit(aURI) {
|
||||
// We should only receive the notification for the non-private URI. This
|
||||
// test is based on the assumption that visit notifications are received
|
||||
// in the same order of the addDownload calls, which is currently true
|
||||
// because database access is serialized on the same worker thread.
|
||||
do_check_true(aURI.equals(DOWNLOAD_URI));
|
||||
|
||||
uri_in_db(DOWNLOAD_URI, true);
|
||||
uri_in_db(PRIVATE_URI, false);
|
||||
|
||||
promiseClearHistory().then(run_next_test);
|
||||
});
|
||||
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"]
|
||||
.getService(Ci.nsIPrivateBrowsingService);
|
||||
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session",
|
||||
true);
|
||||
pb.privateBrowsingEnabled = true;
|
||||
gDownloadHistory.addDownload(PRIVATE_URI, REFERRER_URI, Date.now() * 1000);
|
||||
|
||||
// The addDownload functions calls CanAddURI synchronously, thus we can
|
||||
// exit Private Browsing Mode immediately.
|
||||
pb.privateBrowsingEnabled = false;
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
gDownloadHistory.addDownload(DOWNLOAD_URI, REFERRER_URI, Date.now() * 1000);
|
||||
});
|
||||
|
||||
add_test(function test_dh_addDownload_disabledHistory()
|
||||
{
|
||||
waitForOnVisit(function DHAD_onVisit(aURI) {
|
||||
|
@ -571,6 +571,24 @@ nsFormFillController::GetConsumeRollupEvent(bool *aConsumeRollupEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormFillController::GetInPrivateContext(bool *aInPrivateContext)
|
||||
{
|
||||
if (!mFocusedInput) {
|
||||
*aInPrivateContext = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> inputDoc;
|
||||
mFocusedInput->GetOwnerDocument(getter_AddRefs(inputDoc));
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(inputDoc);
|
||||
nsCOMPtr<nsISupports> container = doc->GetContainer();
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
|
||||
*aInPrivateContext = loadContext && loadContext->UsePrivateBrowsing();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//// nsIAutoCompleteSearch
|
||||
|
@ -163,6 +163,15 @@
|
||||
<property name="searchCount" readonly="true"
|
||||
onget="this.initSearchNames(); return this.mSearchNames.length;"/>
|
||||
|
||||
<field name="PrivateBrowsingUtils" readonly="true">
|
||||
let utils = {};
|
||||
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm", utils);
|
||||
utils.PrivateBrowsingUtils
|
||||
</field>
|
||||
|
||||
<property name="inPrivateContext" readonly="true"
|
||||
onget="this.PrivateBrowsingUtils.isPrivateWindow(window)"/>
|
||||
|
||||
<!-- This is the maximum number of drop-down rows we get when we
|
||||
hit the drop marker beside fields that have it (like the URLbar).-->
|
||||
<field name="maxDropMarkerRows" readonly="true">14</field>
|
||||
|
@ -1942,12 +1942,14 @@ nsresult nsExternalAppHandler::InitializeDownload(nsITransfer* aTransfer)
|
||||
nsCOMPtr<nsIDownloadHistory> dh(do_GetService(NS_DOWNLOADHISTORY_CONTRACTID));
|
||||
if (dh) {
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
if (mRequest) {
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(mRequest);
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(mRequest);
|
||||
if (channel) {
|
||||
NS_GetReferrerFromChannel(channel, getter_AddRefs(referrer));
|
||||
}
|
||||
|
||||
dh->AddDownload(mSourceUrl, referrer, mTimeDownloadStarted, target);
|
||||
if (channel && !NS_UsePrivateBrowsing(channel)) {
|
||||
dh->AddDownload(mSourceUrl, referrer, mTimeDownloadStarted, target);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
Loading…
Reference in New Issue
Block a user