OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/extensions/file_browser_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/statvfs.h> | 8 #include <sys/statvfs.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <utime.h> | 10 #include <utime.h> |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 RequestLocalFileSystemFunction* function_; | 558 RequestLocalFileSystemFunction* function_; |
559 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 559 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
560 // Renderer process id. | 560 // Renderer process id. |
561 int child_id_; | 561 int child_id_; |
562 // Extension source URL. | 562 // Extension source URL. |
563 scoped_refptr<const Extension> extension_; | 563 scoped_refptr<const Extension> extension_; |
564 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemCallbackDispatcher); | 564 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemCallbackDispatcher); |
565 }; | 565 }; |
566 | 566 |
567 FileBrowserPrivateAPI::FileBrowserPrivateAPI(Profile* profile) | 567 FileBrowserPrivateAPI::FileBrowserPrivateAPI(Profile* profile) |
568 : event_router_(make_scoped_refptr(new FileBrowserEventRouter(profile))) { | 568 : event_router_(new FileBrowserEventRouter(profile)) { |
569 (new FileBrowserHandlerParser)->Register(); | 569 (new FileBrowserHandlerParser)->Register(); |
570 | 570 |
571 ExtensionFunctionRegistry* registry = | 571 ExtensionFunctionRegistry* registry = |
572 ExtensionFunctionRegistry::GetInstance(); | 572 ExtensionFunctionRegistry::GetInstance(); |
573 registry->RegisterFunction<LogoutUserFunction>(); | 573 registry->RegisterFunction<LogoutUserFunction>(); |
574 registry->RegisterFunction<CancelFileDialogFunction>(); | 574 registry->RegisterFunction<CancelFileDialogFunction>(); |
575 registry->RegisterFunction<ExecuteTasksFileBrowserFunction>(); | 575 registry->RegisterFunction<ExecuteTasksFileBrowserFunction>(); |
576 registry->RegisterFunction<SetDefaultTaskFileBrowserFunction>(); | 576 registry->RegisterFunction<SetDefaultTaskFileBrowserFunction>(); |
577 registry->RegisterFunction<FileDialogStringsFunction>(); | 577 registry->RegisterFunction<FileDialogStringsFunction>(); |
578 registry->RegisterFunction<GetFileTasksFileBrowserFunction>(); | 578 registry->RegisterFunction<GetFileTasksFileBrowserFunction>(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 &FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread, | 713 &FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread, |
714 this, | 714 this, |
715 FileBrowserPrivateAPI::Get(profile_)->event_router(), | 715 FileBrowserPrivateAPI::Get(profile_)->event_router(), |
716 file_watch_url, | 716 file_watch_url, |
717 extension_id())); | 717 extension_id())); |
718 | 718 |
719 return true; | 719 return true; |
720 } | 720 } |
721 | 721 |
722 void FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread( | 722 void FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread( |
723 scoped_refptr<FileBrowserEventRouter> event_router, | 723 FileBrowserEventRouter* event_router, |
satorux1
2013/04/08 06:34:36
I think this is unsafe, as |event_router| could be
| |
724 const FileSystemURL& file_url, const std::string& extension_id) { | 724 const FileSystemURL& file_url, const std::string& extension_id) { |
725 base::FilePath local_path = file_url.path(); | 725 base::FilePath local_path = file_url.path(); |
726 base::FilePath virtual_path = file_url.virtual_path(); | 726 base::FilePath virtual_path = file_url.virtual_path(); |
727 bool result = !local_path.empty() && PerformFileWatchOperation( | 727 bool result = !local_path.empty() && PerformFileWatchOperation( |
728 event_router, local_path, virtual_path, extension_id); | 728 event_router, local_path, virtual_path, extension_id); |
729 | 729 |
730 BrowserThread::PostTask( | 730 BrowserThread::PostTask( |
731 BrowserThread::UI, FROM_HERE, | 731 BrowserThread::UI, FROM_HERE, |
732 base::Bind( | 732 base::Bind( |
733 &FileWatchBrowserFunctionBase::RespondOnUIThread, this, result)); | 733 &FileWatchBrowserFunctionBase::RespondOnUIThread, this, result)); |
734 } | 734 } |
735 | 735 |
736 bool AddFileWatchBrowserFunction::PerformFileWatchOperation( | 736 bool AddFileWatchBrowserFunction::PerformFileWatchOperation( |
737 scoped_refptr<FileBrowserEventRouter> event_router, | 737 FileBrowserEventRouter* event_router, |
738 const base::FilePath& local_path, const base::FilePath& virtual_path, | 738 const base::FilePath& local_path, const base::FilePath& virtual_path, |
739 const std::string& extension_id) { | 739 const std::string& extension_id) { |
740 return event_router->AddFileWatch(local_path, virtual_path, extension_id); | 740 return event_router->AddFileWatch(local_path, virtual_path, extension_id); |
741 } | 741 } |
742 | 742 |
743 bool RemoveFileWatchBrowserFunction::PerformFileWatchOperation( | 743 bool RemoveFileWatchBrowserFunction::PerformFileWatchOperation( |
744 scoped_refptr<FileBrowserEventRouter> event_router, | 744 FileBrowserEventRouter* event_router, |
745 const base::FilePath& local_path, const base::FilePath& unused, | 745 const base::FilePath& local_path, const base::FilePath& unused, |
746 const std::string& extension_id) { | 746 const std::string& extension_id) { |
747 event_router->RemoveFileWatch(local_path, extension_id); | 747 event_router->RemoveFileWatch(local_path, extension_id); |
748 return true; | 748 return true; |
749 } | 749 } |
750 | 750 |
751 // static | 751 // static |
752 void GetFileTasksFileBrowserFunction::IntersectAvailableDriveTasks( | 752 void GetFileTasksFileBrowserFunction::IntersectAvailableDriveTasks( |
753 drive::DriveWebAppsRegistry* registry, | 753 drive::DriveWebAppsRegistry* registry, |
754 const FileInfoList& file_info_list, | 754 const FileInfoList& file_info_list, |
(...skipping 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3315 OpenNewWindowFunction::OpenNewWindowFunction() {} | 3315 OpenNewWindowFunction::OpenNewWindowFunction() {} |
3316 | 3316 |
3317 OpenNewWindowFunction::~OpenNewWindowFunction() {} | 3317 OpenNewWindowFunction::~OpenNewWindowFunction() {} |
3318 | 3318 |
3319 bool OpenNewWindowFunction::RunImpl() { | 3319 bool OpenNewWindowFunction::RunImpl() { |
3320 std::string url; | 3320 std::string url; |
3321 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); | 3321 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); |
3322 file_manager_util::OpenNewWindow(profile_, GURL(url)); | 3322 file_manager_util::OpenNewWindow(profile_, GURL(url)); |
3323 return true; | 3323 return true; |
3324 } | 3324 } |
OLD | NEW |