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

Unified Diff: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc

Issue 10933137: Media Galleries: Change the media gallery name to be a JSON value with the name and pref id. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: dcheck Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_file_system_registry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
===================================================================
--- chrome/browser/extensions/api/media_galleries/media_galleries_api.cc (revision 157149)
+++ chrome/browser/extensions/api/media_galleries/media_galleries_api.cc (working copy)
@@ -6,10 +6,12 @@
#include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h"
+#include <set>
#include <string>
#include <vector>
#include "base/platform_file.h"
+#include "base/stl_util.h"
#include "base/values.h"
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/media_gallery/media_file_system_registry.h"
@@ -109,16 +111,27 @@
void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries(
const std::vector<MediaFileSystemInfo>& filesystems) {
const int child_id = render_view_host()->GetProcess()->GetID();
+ std::set<std::string> file_system_names;
base::ListValue* list = new base::ListValue();
for (size_t i = 0; i < filesystems.size(); i++) {
- base::DictionaryValue* dict_value = new base::DictionaryValue();
- dict_value->SetWithoutPathExpansion(
+ base::DictionaryValue* file_system_dict_value = new base::DictionaryValue();
+
+ // Send the file system id so the renderer can create a valid FileSystem
+ // object.
+ file_system_dict_value->SetWithoutPathExpansion(
"fsid", Value::CreateStringValue(filesystems[i].fsid));
- // The directory name is not exposed to the js layer.
- dict_value->SetWithoutPathExpansion(
+
+ // The name must be unique according to the HTML5 File System API spec.
+ if (ContainsKey(file_system_names, filesystems[i].name)) {
+ NOTREACHED() << "Duplicate file system name: " << filesystems[i].name;
+ continue;
+ }
+ file_system_names.insert(filesystems[i].name);
+ file_system_dict_value->SetWithoutPathExpansion(
"name", Value::CreateStringValue(filesystems[i].name));
- list->Append(dict_value);
+ list->Append(file_system_dict_value);
+
if (!filesystems[i].path.empty() &&
MediaGalleriesPermission::HasReadAccess(*GetExtension())) {
content::ChildProcessSecurityPolicy* policy =
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_file_system_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698