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

Unified Diff: chrome/browser/extensions/api/media_gallery/media_gallery_api.cc

Issue 10816024: Revert 147895 - switch mediaGalleries to .idl api definition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
Index: chrome/browser/extensions/api/media_gallery/media_gallery_api.cc
diff --git a/chrome/browser/extensions/api/media_gallery/media_gallery_api.cc b/chrome/browser/extensions/api/media_gallery/media_gallery_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..15698f6081fcc0582d9248ec50199fa61e7e28ee
--- /dev/null
+++ b/chrome/browser/extensions/api/media_gallery/media_gallery_api.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Implements the Chrome Extensions Media Galleries API.
+
+#include "chrome/browser/extensions/api/media_gallery/media_gallery_api.h"
+
+#include <string>
+#include <vector>
+
+#include "base/platform_file.h"
+#include "base/values.h"
+#include "chrome/browser/media_gallery/media_file_system_registry.h"
+#include "content/public/browser/child_process_security_policy.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/render_view_host.h"
+
+#if defined(OS_WIN)
+#include "base/sys_string_conversions.h"
+#endif
+
+namespace extensions {
+
+using chrome::MediaFileSystemRegistry;
+using content::ChildProcessSecurityPolicy;
+
+GetMediaFileSystemsFunction::~GetMediaFileSystemsFunction() {}
+
+bool GetMediaFileSystemsFunction::RunImpl() {
+ const content::RenderProcessHost* rph = render_view_host()->GetProcess();
+ chrome::MediaFileSystemRegistry* media_fs_registry =
+ MediaFileSystemRegistry::GetInstance();
+ const std::vector<MediaFileSystemRegistry::MediaFSIDAndPath> filesystems =
+ media_fs_registry->GetMediaFileSystems(rph);
+
+ const int child_id = rph->GetID();
+ base::ListValue* list = new base::ListValue();
+ for (size_t i = 0; i < filesystems.size(); i++) {
+ // TODO(thestig) Check permissions to file systems when that capability
+ // exists.
+ const MediaFileSystemRegistry::MediaFSIDAndPath& fsid_and_path =
+ filesystems[i];
+ const std::string& fsid = fsid_and_path.first;
+ const FilePath& path = fsid_and_path.second;
+
+ base::DictionaryValue* dict_value = new base::DictionaryValue();
+ dict_value->SetWithoutPathExpansion(
+ "fsid", Value::CreateStringValue(fsid));
+ // The directory name is not exposed to the js layer.
+ dict_value->SetWithoutPathExpansion(
+ "dirname", Value::CreateStringValue("_"));
+ list->Append(dict_value);
+
+ content::ChildProcessSecurityPolicy* policy =
+ ChildProcessSecurityPolicy::GetInstance();
+ if (!policy->CanReadFile(child_id, path))
+ policy->GrantReadFile(child_id, path);
+ policy->GrantReadFileSystem(child_id, fsid);
+ }
+
+ SetResult(list);
+ return true;
+}
+
+OpenMediaGalleryManagerFunction::~OpenMediaGalleryManagerFunction() {}
+
+bool OpenMediaGalleryManagerFunction::RunImpl() {
+ // TODO(vandebo) Open the Media Gallery Manager UI.
+ SetResult(Value::CreateNullValue());
+ return true;
+}
+
+AssembleMediaFileFunction::~AssembleMediaFileFunction() {}
+
+bool AssembleMediaFileFunction::RunImpl() {
+ // TODO(vandebo) Update the metadata and return the new file.
+ SetResult(Value::CreateNullValue());
+ return true;
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698