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 2013 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 "SkDocument.h" |
michael@0 | 9 | #include "SkStream.h" |
michael@0 | 10 | |
michael@0 | 11 | SkDocument::SkDocument(SkWStream* stream, void (*doneProc)(SkWStream*, bool)) { |
michael@0 | 12 | fStream = stream; // we do not own this object. |
michael@0 | 13 | fDoneProc = doneProc; |
michael@0 | 14 | fState = kBetweenPages_State; |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | SkDocument::~SkDocument() { |
michael@0 | 18 | this->close(); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | SkCanvas* SkDocument::beginPage(SkScalar width, SkScalar height, |
michael@0 | 22 | const SkRect* content) { |
michael@0 | 23 | if (width <= 0 || height <= 0) { |
michael@0 | 24 | return NULL; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | SkRect outer = SkRect::MakeWH(width, height); |
michael@0 | 28 | SkRect inner; |
michael@0 | 29 | if (content) { |
michael@0 | 30 | inner = *content; |
michael@0 | 31 | if (!inner.intersect(outer)) { |
michael@0 | 32 | return NULL; |
michael@0 | 33 | } |
michael@0 | 34 | } else { |
michael@0 | 35 | inner = outer; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | for (;;) { |
michael@0 | 39 | switch (fState) { |
michael@0 | 40 | case kBetweenPages_State: |
michael@0 | 41 | fState = kInPage_State; |
michael@0 | 42 | return this->onBeginPage(width, height, inner); |
michael@0 | 43 | case kInPage_State: |
michael@0 | 44 | this->endPage(); |
michael@0 | 45 | break; |
michael@0 | 46 | case kClosed_State: |
michael@0 | 47 | return NULL; |
michael@0 | 48 | } |
michael@0 | 49 | } |
michael@0 | 50 | SkDEBUGFAIL("never get here"); |
michael@0 | 51 | return NULL; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | void SkDocument::endPage() { |
michael@0 | 55 | if (kInPage_State == fState) { |
michael@0 | 56 | fState = kBetweenPages_State; |
michael@0 | 57 | this->onEndPage(); |
michael@0 | 58 | } |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | bool SkDocument::close() { |
michael@0 | 62 | for (;;) { |
michael@0 | 63 | switch (fState) { |
michael@0 | 64 | case kBetweenPages_State: { |
michael@0 | 65 | fState = kClosed_State; |
michael@0 | 66 | bool success = this->onClose(fStream); |
michael@0 | 67 | |
michael@0 | 68 | if (fDoneProc) { |
michael@0 | 69 | fDoneProc(fStream, false); |
michael@0 | 70 | } |
michael@0 | 71 | // we don't own the stream, but we mark it NULL since we can |
michael@0 | 72 | // no longer write to it. |
michael@0 | 73 | fStream = NULL; |
michael@0 | 74 | return success; |
michael@0 | 75 | } |
michael@0 | 76 | case kInPage_State: |
michael@0 | 77 | this->endPage(); |
michael@0 | 78 | break; |
michael@0 | 79 | case kClosed_State: |
michael@0 | 80 | return false; |
michael@0 | 81 | } |
michael@0 | 82 | } |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | void SkDocument::abort() { |
michael@0 | 86 | this->onAbort(); |
michael@0 | 87 | |
michael@0 | 88 | fState = kClosed_State; |
michael@0 | 89 | if (fDoneProc) { |
michael@0 | 90 | fDoneProc(fStream, true); |
michael@0 | 91 | } |
michael@0 | 92 | // we don't own the stream, but we mark it NULL since we can |
michael@0 | 93 | // no longer write to it. |
michael@0 | 94 | fStream = NULL; |
michael@0 | 95 | } |