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_galleries/media_galleries_api.h" | 7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } else if (interactive == "if_needed") { | 52 } else if (interactive == "if_needed") { |
53 // TODO(estade): implement. | 53 // TODO(estade): implement. |
54 } else if (interactive != "no") { | 54 } else if (interactive != "no") { |
55 error_ = kInvalidInteractive; | 55 error_ = kInvalidInteractive; |
56 return false; | 56 return false; |
57 } | 57 } |
58 | 58 |
59 const content::RenderProcessHost* rph = render_view_host()->GetProcess(); | 59 const content::RenderProcessHost* rph = render_view_host()->GetProcess(); |
60 chrome::MediaFileSystemRegistry* media_fs_registry = | 60 chrome::MediaFileSystemRegistry* media_fs_registry = |
61 MediaFileSystemRegistry::GetInstance(); | 61 MediaFileSystemRegistry::GetInstance(); |
62 const std::vector<MediaFileSystemRegistry::MediaFSIDAndPath> filesystems = | 62 const std::vector<MediaFileSystemRegistry::MediaFSInfo> filesystems = |
63 media_fs_registry->GetMediaFileSystems(rph, *GetExtension()); | 63 media_fs_registry->GetMediaFileSystemsForExtension(rph, *GetExtension()); |
64 | 64 |
65 const int child_id = rph->GetID(); | 65 const int child_id = rph->GetID(); |
66 base::ListValue* list = new base::ListValue(); | 66 base::ListValue* list = new base::ListValue(); |
67 for (size_t i = 0; i < filesystems.size(); i++) { | 67 for (size_t i = 0; i < filesystems.size(); i++) { |
68 // TODO(thestig) Check permissions to file systems when that capability | |
69 // exists. | |
70 const MediaFileSystemRegistry::MediaFSIDAndPath& fsid_and_path = | |
71 filesystems[i]; | |
72 const std::string& fsid = fsid_and_path.first; | |
73 const FilePath& path = fsid_and_path.second; | |
74 | |
75 base::DictionaryValue* dict_value = new base::DictionaryValue(); | 68 base::DictionaryValue* dict_value = new base::DictionaryValue(); |
76 dict_value->SetWithoutPathExpansion( | 69 dict_value->SetWithoutPathExpansion( |
77 "fsid", Value::CreateStringValue(fsid)); | 70 "fsid", Value::CreateStringValue(filesystems[i].fsid)); |
78 // The directory name is not exposed to the js layer. | 71 // The directory name is not exposed to the js layer. |
79 dict_value->SetWithoutPathExpansion( | 72 dict_value->SetWithoutPathExpansion( |
80 "dirname", Value::CreateStringValue("_")); | 73 "name", Value::CreateStringValue(filesystems[i].name)); |
81 list->Append(dict_value); | 74 list->Append(dict_value); |
82 | 75 |
83 | |
84 if (GetExtension()->HasAPIPermission( | 76 if (GetExtension()->HasAPIPermission( |
85 extensions::APIPermission::kMediaGalleriesRead)) { | 77 extensions::APIPermission::kMediaGalleriesRead)) { |
86 content::ChildProcessSecurityPolicy* policy = | 78 content::ChildProcessSecurityPolicy* policy = |
87 ChildProcessSecurityPolicy::GetInstance(); | 79 ChildProcessSecurityPolicy::GetInstance(); |
88 if (!policy->CanReadFile(child_id, path)) | 80 if (!policy->CanReadFile(child_id, filesystems[i].path)) |
89 policy->GrantReadFile(child_id, path); | 81 policy->GrantReadFile(child_id, filesystems[i].path); |
90 policy->GrantReadFileSystem(child_id, fsid); | 82 policy->GrantReadFileSystem(child_id, filesystems[i].fsid); |
91 } | 83 } |
92 // TODO(vandebo) Handle write permission. | 84 // TODO(vandebo) Handle write permission. |
93 } | 85 } |
94 | 86 |
95 SetResult(list); | 87 SetResult(list); |
96 return true; | 88 return true; |
97 } | 89 } |
98 | 90 |
99 MediaGalleriesAssembleMediaFileFunction:: | 91 MediaGalleriesAssembleMediaFileFunction:: |
100 ~MediaGalleriesAssembleMediaFileFunction() {} | 92 ~MediaGalleriesAssembleMediaFileFunction() {} |
101 | 93 |
102 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { | 94 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { |
103 // TODO(vandebo) Update the metadata and return the new file. | 95 // TODO(vandebo) Update the metadata and return the new file. |
104 SetResult(Value::CreateNullValue()); | 96 SetResult(Value::CreateNullValue()); |
105 return true; | 97 return true; |
106 } | 98 } |
107 | 99 |
108 } // namespace extensions | 100 } // namespace extensions |
OLD | NEW |