Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 // ArchiveOpenCallback.h
3 #ifndef __ARCHIVE_OPEN_CALLBACK_H
4 #define __ARCHIVE_OPEN_CALLBACK_H
6 #include "Common/String.h"
7 #include "Common/MyCom.h"
8 #include "Windows/FileFind.h"
10 #ifndef _NO_CRYPTO
11 #include "../../IPassword.h"
12 #endif
13 #include "../../Archive/IArchive.h"
15 struct IOpenCallbackUI
16 {
17 virtual HRESULT CheckBreak() = 0;
18 virtual HRESULT SetTotal(const UInt64 *files, const UInt64 *bytes) = 0;
19 virtual HRESULT SetCompleted(const UInt64 *files, const UInt64 *bytes) = 0;
20 #ifndef _NO_CRYPTO
21 virtual HRESULT CryptoGetTextPassword(BSTR *password) = 0;
22 virtual HRESULT GetPasswordIfAny(UString &password) = 0;
23 #endif
24 };
26 class COpenCallbackImp:
27 public IArchiveOpenCallback,
28 public IArchiveOpenVolumeCallback,
29 public IArchiveOpenSetSubArchiveName,
30 #ifndef _NO_CRYPTO
31 public ICryptoGetTextPassword,
32 #endif
33 public CMyUnknownImp
34 {
35 public:
36 #ifndef _NO_CRYPTO
37 MY_UNKNOWN_IMP3(
38 IArchiveOpenVolumeCallback,
39 ICryptoGetTextPassword,
40 IArchiveOpenSetSubArchiveName
41 )
42 #else
43 MY_UNKNOWN_IMP2(
44 IArchiveOpenVolumeCallback,
45 IArchiveOpenSetSubArchiveName
46 )
47 #endif
49 STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes);
50 STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes);
52 // IArchiveOpenVolumeCallback
53 STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value);
54 STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream);
56 #ifndef _NO_CRYPTO
57 // ICryptoGetTextPassword
58 STDMETHOD(CryptoGetTextPassword)(BSTR *password);
59 #endif
61 STDMETHOD(SetSubArchiveName(const wchar_t *name))
62 {
63 _subArchiveMode = true;
64 _subArchiveName = name;
65 return S_OK;
66 }
68 private:
69 UString _folderPrefix;
70 NWindows::NFile::NFind::CFileInfoW _fileInfo;
71 bool _subArchiveMode;
72 UString _subArchiveName;
73 public:
74 UStringVector FileNames;
75 IOpenCallbackUI *Callback;
76 void Init(const UString &folderPrefix, const UString &fileName)
77 {
78 _folderPrefix = folderPrefix;
79 if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo))
80 throw 1;
81 FileNames.Clear();
82 _subArchiveMode = false;
83 }
84 int FindName(const UString &name);
85 };
87 #endif