BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / chromeos / file_system_provider / operations / create_file.cc
blobc8a8e78aa9c0dbd8671bbb75ad01e68e7dca2cbd
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/file_system_provider/operations/create_file.h"
7 #include <string>
9 #include "chrome/common/extensions/api/file_system_provider.h"
10 #include "chrome/common/extensions/api/file_system_provider_internal.h"
12 namespace chromeos {
13 namespace file_system_provider {
14 namespace operations {
16 CreateFile::CreateFile(extensions::EventRouter* event_router,
17 const ProvidedFileSystemInfo& file_system_info,
18 const base::FilePath& file_path,
19 const storage::AsyncFileUtil::StatusCallback& callback)
20 : Operation(event_router, file_system_info),
21 file_path_(file_path),
22 callback_(callback) {
25 CreateFile::~CreateFile() {
28 bool CreateFile::Execute(int request_id) {
29 using extensions::api::file_system_provider::CreateFileRequestedOptions;
31 if (!file_system_info_.writable())
32 return false;
34 CreateFileRequestedOptions options;
35 options.file_system_id = file_system_info_.file_system_id();
36 options.request_id = request_id;
37 options.file_path = file_path_.AsUTF8Unsafe();
39 return SendEvent(
40 request_id,
41 extensions::events::FILE_SYSTEM_PROVIDER_ON_CREATE_FILE_REQUESTED,
42 extensions::api::file_system_provider::OnCreateFileRequested::kEventName,
43 extensions::api::file_system_provider::OnCreateFileRequested::Create(
44 options));
47 void CreateFile::OnSuccess(int /* request_id */,
48 scoped_ptr<RequestValue> /* result */,
49 bool has_more) {
50 callback_.Run(base::File::FILE_OK);
53 void CreateFile::OnError(int /* request_id */,
54 scoped_ptr<RequestValue> /* result */,
55 base::File::Error error) {
56 callback_.Run(error);
59 } // namespace operations
60 } // namespace file_system_provider
61 } // namespace chromeos