| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 base::ListValue* ConstructFileSystemList( | 137 base::ListValue* ConstructFileSystemList( |
| 138 content::RenderViewHost* rvh, | 138 content::RenderViewHost* rvh, |
| 139 const Extension* extension, | 139 const Extension* extension, |
| 140 const std::vector<MediaFileSystemInfo>& filesystems) { | 140 const std::vector<MediaFileSystemInfo>& filesystems) { |
| 141 if (!rvh) | 141 if (!rvh) |
| 142 return NULL; | 142 return NULL; |
| 143 | 143 |
| 144 MediaGalleriesPermission::CheckParam read_param( | 144 MediaGalleriesPermission::CheckParam read_param( |
| 145 MediaGalleriesPermission::kReadPermission); | 145 MediaGalleriesPermission::kReadPermission); |
| 146 const PermissionsData* permissions_data = | 146 const PermissionsData* permissions_data = extension->permissions_data(); |
| 147 PermissionsData::ForExtension(extension); | |
| 148 bool has_read_permission = permissions_data->CheckAPIPermissionWithParam( | 147 bool has_read_permission = permissions_data->CheckAPIPermissionWithParam( |
| 149 APIPermission::kMediaGalleries, &read_param); | 148 APIPermission::kMediaGalleries, &read_param); |
| 150 MediaGalleriesPermission::CheckParam copy_to_param( | 149 MediaGalleriesPermission::CheckParam copy_to_param( |
| 151 MediaGalleriesPermission::kCopyToPermission); | 150 MediaGalleriesPermission::kCopyToPermission); |
| 152 bool has_copy_to_permission = permissions_data->CheckAPIPermissionWithParam( | 151 bool has_copy_to_permission = permissions_data->CheckAPIPermissionWithParam( |
| 153 APIPermission::kMediaGalleries, ©_to_param); | 152 APIPermission::kMediaGalleries, ©_to_param); |
| 154 MediaGalleriesPermission::CheckParam delete_param( | 153 MediaGalleriesPermission::CheckParam delete_param( |
| 155 MediaGalleriesPermission::kDeletePermission); | 154 MediaGalleriesPermission::kDeletePermission); |
| 156 bool has_delete_permission = permissions_data->CheckAPIPermissionWithParam( | 155 bool has_delete_permission = permissions_data->CheckAPIPermissionWithParam( |
| 157 APIPermission::kMediaGalleries, &delete_param); | 156 APIPermission::kMediaGalleries, &delete_param); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 return list.release(); | 203 return list.release(); |
| 205 } | 204 } |
| 206 | 205 |
| 207 bool CheckScanPermission(const extensions::Extension* extension, | 206 bool CheckScanPermission(const extensions::Extension* extension, |
| 208 std::string* error) { | 207 std::string* error) { |
| 209 DCHECK(extension); | 208 DCHECK(extension); |
| 210 DCHECK(error); | 209 DCHECK(error); |
| 211 MediaGalleriesPermission::CheckParam scan_param( | 210 MediaGalleriesPermission::CheckParam scan_param( |
| 212 MediaGalleriesPermission::kScanPermission); | 211 MediaGalleriesPermission::kScanPermission); |
| 213 bool has_scan_permission = | 212 bool has_scan_permission = |
| 214 PermissionsData::ForExtension(extension)->CheckAPIPermissionWithParam( | 213 extension->permissions_data()->CheckAPIPermissionWithParam( |
| 215 APIPermission::kMediaGalleries, &scan_param); | 214 APIPermission::kMediaGalleries, &scan_param); |
| 216 if (!has_scan_permission) | 215 if (!has_scan_permission) |
| 217 *error = kNoScanPermission; | 216 *error = kNoScanPermission; |
| 218 return has_scan_permission; | 217 return has_scan_permission; |
| 219 } | 218 } |
| 220 | 219 |
| 221 class SelectDirectoryDialog : public ui::SelectFileDialog::Listener, | 220 class SelectDirectoryDialog : public ui::SelectFileDialog::Listener, |
| 222 public base::RefCounted<SelectDirectoryDialog> { | 221 public base::RefCounted<SelectDirectoryDialog> { |
| 223 public: | 222 public: |
| 224 // Selected file path, or an empty path if the user canceled. | 223 // Selected file path, or an empty path if the user canceled. |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 return; | 981 return; |
| 983 } | 982 } |
| 984 | 983 |
| 985 // All Blobs have been constructed. The renderer will take ownership. | 984 // All Blobs have been constructed. The renderer will take ownership. |
| 986 SetResult(result_dictionary.release()); | 985 SetResult(result_dictionary.release()); |
| 987 SetTransferredBlobUUIDs(*blob_uuids); | 986 SetTransferredBlobUUIDs(*blob_uuids); |
| 988 SendResponse(true); | 987 SendResponse(true); |
| 989 } | 988 } |
| 990 | 989 |
| 991 } // namespace extensions | 990 } // namespace extensions |
| OLD | NEW |