| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/extensions/shell_window_registry.h" | 19 #include "chrome/browser/extensions/shell_window_registry.h" |
| 20 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 20 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
| 21 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" | 21 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" |
| 22 #include "chrome/browser/ui/chrome_select_file_policy.h" | 22 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 23 #include "chrome/browser/ui/extensions/shell_window.h" | 23 #include "chrome/browser/ui/extensions/shell_window.h" |
| 24 #include "chrome/common/extensions/api/experimental_media_galleries.h" | 24 #include "chrome/common/extensions/api/experimental_media_galleries.h" |
| 25 #include "chrome/common/extensions/api/media_galleries.h" | 25 #include "chrome/common/extensions/api/media_galleries.h" |
| 26 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/extensions/permissions/api_permission.h" | 27 #include "chrome/common/extensions/permissions/api_permission.h" |
| 28 #include "chrome/common/extensions/permissions/media_galleries_permission.h" | 28 #include "chrome/common/extensions/permissions/media_galleries_permission.h" |
| 29 #include "chrome/common/extensions/permissions/permissions_data.h" |
| 29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 30 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 31 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 31 #include "content/public/browser/child_process_security_policy.h" | 32 #include "content/public/browser/child_process_security_policy.h" |
| 32 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
| 33 #include "content/public/browser/render_view_host.h" | 34 #include "content/public/browser/render_view_host.h" |
| 34 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| 35 | 36 |
| 36 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 37 #include "base/strings/sys_string_conversions.h" | 38 #include "base/strings/sys_string_conversions.h" |
| 38 #endif | 39 #endif |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 140 |
| 140 void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries( | 141 void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries( |
| 141 const std::vector<MediaFileSystemInfo>& filesystems) { | 142 const std::vector<MediaFileSystemInfo>& filesystems) { |
| 142 content::RenderViewHost* rvh = render_view_host(); | 143 content::RenderViewHost* rvh = render_view_host(); |
| 143 if (!rvh) { | 144 if (!rvh) { |
| 144 SendResponse(false); | 145 SendResponse(false); |
| 145 return; | 146 return; |
| 146 } | 147 } |
| 147 MediaGalleriesPermission::CheckParam read_param( | 148 MediaGalleriesPermission::CheckParam read_param( |
| 148 MediaGalleriesPermission::kReadPermission); | 149 MediaGalleriesPermission::kReadPermission); |
| 149 bool has_read_permission = GetExtension()->CheckAPIPermissionWithParam( | 150 bool has_read_permission = PermissionsData::CheckAPIPermissionWithParam( |
| 150 APIPermission::kMediaGalleries, &read_param); | 151 GetExtension(), APIPermission::kMediaGalleries, &read_param); |
| 151 | 152 |
| 152 const int child_id = rvh->GetProcess()->GetID(); | 153 const int child_id = rvh->GetProcess()->GetID(); |
| 153 base::ListValue* list = new base::ListValue(); | 154 base::ListValue* list = new base::ListValue(); |
| 154 for (size_t i = 0; i < filesystems.size(); i++) { | 155 for (size_t i = 0; i < filesystems.size(); i++) { |
| 155 scoped_ptr<base::DictionaryValue> file_system_dict_value( | 156 scoped_ptr<base::DictionaryValue> file_system_dict_value( |
| 156 new base::DictionaryValue()); | 157 new base::DictionaryValue()); |
| 157 | 158 |
| 158 // Send the file system id so the renderer can create a valid FileSystem | 159 // Send the file system id so the renderer can create a valid FileSystem |
| 159 // object. | 160 // object. |
| 160 file_system_dict_value->SetStringWithoutPathExpansion( | 161 file_system_dict_value->SetStringWithoutPathExpansion( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { | 239 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { |
| 239 if (!ApiIsAccessible(&error_)) | 240 if (!ApiIsAccessible(&error_)) |
| 240 return false; | 241 return false; |
| 241 | 242 |
| 242 // TODO(vandebo) Update the metadata and return the new file. | 243 // TODO(vandebo) Update the metadata and return the new file. |
| 243 SetResult(base::Value::CreateNullValue()); | 244 SetResult(base::Value::CreateNullValue()); |
| 244 return true; | 245 return true; |
| 245 } | 246 } |
| 246 | 247 |
| 247 } // namespace extensions | 248 } // namespace extensions |
| OLD | NEW |