| 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 // Implements the Chrome Extensions Media Galleries API. | 5 // Implements the Chrome Extensions Media Galleries API. |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/media_gallery/media_gallery_api.h" | 7 #include "chrome/browser/extensions/api/media_gallery/media_gallery_api.h" |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 const int child_id = rph->GetID(); | 37 const int child_id = rph->GetID(); |
| 38 base::ListValue* list = new base::ListValue(); | 38 base::ListValue* list = new base::ListValue(); |
| 39 for (size_t i = 0; i < filesystems.size(); i++) { | 39 for (size_t i = 0; i < filesystems.size(); i++) { |
| 40 // TODO(thestig) Check permissions to file systems when that capability | 40 // TODO(thestig) Check permissions to file systems when that capability |
| 41 // exists. | 41 // exists. |
| 42 const MediaFileSystemRegistry::MediaFSIDAndPath& fsid_and_path = | 42 const MediaFileSystemRegistry::MediaFSIDAndPath& fsid_and_path = |
| 43 filesystems[i]; | 43 filesystems[i]; |
| 44 const std::string& fsid = fsid_and_path.first; | 44 const std::string& fsid = fsid_and_path.first; |
| 45 const FilePath& path = fsid_and_path.second; | 45 const FilePath& path = fsid_and_path.second; |
| 46 const std::string basepath_utf8(path.BaseName().AsUTF8Unsafe()); | |
| 47 | 46 |
| 48 base::DictionaryValue* dict_value = new base::DictionaryValue(); | 47 base::DictionaryValue* dict_value = new base::DictionaryValue(); |
| 49 dict_value->SetWithoutPathExpansion( | 48 dict_value->SetWithoutPathExpansion( |
| 50 "fsid", Value::CreateStringValue(fsid)); | 49 "fsid", Value::CreateStringValue(fsid)); |
| 50 // The directory name is not exposed to the js layer. |
| 51 dict_value->SetWithoutPathExpansion( | 51 dict_value->SetWithoutPathExpansion( |
| 52 "dirname", Value::CreateStringValue(basepath_utf8)); | 52 "dirname", Value::CreateStringValue("_")); |
| 53 list->Append(dict_value); | 53 list->Append(dict_value); |
| 54 | 54 |
| 55 content::ChildProcessSecurityPolicy* policy = | 55 content::ChildProcessSecurityPolicy* policy = |
| 56 ChildProcessSecurityPolicy::GetInstance(); | 56 ChildProcessSecurityPolicy::GetInstance(); |
| 57 if (!policy->CanReadFile(child_id, path)) | 57 if (!policy->CanReadFile(child_id, path)) |
| 58 policy->GrantReadFile(child_id, path); | 58 policy->GrantReadFile(child_id, path); |
| 59 policy->GrantReadFileSystem(child_id, fsid); | 59 policy->GrantReadFileSystem(child_id, fsid); |
| 60 } | 60 } |
| 61 | 61 |
| 62 result_.reset(list); | 62 result_.reset(list); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 73 | 73 |
| 74 AssembleMediaFileFunction::~AssembleMediaFileFunction() {} | 74 AssembleMediaFileFunction::~AssembleMediaFileFunction() {} |
| 75 | 75 |
| 76 bool AssembleMediaFileFunction::RunImpl() { | 76 bool AssembleMediaFileFunction::RunImpl() { |
| 77 // TODO(vandebo) Update the metadata and return the new file. | 77 // TODO(vandebo) Update the metadata and return the new file. |
| 78 result_.reset(Value::CreateNullValue()); | 78 result_.reset(Value::CreateNullValue()); |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace extensions | 82 } // namespace extensions |
| OLD | NEW |