| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/file_system/browser_file_system_helper.h" | 5 #include "content/browser/file_system/browser_file_system_helper.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| 11 #include "webkit/fileapi/file_system_options.h" |
| 11 #include "webkit/quota/quota_manager.h" | 12 #include "webkit/quota/quota_manager.h" |
| 12 | 13 |
| 13 using content::BrowserThread; | 14 using content::BrowserThread; |
| 14 | 15 |
| 16 namespace { |
| 17 |
| 18 class BrowserFileSystemOptions : public fileapi::FileSystemOptions { |
| 19 public: |
| 20 explicit BrowserFileSystemOptions(bool is_incognito) |
| 21 : is_incognito_(is_incognito) {} |
| 22 |
| 23 // Implements FileSystemOptions. |
| 24 virtual bool is_incognito() const OVERRIDE { |
| 25 return is_incognito_; |
| 26 } |
| 27 |
| 28 // Implements FileSystemOptions. |
| 29 virtual bool allow_file_access_from_files() const OVERRIDE { |
| 30 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 31 switches::kAllowFileAccessFromFiles); |
| 32 } |
| 33 |
| 34 private: |
| 35 bool is_incognito_; |
| 36 }; |
| 37 |
| 38 } // anonymous namespace |
| 39 |
| 15 scoped_refptr<fileapi::FileSystemContext> CreateFileSystemContext( | 40 scoped_refptr<fileapi::FileSystemContext> CreateFileSystemContext( |
| 16 const FilePath& profile_path, bool is_incognito, | 41 const FilePath& profile_path, bool is_incognito, |
| 17 quota::SpecialStoragePolicy* special_storage_policy, | 42 quota::SpecialStoragePolicy* special_storage_policy, |
| 18 quota::QuotaManagerProxy* quota_manager_proxy) { | 43 quota::QuotaManagerProxy* quota_manager_proxy) { |
| 19 return new fileapi::FileSystemContext( | 44 return new fileapi::FileSystemContext( |
| 20 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 45 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 21 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 46 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
| 22 special_storage_policy, | 47 special_storage_policy, |
| 23 quota_manager_proxy, | 48 quota_manager_proxy, |
| 24 profile_path, | 49 profile_path, |
| 25 is_incognito, | 50 new BrowserFileSystemOptions(is_incognito)); |
| 26 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 27 switches::kAllowFileAccessFromFiles), | |
| 28 NULL); | |
| 29 } | 51 } |
| OLD | NEW |