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

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

Issue 10409084: Media Gallery: Implement a basic version of GetMediaFileSystems(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_file_system_registry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_gallery/media_gallery_api.h" 7 #include "chrome/browser/extensions/api/media_gallery/media_gallery_api.h"
8 8
9 #include "base/json/json_writer.h" 9 #include <string>
10 #include <vector>
11
12 #include "base/platform_file.h"
10 #include "base/values.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"
11 18
12 namespace extensions { 19 namespace extensions {
13 20
21 using chrome::MediaFileSystemRegistry;
22 using content::ChildProcessSecurityPolicy;
23
14 GetMediaFileSystemsFunction::~GetMediaFileSystemsFunction() {} 24 GetMediaFileSystemsFunction::~GetMediaFileSystemsFunction() {}
15 25
16 bool GetMediaFileSystemsFunction::RunImpl() { 26 bool GetMediaFileSystemsFunction::RunImpl() {
17 // TODO(vandebo) Get the list of galleries. 27 chrome::MediaFileSystemRegistry* media_fs_registry =
18 result_.reset(new ListValue()); 28 MediaFileSystemRegistry::GetInstance();
29 const std::vector<MediaFileSystemRegistry::MediaFSIDAndPath> filesystems =
30 media_fs_registry->GetMediaFileSystems();
31
32 base::ListValue* list = new base::ListValue();
33 for (size_t i = 0; i < filesystems.size(); i++) {
34 // TODO(thestig) Check permissions to file systems when that capability
35 // exists.
36 const MediaFileSystemRegistry::MediaFSIDAndPath& fsid_and_path =
37 filesystems[i];
38 const std::string& fsid = fsid_and_path.first;
39 const FilePath& path = fsid_and_path.second;
40 const FilePath::StringType basepath = path.BaseName().value();
41 #if defined(OS_WIN)
42 // We standardize on UTF8 encoding for |basepath|.
43 const std::string basepath_utf8(base::SysWideToUTF8(basepath);
44 #elif defined(OS_POSIX)
45 const std::string basepath_utf8(basepath);
46 #endif
47
48 base::DictionaryValue* dict_value = new base::DictionaryValue();
49 dict_value->SetWithoutPathExpansion(
50 "fsid", Value::CreateStringValue(fsid));
51 dict_value->SetWithoutPathExpansion(
52 "dirname", Value::CreateStringValue(basepath_utf8));
53 list->Append(dict_value);
54
55 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile(
kinuko 2012/05/25 09:30:38 Instead of specifying detailed permissions you can
vandebo (ex-Chrome) 2012/05/29 16:46:07 Should this be GrantReadDirectory or even GrantAcc
Lei Zhang 2012/05/29 23:26:41 Done.
Lei Zhang 2012/05/29 23:26:41 In the current ChildProcessSecurityPolicy implemen
kinuko 2012/05/30 09:45:13 Yup... if my one lands earlier please change these
56 render_view_host()->GetProcess()->GetID(),
57 path,
58 (base::PLATFORM_FILE_OPEN |
59 base::PLATFORM_FILE_READ |
60 base::PLATFORM_FILE_EXCLUSIVE_READ |
61 base::PLATFORM_FILE_ASYNC));
62 }
63
64 result_.reset(list);
19 return true; 65 return true;
20 } 66 }
21 67
22 OpenMediaGalleryManagerFunction::~OpenMediaGalleryManagerFunction() {} 68 OpenMediaGalleryManagerFunction::~OpenMediaGalleryManagerFunction() {}
23 69
24 bool OpenMediaGalleryManagerFunction::RunImpl() { 70 bool OpenMediaGalleryManagerFunction::RunImpl() {
25 // TODO(vandebo) Open the Media Gallery Manager UI. 71 // TODO(vandebo) Open the Media Gallery Manager UI.
26 result_.reset(Value::CreateNullValue()); 72 result_.reset(Value::CreateNullValue());
27 return true; 73 return true;
28 } 74 }
29 75
30 AssembleMediaFileFunction::~AssembleMediaFileFunction() {} 76 AssembleMediaFileFunction::~AssembleMediaFileFunction() {}
31 77
32 bool AssembleMediaFileFunction::RunImpl() { 78 bool AssembleMediaFileFunction::RunImpl() {
33 // TODO(vandebo) Update the metadata and return the new file. 79 // TODO(vandebo) Update the metadata and return the new file.
34 result_.reset(Value::CreateNullValue()); 80 result_.reset(Value::CreateNullValue());
35 return true; 81 return true;
36 } 82 }
37 83
38 } // namespace extensions 84 } // namespace extensions
OLDNEW
« 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