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

Side by Side Diff: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc

Issue 12213076: Media Galleries: Disable write support. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const std::vector<MediaFileSystemInfo>& filesystems) { 136 const std::vector<MediaFileSystemInfo>& filesystems) {
137 content::RenderViewHost* rvh = render_view_host(); 137 content::RenderViewHost* rvh = render_view_host();
138 if (!rvh) { 138 if (!rvh) {
139 SendResponse(false); 139 SendResponse(false);
140 return; 140 return;
141 } 141 }
142 MediaGalleriesPermission::CheckParam read_param( 142 MediaGalleriesPermission::CheckParam read_param(
143 MediaGalleriesPermission::kReadPermission); 143 MediaGalleriesPermission::kReadPermission);
144 bool has_read_permission = GetExtension()->CheckAPIPermissionWithParam( 144 bool has_read_permission = GetExtension()->CheckAPIPermissionWithParam(
145 APIPermission::kMediaGalleries, &read_param); 145 APIPermission::kMediaGalleries, &read_param);
146 MediaGalleriesPermission::CheckParam write_param(
147 MediaGalleriesPermission::kWritePermission);
148 bool has_write_permission = GetExtension()->CheckAPIPermissionWithParam(
149 APIPermission::kMediaGalleries, &write_param);
150 146
151 const int child_id = rvh->GetProcess()->GetID(); 147 const int child_id = rvh->GetProcess()->GetID();
152 std::set<std::string> file_system_names; 148 std::set<std::string> file_system_names;
153 base::ListValue* list = new base::ListValue(); 149 base::ListValue* list = new base::ListValue();
154 for (size_t i = 0; i < filesystems.size(); i++) { 150 for (size_t i = 0; i < filesystems.size(); i++) {
155 scoped_ptr<base::DictionaryValue> file_system_dict_value( 151 scoped_ptr<base::DictionaryValue> file_system_dict_value(
156 new base::DictionaryValue()); 152 new base::DictionaryValue());
157 153
158 // Send the file system id so the renderer can create a valid FileSystem 154 // Send the file system id so the renderer can create a valid FileSystem
159 // object. 155 // object.
(...skipping 18 matching lines...) Expand all
178 file_system_dict_value->SetBooleanWithoutPathExpansion( 174 file_system_dict_value->SetBooleanWithoutPathExpansion(
179 kIsRemovableKey, filesystems[i].removable); 175 kIsRemovableKey, filesystems[i].removable);
180 file_system_dict_value->SetBooleanWithoutPathExpansion( 176 file_system_dict_value->SetBooleanWithoutPathExpansion(
181 kIsMediaDeviceKey, filesystems[i].media_device); 177 kIsMediaDeviceKey, filesystems[i].media_device);
182 178
183 list->Append(file_system_dict_value.release()); 179 list->Append(file_system_dict_value.release());
184 180
185 if (filesystems[i].path.empty()) 181 if (filesystems[i].path.empty())
186 continue; 182 continue;
187 183
188 if (has_read_permission || has_write_permission) { 184 if (has_read_permission) {
189 content::ChildProcessSecurityPolicy* policy = 185 content::ChildProcessSecurityPolicy* policy =
190 ChildProcessSecurityPolicy::GetInstance(); 186 ChildProcessSecurityPolicy::GetInstance();
191 if (!policy->CanReadFile(child_id, filesystems[i].path)) 187 if (!policy->CanReadFile(child_id, filesystems[i].path))
192 policy->GrantReadFile(child_id, filesystems[i].path); 188 policy->GrantReadFile(child_id, filesystems[i].path);
193 policy->GrantReadFileSystem(child_id, filesystems[i].fsid); 189 policy->GrantReadFileSystem(child_id, filesystems[i].fsid);
194 if (has_write_permission) {
195 policy->GrantWriteFileSystem(child_id, filesystems[i].fsid);
196 policy->GrantCreateFileForFileSystem(child_id, filesystems[i].fsid);
197 }
198 } 190 }
199 } 191 }
200 192
201 SetResult(list); 193 SetResult(list);
202 SendResponse(true); 194 SendResponse(true);
203 } 195 }
204 196
205 void MediaGalleriesGetMediaFileSystemsFunction::ShowDialog() { 197 void MediaGalleriesGetMediaFileSystemsFunction::ShowDialog() {
206 WebContents* contents = WebContents::FromRenderViewHost(render_view_host()); 198 WebContents* contents = WebContents::FromRenderViewHost(render_view_host());
207 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 199 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { 240 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() {
249 if (!ApiIsAccessible(&error_)) 241 if (!ApiIsAccessible(&error_))
250 return false; 242 return false;
251 243
252 // TODO(vandebo) Update the metadata and return the new file. 244 // TODO(vandebo) Update the metadata and return the new file.
253 SetResult(base::Value::CreateNullValue()); 245 SetResult(base::Value::CreateNullValue());
254 return true; 246 return true;
255 } 247 }
256 248
257 } // namespace extensions 249 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698