Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: chrome/browser/extensions/api/file_system/file_system_api.cc

Issue 10694106: Added support for multiple parameters to Extension API callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review fixes. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/extensions/api/file_system/file_system_api.h" 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 std::string filesystem_path; 141 std::string filesystem_path;
142 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); 142 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name));
143 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); 143 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path));
144 144
145 FilePath file_path; 145 FilePath file_path;
146 if (!GetFilePathOfFileEntry(filesystem_name, filesystem_path, 146 if (!GetFilePathOfFileEntry(filesystem_name, filesystem_path,
147 render_view_host_, &file_path, &error_)) 147 render_view_host_, &file_path, &error_))
148 return false; 148 return false;
149 149
150 file_path = PrettifyPath(file_path); 150 file_path = PrettifyPath(file_path);
151 result_.reset(base::Value::CreateStringValue(file_path.value())); 151 SetSingleResult(base::Value::CreateStringValue(file_path.value()));
152 return true; 152 return true;
153 } 153 }
154 154
155 bool FileSystemEntryFunction::HasFileSystemWritePermission() { 155 bool FileSystemEntryFunction::HasFileSystemWritePermission() {
156 const extensions::Extension* extension = GetExtension(); 156 const extensions::Extension* extension = GetExtension();
157 if (!extension) 157 if (!extension)
158 return false; 158 return false;
159 159
160 return extension->HasAPIPermission(APIPermission::kFileSystemWrite); 160 return extension->HasAPIPermission(APIPermission::kFileSystemWrite);
161 } 161 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 else 193 else
194 policy->GrantReadFileSystem(renderer_id, filesystem_id); 194 policy->GrantReadFileSystem(renderer_id, filesystem_id);
195 195
196 // We only need file level access for reading FileEntries. Saving FileEntries 196 // We only need file level access for reading FileEntries. Saving FileEntries
197 // just needs the file system to have read/write access, which is granted 197 // just needs the file system to have read/write access, which is granted
198 // above if required. 198 // above if required.
199 if (!policy->CanReadFile(renderer_id, path)) 199 if (!policy->CanReadFile(renderer_id, path))
200 policy->GrantReadFile(renderer_id, path); 200 policy->GrantReadFile(renderer_id, path);
201 201
202 DictionaryValue* dict = new DictionaryValue(); 202 DictionaryValue* dict = new DictionaryValue();
203 result_.reset(dict); 203 SetSingleResult(dict);
204 dict->SetString("fileSystemId", filesystem_id); 204 dict->SetString("fileSystemId", filesystem_id);
205 dict->SetString("baseName", path.BaseName().AsUTF8Unsafe()); 205 dict->SetString("baseName", path.BaseName().AsUTF8Unsafe());
206 SendResponse(true); 206 SendResponse(true);
207 } 207 }
208 208
209 void FileSystemEntryFunction::HandleWritableFileError() { 209 void FileSystemEntryFunction::HandleWritableFileError() {
210 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 210 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
211 error_ = kWritableFileError; 211 error_ = kWritableFileError;
212 SendResponse(false); 212 SendResponse(false);
213 } 213 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 if (entry_type == WRITABLE && !HasFileSystemWritePermission()) { 390 if (entry_type == WRITABLE && !HasFileSystemWritePermission()) {
391 error_ = kRequiresFileSystemWriteError; 391 error_ = kRequiresFileSystemWriteError;
392 return false; 392 return false;
393 } 393 }
394 394
395 return ShowPicker(FilePath(), picker_type, entry_type); 395 return ShowPicker(FilePath(), picker_type, entry_type);
396 } 396 }
397 397
398 } // namespace extensions 398 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698