OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/file_system/browser_file_system_context.h" | 5 #include "chrome/browser/file_system/browser_file_system_context.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "webkit/fileapi/file_system_path_manager.h" | |
11 #include "webkit/fileapi/file_system_quota_manager.h" | 10 #include "webkit/fileapi/file_system_quota_manager.h" |
12 | 11 |
13 static inline bool GetAllowFileAccessFromFiles() { | |
14 return CommandLine::ForCurrentProcess()->HasSwitch( | |
15 switches::kAllowFileAccessFromFiles); | |
16 } | |
17 | |
18 BrowserFileSystemContext::BrowserFileSystemContext( | 12 BrowserFileSystemContext::BrowserFileSystemContext( |
19 const FilePath& data_path, bool is_incognito) { | 13 const FilePath& profile_path, bool is_incognito) |
20 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 14 : fileapi::SandboxedFileSystemContext( |
21 bool allow_file_access_from_files = | 15 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
22 command_line->HasSwitch(switches::kAllowFileAccessFromFiles); | 16 profile_path, |
23 bool unlimited_quota = | 17 is_incognito, |
24 command_line->HasSwitch(switches::kUnlimitedQuotaForFiles); | 18 CommandLine::ForCurrentProcess()->HasSwitch( |
25 quota_manager_.reset(new fileapi::FileSystemQuotaManager( | 19 switches::kAllowFileAccessFromFiles), |
26 allow_file_access_from_files, unlimited_quota)); | 20 CommandLine::ForCurrentProcess()->HasSwitch( |
27 path_manager_.reset(new fileapi::FileSystemPathManager( | 21 switches::kUnlimitedQuotaForFiles)) { |
28 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | |
29 data_path, is_incognito, allow_file_access_from_files)); | |
30 } | |
31 | |
32 bool BrowserFileSystemContext::CheckOriginQuota(const GURL& url, int64 growth) { | |
33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
34 return quota_manager_->CheckOriginQuota(url, growth); | |
35 } | 22 } |
36 | 23 |
37 void BrowserFileSystemContext::SetOriginQuotaUnlimited(const GURL& url) { | 24 void BrowserFileSystemContext::SetOriginQuotaUnlimited(const GURL& url) { |
38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
39 quota_manager_->SetOriginQuotaUnlimited(url); | 26 quota_manager()->SetOriginQuotaUnlimited(url); |
40 } | 27 } |
41 | 28 |
42 void BrowserFileSystemContext::ResetOriginQuotaUnlimited(const GURL& url) { | 29 void BrowserFileSystemContext::ResetOriginQuotaUnlimited(const GURL& url) { |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
44 quota_manager_->ResetOriginQuotaUnlimited(url); | 31 quota_manager()->ResetOriginQuotaUnlimited(url); |
45 } | 32 } |
46 | 33 |
47 BrowserFileSystemContext::~BrowserFileSystemContext() {} | 34 BrowserFileSystemContext::~BrowserFileSystemContext() {} |
OLD | NEW |