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

Side by Side Diff: chrome/browser/extensions/api/media_gallery/media_gallery_api.cc

Issue 10806023: switch mediaGalleries to .idl api definition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retry upload 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Implements the Chrome Extensions Media Galleries API.
6
7 #include "chrome/browser/extensions/api/media_gallery/media_gallery_api.h"
8
9 #include <string>
10 #include <vector>
11
12 #include "base/platform_file.h"
13 #include "base/values.h"
14 #include "chrome/browser/media_gallery/media_file_system_registry.h"
15 #include "content/public/browser/child_process_security_policy.h"
16 #include "content/public/browser/render_process_host.h"
17 #include "content/public/browser/render_view_host.h"
18
19 #if defined(OS_WIN)
20 #include "base/sys_string_conversions.h"
21 #endif
22
23 namespace extensions {
24
25 using chrome::MediaFileSystemRegistry;
26 using content::ChildProcessSecurityPolicy;
27
28 GetMediaFileSystemsFunction::~GetMediaFileSystemsFunction() {}
29
30 bool GetMediaFileSystemsFunction::RunImpl() {
31 const content::RenderProcessHost* rph = render_view_host()->GetProcess();
32 chrome::MediaFileSystemRegistry* media_fs_registry =
33 MediaFileSystemRegistry::GetInstance();
34 const std::vector<MediaFileSystemRegistry::MediaFSIDAndPath> filesystems =
35 media_fs_registry->GetMediaFileSystems(rph);
36
37 const int child_id = rph->GetID();
38 base::ListValue* list = new base::ListValue();
39 for (size_t i = 0; i < filesystems.size(); i++) {
40 // TODO(thestig) Check permissions to file systems when that capability
41 // exists.
42 const MediaFileSystemRegistry::MediaFSIDAndPath& fsid_and_path =
43 filesystems[i];
44 const std::string& fsid = fsid_and_path.first;
45 const FilePath& path = fsid_and_path.second;
46
47 base::DictionaryValue* dict_value = new base::DictionaryValue();
48 dict_value->SetWithoutPathExpansion(
49 "fsid", Value::CreateStringValue(fsid));
50 // The directory name is not exposed to the js layer.
51 dict_value->SetWithoutPathExpansion(
52 "dirname", Value::CreateStringValue("_"));
53 list->Append(dict_value);
54
55 content::ChildProcessSecurityPolicy* policy =
56 ChildProcessSecurityPolicy::GetInstance();
57 if (!policy->CanReadFile(child_id, path))
58 policy->GrantReadFile(child_id, path);
59 policy->GrantReadFileSystem(child_id, fsid);
60 }
61
62 SetResult(list);
63 return true;
64 }
65
66 OpenMediaGalleryManagerFunction::~OpenMediaGalleryManagerFunction() {}
67
68 bool OpenMediaGalleryManagerFunction::RunImpl() {
69 // TODO(vandebo) Open the Media Gallery Manager UI.
70 SetResult(Value::CreateNullValue());
71 return true;
72 }
73
74 AssembleMediaFileFunction::~AssembleMediaFileFunction() {}
75
76 bool AssembleMediaFileFunction::RunImpl() {
77 // TODO(vandebo) Update the metadata and return the new file.
78 SetResult(Value::CreateNullValue());
79 return true;
80 }
81
82 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698