Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2010 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #include "SkStream_NSData.h" |
michael@0 | 9 | |
michael@0 | 10 | NSData* NSData_dataWithStream(SkStream* stream) { |
michael@0 | 11 | size_t length = stream->getLength(); |
michael@0 | 12 | void* src = malloc(length); |
michael@0 | 13 | size_t bytes = stream->read(src, length); |
michael@0 | 14 | SkASSERT(bytes == length); |
michael@0 | 15 | return [NSData dataWithBytesNoCopy:src length:length freeWhenDone:YES]; |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | NSData* NSData_dataFromResource(const char cname[], const char csuffix[]) { |
michael@0 | 19 | NSBundle* bundle = [NSBundle mainBundle]; |
michael@0 | 20 | NSString* name = [NSString stringWithUTF8String:cname]; |
michael@0 | 21 | NSString* suffix = [NSString stringWithUTF8String:csuffix]; |
michael@0 | 22 | NSString* path = [bundle pathForResource:name ofType:suffix]; |
michael@0 | 23 | return [NSData dataWithContentsOfMappedFile:path]; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 27 | |
michael@0 | 28 | SkStream_NSData::SkStream_NSData(NSData* data) { |
michael@0 | 29 | fNSData = data; |
michael@0 | 30 | [fNSData retain]; |
michael@0 | 31 | |
michael@0 | 32 | this->setMemory([fNSData bytes], [fNSData length], false); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | SkStream_NSData::~SkStream_NSData() { |
michael@0 | 36 | [fNSData release]; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | SkStream_NSData* SkStream_NSData::CreateFromResource(const char name[], |
michael@0 | 40 | const char suffix[]) { |
michael@0 | 41 | NSData* data = NSData_dataFromResource(name, suffix); |
michael@0 | 42 | return SkNEW_ARGS(SkStream_NSData, (data)); |
michael@0 | 43 | } |
michael@0 | 44 |