| 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 "chrome/browser/extensions/extension_file_browser_private_api.h" | 5 #include "chrome/browser/extensions/extension_file_browser_private_api.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "content/browser/tab_contents/tab_contents.h" | 37 #include "content/browser/tab_contents/tab_contents.h" |
| 38 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 39 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
| 40 #include "googleurl/src/gurl.h" | 40 #include "googleurl/src/gurl.h" |
| 41 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
| 42 #include "grit/platform_locale_settings.h" | 42 #include "grit/platform_locale_settings.h" |
| 43 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
| 44 #include "webkit/fileapi/file_system_context.h" | 44 #include "webkit/fileapi/file_system_context.h" |
| 45 #include "webkit/fileapi/file_system_file_util.h" | 45 #include "webkit/fileapi/file_system_file_util.h" |
| 46 #include "webkit/fileapi/file_system_mount_point_provider.h" | 46 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 47 #include "webkit/fileapi/file_system_operation.h" | |
| 48 #include "webkit/fileapi/file_system_operation_context.h" | 47 #include "webkit/fileapi/file_system_operation_context.h" |
| 49 #include "webkit/fileapi/file_system_types.h" | 48 #include "webkit/fileapi/file_system_types.h" |
| 50 #include "webkit/fileapi/file_system_util.h" | 49 #include "webkit/fileapi/file_system_util.h" |
| 51 | 50 |
| 52 using content::BrowserThread; | 51 using content::BrowserThread; |
| 53 | 52 |
| 54 namespace { | 53 namespace { |
| 55 | 54 |
| 56 // Error messages. | 55 // Error messages. |
| 57 const char kFileError[] = "File error %d"; | 56 const char kFileError[] = "File error %d"; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 Profile* profile_; | 403 Profile* profile_; |
| 405 // Renderer process id. | 404 // Renderer process id. |
| 406 int child_id_; | 405 int child_id_; |
| 407 // Extension source URL. | 406 // Extension source URL. |
| 408 scoped_refptr<const Extension> extension_; | 407 scoped_refptr<const Extension> extension_; |
| 409 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemCallbackDispatcher); | 408 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemCallbackDispatcher); |
| 410 }; | 409 }; |
| 411 | 410 |
| 412 void RequestLocalFileSystemFunction::RequestOnFileThread( | 411 void RequestLocalFileSystemFunction::RequestOnFileThread( |
| 413 const GURL& source_url, int child_id) { | 412 const GURL& source_url, int child_id) { |
| 414 fileapi::FileSystemOperation* operation = | |
| 415 new fileapi::FileSystemOperation( | |
| 416 new LocalFileSystemCallbackDispatcher( | |
| 417 this, | |
| 418 profile(), | |
| 419 child_id, | |
| 420 GetExtension()), | |
| 421 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | |
| 422 profile()->GetFileSystemContext()); | |
| 423 GURL origin_url = source_url.GetOrigin(); | 413 GURL origin_url = source_url.GetOrigin(); |
| 424 operation->OpenFileSystem(origin_url, fileapi::kFileSystemTypeExternal, | 414 profile()->GetFileSystemContext()->OpenFileSystem( |
| 425 false); // create | 415 origin_url, fileapi::kFileSystemTypeExternal, false, // create |
| 416 new LocalFileSystemCallbackDispatcher( |
| 417 this, |
| 418 profile(), |
| 419 child_id, |
| 420 GetExtension())); |
| 426 } | 421 } |
| 427 | 422 |
| 428 bool RequestLocalFileSystemFunction::RunImpl() { | 423 bool RequestLocalFileSystemFunction::RunImpl() { |
| 429 if (!dispatcher() || !render_view_host() || !render_view_host()->process()) | 424 if (!dispatcher() || !render_view_host() || !render_view_host()->process()) |
| 430 return false; | 425 return false; |
| 431 | 426 |
| 432 BrowserThread::PostTask( | 427 BrowserThread::PostTask( |
| 433 BrowserThread::FILE, FROM_HERE, | 428 BrowserThread::FILE, FROM_HERE, |
| 434 base::Bind( | 429 base::Bind( |
| 435 &RequestLocalFileSystemFunction::RequestOnFileThread, | 430 &RequestLocalFileSystemFunction::RequestOnFileThread, |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 task_id, | 853 task_id, |
| 859 file_urls)); | 854 file_urls)); |
| 860 result_.reset(new base::FundamentalValue(true)); | 855 result_.reset(new base::FundamentalValue(true)); |
| 861 return true; | 856 return true; |
| 862 } | 857 } |
| 863 | 858 |
| 864 void ExecuteTasksFileBrowserFunction::RequestFileEntryOnFileThread( | 859 void ExecuteTasksFileBrowserFunction::RequestFileEntryOnFileThread( |
| 865 const GURL& source_url, const std::string& task_id, | 860 const GURL& source_url, const std::string& task_id, |
| 866 const std::vector<GURL>& file_urls) { | 861 const std::vector<GURL>& file_urls) { |
| 867 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 862 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 868 fileapi::FileSystemOperation* operation = | |
| 869 new fileapi::FileSystemOperation( | |
| 870 new ExecuteTasksFileSystemCallbackDispatcher( | |
| 871 this, | |
| 872 profile(), | |
| 873 render_view_host()->process()->GetID(), | |
| 874 source_url, | |
| 875 GetExtension(), | |
| 876 task_id, | |
| 877 file_urls), | |
| 878 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | |
| 879 profile()->GetFileSystemContext()); | |
| 880 GURL origin_url = source_url.GetOrigin(); | 863 GURL origin_url = source_url.GetOrigin(); |
| 881 operation->OpenFileSystem(origin_url, fileapi::kFileSystemTypeExternal, | 864 profile()->GetFileSystemContext()->OpenFileSystem( |
| 882 false); // create | 865 origin_url, fileapi::kFileSystemTypeExternal, false, // create |
| 866 new ExecuteTasksFileSystemCallbackDispatcher( |
| 867 this, |
| 868 profile(), |
| 869 render_view_host()->process()->GetID(), |
| 870 source_url, |
| 871 GetExtension(), |
| 872 task_id, |
| 873 file_urls)); |
| 883 } | 874 } |
| 884 | 875 |
| 885 void ExecuteTasksFileBrowserFunction::ExecuteFailedOnUIThread() { | 876 void ExecuteTasksFileBrowserFunction::ExecuteFailedOnUIThread() { |
| 886 SendResponse(false); | 877 SendResponse(false); |
| 887 } | 878 } |
| 888 | 879 |
| 889 | 880 |
| 890 void ExecuteTasksFileBrowserFunction::ExecuteFileActionsOnUIThread( | 881 void ExecuteTasksFileBrowserFunction::ExecuteFileActionsOnUIThread( |
| 891 const std::string& task_id, | 882 const std::string& task_id, |
| 892 const std::string& file_system_name, | 883 const std::string& file_system_name, |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 SET_STRING(IDS_FILE_BROWSER, ENQUEUE); | 1662 SET_STRING(IDS_FILE_BROWSER, ENQUEUE); |
| 1672 #undef SET_STRING | 1663 #undef SET_STRING |
| 1673 | 1664 |
| 1674 ChromeURLDataManager::DataSource::SetFontAndTextDirection(dict); | 1665 ChromeURLDataManager::DataSource::SetFontAndTextDirection(dict); |
| 1675 | 1666 |
| 1676 dict->SetString("PLAY_MEDIA", | 1667 dict->SetString("PLAY_MEDIA", |
| 1677 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); | 1668 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); |
| 1678 | 1669 |
| 1679 return true; | 1670 return true; |
| 1680 } | 1671 } |
| OLD | NEW |