Chromium Code Reviews| Index: chrome/browser/extensions/api/developer_private/developer_private_api.cc |
| diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
| index 89cf5df13f32bf9dff52cd110ca4453b0e9f4bda..c54d7a94d78821b1d56b301df6b1c4c8c0e97e55 100644 |
| --- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
| +++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
| @@ -56,6 +56,8 @@ namespace extensions { |
| namespace { |
| +char kUnpackedAppsFolder[] = "apps_target"; |
| + |
| ExtensionUpdater* GetExtensionUpdater(Profile* profile) { |
| return profile->GetExtensionService()->updater(); |
| } |
| @@ -816,7 +818,7 @@ void DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
| base::FilePath(file_list[i].name))); |
| base::FilePath target_path(profile()->GetPath()); |
| target_path = |
| - target_path.Append(FILE_PATH_LITERAL("apps_target")); |
| + target_path.Append(FILE_PATH_LITERAL(kUnpackedAppsFolder)); |
| target_path = target_path.Append(project_name); |
| target_path = target_path.Append(file_list[i].name); |
| @@ -877,6 +879,71 @@ DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
| DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
| ~DeveloperPrivateExportSyncfsFolderToLocalfsFunction() {} |
| +bool DeveloperPrivateLoadProjectToSyncfsFunction::RunImpl() { |
| + // TODO(grv) : implement |
| + return true; |
| +} |
| + |
| +DeveloperPrivateLoadProjectToSyncfsFunction:: |
| + DeveloperPrivateLoadProjectToSyncfsFunction() {} |
| + |
| +DeveloperPrivateLoadProjectToSyncfsFunction:: |
| + ~DeveloperPrivateLoadProjectToSyncfsFunction() {} |
| + |
| +bool DeveloperPrivateGetProjectsInfoFunction::RunImpl() { |
| + content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
| + base::Bind(&DeveloperPrivateGetProjectsInfoFunction::ReadFolder, |
| + this)); |
| + |
| + // Released by ReadFolder |
| + AddRef(); |
| + return true; |
| +} |
| + |
| +void DeveloperPrivateGetProjectsInfoFunction::ReadFolder() { |
| + base::FilePath path(profile()->GetPath()); |
| + path = path.Append(FILE_PATH_LITERAL(kUnpackedAppsFolder)); |
| + |
| + file_util::FileEnumerator files( |
| + path, false, file_util::FileEnumerator::DIRECTORIES); |
| + ProjectInfoList info_list; |
| + for (base::FilePath current_path = files.Next(); !current_path.empty(); |
| + current_path = files.Next()) { |
| + scoped_ptr<developer::ProjectInfo> info(new developer::ProjectInfo()); |
| + info->name = current_path.BaseName().MaybeAsASCII(); |
| + info_list.push_back( |
| + make_linked_ptr<developer::ProjectInfo>(info.release())); |
| + } |
| + results_ = developer::GetProjectsInfo::Results::Create(info_list); |
| + content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| + base::Bind(&DeveloperPrivateGetProjectsInfoFunction::SendResponse, |
| + this, |
| + true)); |
| + Release(); |
| +} |
| + |
| +DeveloperPrivateGetProjectsInfoFunction:: |
| + DeveloperPrivateGetProjectsInfoFunction() {} |
| + |
| +DeveloperPrivateGetProjectsInfoFunction:: |
| + ~DeveloperPrivateGetProjectsInfoFunction() {} |
| + |
| +bool DeveloperPrivateLoadProjectFunction::RunImpl() { |
| + std::string project_name; |
| + EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &project_name)); |
| + base::FilePath path(profile()->GetPath()); |
| + path = path.Append(FILE_PATH_LITERAL(kUnpackedAppsFolder)); |
| + path = path.Append(project_name); |
|
miket_OOO
2013/04/18 03:12:00
Please add a TODO to sanitize this value, and furt
Gaurav
2013/04/18 17:24:06
Done.
miket_OOO
2013/04/23 17:02:47
This didn't happen. What's going on?
Gaurav
2013/04/23 18:08:33
Added the checks for folder name validation (was t
|
| + ExtensionService* service = profile()->GetExtensionService(); |
| + UnpackedInstaller::Create(service)->Load(path); |
| + SendResponse(true); |
| + return true; |
| +} |
| + |
| +DeveloperPrivateLoadProjectFunction::DeveloperPrivateLoadProjectFunction() {} |
| + |
| +DeveloperPrivateLoadProjectFunction::~DeveloperPrivateLoadProjectFunction() {} |
| + |
| bool DeveloperPrivateChoosePathFunction::RunImpl() { |
| scoped_ptr<developer::ChoosePath::Params> params( |