Bug 67870 - Private Browsing is a per-page setting that sets a global value
Summary: Private Browsing is a per-page setting that sets a global value
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-09-09 15:35 PDT by Jessie Berlin
Modified: 2012-11-16 09:47 PST (History)
9 users (show)

See Also:


Attachments
WIP (73.43 KB, patch)
2012-11-14 16:59 PST, Alexey Proskuryakov
buildbot: commit-queue-
Details | Formatted Diff | Diff
proposed patch (99.71 KB, patch)
2012-11-15 16:20 PST, Alexey Proskuryakov
no flags Details | Formatted Diff | Diff
updated patch (99.56 KB, patch)
2012-11-15 17:27 PST, Alexey Proskuryakov
sam: review+
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jessie Berlin 2011-09-09 15:35:20 PDT
In WebCore’s Settings.cpp’s setPrivateBrowsingEnabled, both of the following methods for turning on or off Private Browsing affect global settings:

// This modifies a static on ResourceHandle.
#if USE(CFURLSTORAGESESSIONS)
    ResourceHandle::setPrivateBrowsingEnabled(privateBrowsingEnabled);
#endif

and 

// This modifies the shared NSHTTPCookieStorage.
setCookieStoragePrivateBrowsingEnabled(privateBrowsingEnabled);

However, the Settings object is the Settings for a single Page. It should not be modifying global settings.
Comment 1 Jessie Berlin 2011-09-09 15:36:39 PDT
<rdar://problem/10103215>
Comment 2 Jessie Berlin 2011-09-09 17:03:31 PDT
Re-titling to express the interest that Private Browsing should be able to be something done per-page.
Comment 3 Alexey Proskuryakov 2012-11-14 16:59:32 PST
Created attachment 174291 [details]
WIP
Comment 4 WebKit Review Bot 2012-11-14 17:02:30 PST
Attachment 174291 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/WebCore.exp.in', u'Source/W..." exit_code: 1
Source/WebCore/platform/network/cf/CookieJarCFNet.cpp:35:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 36 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Build Bot 2012-11-14 21:12:21 PST
Comment on attachment 174291 [details]
WIP

Attachment 174291 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14844336
Comment 6 Alexey Proskuryakov 2012-11-15 16:20:18 PST
Created attachment 174545 [details]
proposed patch
Comment 7 WebKit Review Bot 2012-11-15 16:23:56 PST
Attachment 174545 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1
Source/WebCore/platform/network/cf/CookieJarCFNet.cpp:35:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 45 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Alexey Proskuryakov 2012-11-15 16:26:18 PST
Comment on attachment 174545 [details]
proposed patch

Actually, this doesn't work. A Web Inspector page created while private browsing is active would kill the private session.
Comment 9 Sam Weinig 2012-11-15 16:41:32 PST
Comment on attachment 174545 [details]
proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=174545&action=review

> Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp:422
> +    RetainPtr<CFArrayRef> cookies(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(cfCookieStorage.get(), cfURL.get(), false));

This should use the adoptCF() function (like above).

> Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp:827
> +    RetainPtr<CFDataRef> data(AdoptCF, CFURLConnectionSendSynchronousRequest(request.cfURLRequest(), &cfResponse, &cfError, request.timeoutInterval()));

This should use adoptCF()

> Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:113
> +    if (CFURLStorageSessionRef session = WebFrameNetworkingContext::defaultStorageSession())
> +        return RetainPtr<CFHTTPCookieStorageRef>(AdoptCF, WKCopyHTTPCookieStorage(session));

This should use the adoptCF() function, rather than the RetainPtr constructor (we are moving to that to be consistent with RefPtr.

> Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPlatformStrategiesMac.mm:39
> +    if (CFURLStorageSessionRef session = WebFrameNetworkingContext::defaultStorageSession())
> +        return RetainPtr<CFHTTPCookieStorageRef>(AdoptCF, WKCopyHTTPCookieStorage(session));

This should use adoptCF().

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2185
> +#if PLATFORM(MAC) || USE(CFNETWORK)
> +    if (privateBrowsingEnabled)
> +        WebFrameNetworkingContext::ensurePrivateBrowsingSession();
> +    else
> +        WebFrameNetworkingContext::destroyPrivateBrowsingSession();
> +#endif

Can this go in platformPreferencesDidChange()?

> Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm:87
> +    if (CFURLStorageSessionRef session = WebFrameNetworkingContext::defaultStorageSession())
> +        return RetainPtr<CFHTTPCookieStorageRef>(AdoptCF, WKCopyHTTPCookieStorage(session));

This should use adoptCF().

> Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp:84
> +    if (CFURLStorageSessionRef session = WebFrameNetworkingContext::defaultStorageSession())
> +        return RetainPtr<CFHTTPCookieStorageRef>(AdoptCF, wkCopyHTTPCookieStorage(session));

Please use adoptCF().
Comment 10 Alexey Proskuryakov 2012-11-15 17:22:21 PST
> Can this go in platformPreferencesDidChange()?

Probably not - it's a cross platform preference with some semi-temporary platform specific implementation details, not something entirely specific to a platform. So, we'd have the code to support it confusingly sprinkled around the code base.
Comment 11 Alexey Proskuryakov 2012-11-15 17:27:52 PST
Created attachment 174567 [details]
updated patch
Comment 12 Alexey Proskuryakov 2012-11-15 17:39:06 PST
By the way, I'm shamelessly using this bug, because it's in WebCore component, and I'm fixing it for WebCore, if not for WebKit :)
Comment 13 Build Bot 2012-11-15 20:28:54 PST
Comment on attachment 174567 [details]
updated patch

Attachment 174567 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14845747
Comment 14 WebKit Review Bot 2012-11-15 21:19:11 PST
Comment on attachment 174567 [details]
updated patch

Rejecting attachment 174567 [details] from commit-queue.

Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2

Last 500 characters of output:
ommit-queue/Source/WebKit/chromium/third_party/snappy/src --revision 63 --non-interactive --force --accept theirs-conflict --ignore-externals' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'
50>At revision 63.

________ running '/usr/bin/python tools/clang/scripts/update.py --mac-only' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'

________ running '/usr/bin/python gyp_webkit' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'
Updating webkit projects from gyp files...

Full output: http://queues.webkit.org/results/14848677
Comment 15 Alexey Proskuryakov 2012-11-16 09:47:43 PST
Committed <http://trac.webkit.org/changeset/134960>.