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/extensions/api/file_handlers/app_file_handler_util.h" | 5 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "chrome/browser/extensions/extension_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 bool HasFileSystemWritePermission(const Extension* extension) { | 343 bool HasFileSystemWritePermission(const Extension* extension) { |
344 return extension->HasAPIPermission(APIPermission::kFileSystemWrite); | 344 return extension->HasAPIPermission(APIPermission::kFileSystemWrite); |
345 } | 345 } |
346 | 346 |
347 bool ValidateFileEntryAndGetPath( | 347 bool ValidateFileEntryAndGetPath( |
348 const std::string& filesystem_name, | 348 const std::string& filesystem_name, |
349 const std::string& filesystem_path, | 349 const std::string& filesystem_path, |
350 const content::RenderViewHost* render_view_host, | 350 const content::RenderViewHost* render_view_host, |
351 base::FilePath* file_path, | 351 base::FilePath* file_path, |
352 std::string* error) { | 352 std::string* error) { |
| 353 if (filesystem_path.empty()) { |
| 354 *error = kInvalidParameters; |
| 355 return false; |
| 356 } |
| 357 |
353 std::string filesystem_id; | 358 std::string filesystem_id; |
354 if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) { | 359 if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) { |
355 *error = kInvalidParameters; | 360 *error = kInvalidParameters; |
356 return false; | 361 return false; |
357 } | 362 } |
358 | 363 |
359 // Only return the display path if the process has read access to the | 364 // Only return the display path if the process has read access to the |
360 // filesystem. | 365 // filesystem. |
361 content::ChildProcessSecurityPolicy* policy = | 366 content::ChildProcessSecurityPolicy* policy = |
362 content::ChildProcessSecurityPolicy::GetInstance(); | 367 content::ChildProcessSecurityPolicy::GetInstance(); |
(...skipping 24 matching lines...) Expand all Loading... |
387 *error = kInvalidParameters; | 392 *error = kInvalidParameters; |
388 return false; | 393 return false; |
389 } | 394 } |
390 | 395 |
391 return true; | 396 return true; |
392 } | 397 } |
393 | 398 |
394 } // namespace app_file_handler_util | 399 } // namespace app_file_handler_util |
395 | 400 |
396 } // namespace extensions | 401 } // namespace extensions |
OLD | NEW |