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_gallery/media_gallery_api.h" | 7 #include "chrome/browser/extensions/api/media_gallery/media_gallery_api.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 const FilePath& path = fsid_and_path.second; | 45 const FilePath& path = fsid_and_path.second; |
46 | 46 |
47 base::DictionaryValue* dict_value = new base::DictionaryValue(); | 47 base::DictionaryValue* dict_value = new base::DictionaryValue(); |
48 dict_value->SetWithoutPathExpansion( | 48 dict_value->SetWithoutPathExpansion( |
49 "fsid", Value::CreateStringValue(fsid)); | 49 "fsid", Value::CreateStringValue(fsid)); |
50 // The directory name is not exposed to the js layer. | 50 // The directory name is not exposed to the js layer. |
51 dict_value->SetWithoutPathExpansion( | 51 dict_value->SetWithoutPathExpansion( |
52 "dirname", Value::CreateStringValue("_")); | 52 "dirname", Value::CreateStringValue("_")); |
53 list->Append(dict_value); | 53 list->Append(dict_value); |
54 | 54 |
55 content::ChildProcessSecurityPolicy* policy = | 55 |
56 ChildProcessSecurityPolicy::GetInstance(); | 56 if (GetExtension()->HasAPIPermission( |
57 if (!policy->CanReadFile(child_id, path)) | 57 extensions::APIPermission::kMediaGalleriesRead)) { |
58 policy->GrantReadFile(child_id, path); | 58 content::ChildProcessSecurityPolicy* policy = |
59 policy->GrantReadFileSystem(child_id, fsid); | 59 ChildProcessSecurityPolicy::GetInstance(); |
60 if (!policy->CanReadFile(child_id, path)) | |
61 policy->GrantReadFile(child_id, path); | |
62 policy->GrantReadFileSystem(child_id, fsid); | |
63 } | |
Matt Perry
2012/07/24 00:21:07
What happens if the extension doesn't have read pe
vandebo (ex-Chrome)
2012/07/24 00:32:57
It's an implementation detail that we could get he
Matt Perry
2012/07/24 00:51:20
But an extension could get here by only requesting
vandebo (ex-Chrome)
2012/07/24 01:07:59
Correct. That's not an error. But right now, onl
| |
64 // TODO(vandebo) Handle write permission. | |
60 } | 65 } |
61 | 66 |
62 SetResult(list); | 67 SetResult(list); |
63 return true; | 68 return true; |
64 } | 69 } |
65 | 70 |
66 OpenMediaGalleryManagerFunction::~OpenMediaGalleryManagerFunction() {} | 71 OpenMediaGalleryManagerFunction::~OpenMediaGalleryManagerFunction() {} |
67 | 72 |
68 bool OpenMediaGalleryManagerFunction::RunImpl() { | 73 bool OpenMediaGalleryManagerFunction::RunImpl() { |
69 // TODO(vandebo) Open the Media Gallery Manager UI. | 74 // TODO(vandebo) Open the Media Gallery Manager UI. |
70 SetResult(Value::CreateNullValue()); | 75 SetResult(Value::CreateNullValue()); |
71 return true; | 76 return true; |
72 } | 77 } |
73 | 78 |
74 AssembleMediaFileFunction::~AssembleMediaFileFunction() {} | 79 AssembleMediaFileFunction::~AssembleMediaFileFunction() {} |
75 | 80 |
76 bool AssembleMediaFileFunction::RunImpl() { | 81 bool AssembleMediaFileFunction::RunImpl() { |
77 // TODO(vandebo) Update the metadata and return the new file. | 82 // TODO(vandebo) Update the metadata and return the new file. |
78 SetResult(Value::CreateNullValue()); | 83 SetResult(Value::CreateNullValue()); |
79 return true; | 84 return true; |
80 } | 85 } |
81 | 86 |
82 } // namespace extensions | 87 } // namespace extensions |
OLD | NEW |