| Index: chrome/browser/google_apis/drive_api_operations.cc
|
| diff --git a/chrome/browser/google_apis/drive_api_operations.cc b/chrome/browser/google_apis/drive_api_operations.cc
|
| index d7f28fc8aebae3d061d0b23c0eedc99fd316fed4..1bb415214b37946a673699633e9635b7cc15fdb7 100644
|
| --- a/chrome/browser/google_apis/drive_api_operations.cc
|
| +++ b/chrome/browser/google_apis/drive_api_operations.cc
|
| @@ -4,7 +4,16 @@
|
|
|
| #include "chrome/browser/google_apis/drive_api_operations.h"
|
|
|
| +#include "base/json/json_writer.h"
|
| +#include "base/values.h"
|
| +
|
| namespace google_apis {
|
| +namespace {
|
| +
|
| +const char kContentTypeApplicationJson[] = "application/json";
|
| +const char kDirectoryMimeType[] = "application/vnd.google-apps.folder";
|
| +
|
| +} // namespace
|
|
|
| //============================== GetAboutOperation =============================
|
|
|
| @@ -106,4 +115,58 @@ GURL GetFileOperation::GetURL() const {
|
| return url_generator_.GetFileUrl(file_id_);
|
| }
|
|
|
| +namespace drive {
|
| +
|
| +//========================== CreateDirectoryOperation ==========================
|
| +
|
| +CreateDirectoryOperation::CreateDirectoryOperation(
|
| + OperationRegistry* registry,
|
| + net::URLRequestContextGetter* url_request_context_getter,
|
| + const DriveApiUrlGenerator& url_generator,
|
| + const std::string& parent_resource_id,
|
| + const std::string& directory_name,
|
| + const GetDataCallback& callback)
|
| + : GetDataOperation(registry, url_request_context_getter, callback),
|
| + url_generator_(url_generator),
|
| + parent_resource_id_(parent_resource_id),
|
| + directory_name_(directory_name) {
|
| + DCHECK(!callback.is_null());
|
| +}
|
| +
|
| +CreateDirectoryOperation::~CreateDirectoryOperation() {}
|
| +
|
| +GURL CreateDirectoryOperation::GetURL() const {
|
| + if (parent_resource_id_.empty() || directory_name_.empty()) {
|
| + return GURL();
|
| + }
|
| + return url_generator_.GetFilelistUrl(GURL(), "");
|
| +}
|
| +
|
| +net::URLFetcher::RequestType CreateDirectoryOperation::GetRequestType() const {
|
| + return net::URLFetcher::POST;
|
| +}
|
| +
|
| +bool CreateDirectoryOperation::GetContentData(std::string* upload_content_type,
|
| + std::string* upload_content) {
|
| + *upload_content_type = kContentTypeApplicationJson;
|
| +
|
| + base::DictionaryValue root;
|
| + root.SetString("title", directory_name_);
|
| + {
|
| + base::DictionaryValue* parent_value = new base::DictionaryValue;
|
| + parent_value->SetString("id", parent_resource_id_);
|
| + base::ListValue* parent_list_value = new base::ListValue;
|
| + parent_list_value->Append(parent_value);
|
| + root.Set("parents", parent_list_value);
|
| + }
|
| + root.SetString("mimeType", kDirectoryMimeType);
|
| +
|
| + base::JSONWriter::Write(&root, upload_content);
|
| +
|
| + DVLOG(1) << "CreateDirectory data: " << *upload_content_type << ", ["
|
| + << *upload_content << "]";
|
| + return true;
|
| +}
|
| +
|
| +} // namespace drive
|
| } // namespace google_apis
|
|
|