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 <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 render_view_host(), GetExtension(), base::Bind( | 107 render_view_host(), GetExtension(), base::Bind( |
108 &MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries, this)); | 108 &MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries, this)); |
109 } | 109 } |
110 | 110 |
111 void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries( | 111 void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries( |
112 const std::vector<MediaFileSystemInfo>& filesystems) { | 112 const std::vector<MediaFileSystemInfo>& filesystems) { |
113 const int child_id = render_view_host()->GetProcess()->GetID(); | 113 const int child_id = render_view_host()->GetProcess()->GetID(); |
114 std::set<std::string> file_system_names; | 114 std::set<std::string> file_system_names; |
115 base::ListValue* list = new base::ListValue(); | 115 base::ListValue* list = new base::ListValue(); |
116 for (size_t i = 0; i < filesystems.size(); i++) { | 116 for (size_t i = 0; i < filesystems.size(); i++) { |
117 base::DictionaryValue* file_system_dict_value = new base::DictionaryValue(); | 117 scoped_ptr<base::DictionaryValue> file_system_dict_value( |
118 new base::DictionaryValue()); | |
118 | 119 |
119 // Send the file system id so the renderer can create a valid FileSystem | 120 // Send the file system id so the renderer can create a valid FileSystem |
120 // object. | 121 // object. |
121 file_system_dict_value->SetWithoutPathExpansion( | 122 file_system_dict_value->SetWithoutPathExpansion( |
122 "fsid", Value::CreateStringValue(filesystems[i].fsid)); | 123 "fsid", Value::CreateStringValue(filesystems[i].fsid)); |
123 | 124 |
124 // The name must be unique according to the HTML5 File System API spec. | 125 // The name must be unique according to the HTML5 File System API spec. |
125 if (ContainsKey(file_system_names, filesystems[i].name)) { | 126 if (ContainsKey(file_system_names, filesystems[i].name)) { |
126 NOTREACHED() << "Duplicate file system name: " << filesystems[i].name; | 127 NOTREACHED() << "Duplicate file system name: " << filesystems[i].name; |
127 continue; | 128 continue; |
not at google - send to devlin
2012/09/21 01:08:33
leak here
| |
128 } | 129 } |
129 file_system_names.insert(filesystems[i].name); | 130 file_system_names.insert(filesystems[i].name); |
130 file_system_dict_value->SetWithoutPathExpansion( | 131 file_system_dict_value->SetWithoutPathExpansion( |
131 "name", Value::CreateStringValue(filesystems[i].name)); | 132 "name", Value::CreateStringValue(filesystems[i].name)); |
132 | 133 |
133 list->Append(file_system_dict_value); | 134 list->Append(file_system_dict_value.release()); |
134 | 135 |
135 if (!filesystems[i].path.empty() && | 136 if (!filesystems[i].path.empty() && |
136 MediaGalleriesPermission::HasReadAccess(*GetExtension())) { | 137 MediaGalleriesPermission::HasReadAccess(*GetExtension())) { |
137 content::ChildProcessSecurityPolicy* policy = | 138 content::ChildProcessSecurityPolicy* policy = |
138 ChildProcessSecurityPolicy::GetInstance(); | 139 ChildProcessSecurityPolicy::GetInstance(); |
139 if (!policy->CanReadFile(child_id, filesystems[i].path)) | 140 if (!policy->CanReadFile(child_id, filesystems[i].path)) |
140 policy->GrantReadFile(child_id, filesystems[i].path); | 141 policy->GrantReadFile(child_id, filesystems[i].path); |
141 policy->GrantReadFileSystem(child_id, filesystems[i].fsid); | 142 policy->GrantReadFileSystem(child_id, filesystems[i].fsid); |
142 } | 143 } |
143 // TODO(vandebo) Handle write permission. | 144 // TODO(vandebo) Handle write permission. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { | 178 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { |
178 if (!ApiIsAccessible(&error_)) | 179 if (!ApiIsAccessible(&error_)) |
179 return false; | 180 return false; |
180 | 181 |
181 // TODO(vandebo) Update the metadata and return the new file. | 182 // TODO(vandebo) Update the metadata and return the new file. |
182 SetResult(Value::CreateNullValue()); | 183 SetResult(Value::CreateNullValue()); |
183 return true; | 184 return true; |
184 } | 185 } |
185 | 186 |
186 } // namespace extensions | 187 } // namespace extensions |
OLD | NEW |