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

Side by Side Diff: chrome/browser/extensions/api/media_galleries/media_galleries_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
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_galleries/media_galleries_api.h"
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/platform_file.h" 12 #include "base/platform_file.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/media_gallery/media_file_system_registry.h" 14 #include "chrome/browser/media_gallery/media_file_system_registry.h"
15 #include "chrome/common/extensions/api/experimental_media_galleries.h"
15 #include "content/public/browser/child_process_security_policy.h" 16 #include "content/public/browser/child_process_security_policy.h"
16 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
17 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
18 19
19 #if defined(OS_WIN) 20 #if defined(OS_WIN)
20 #include "base/sys_string_conversions.h" 21 #include "base/sys_string_conversions.h"
21 #endif 22 #endif
22 23
23 namespace extensions { 24 namespace extensions {
24 25
26 namespace {
27
28 const char kInvalidInteractive[] = "Unknown value for interactive.";
29
30 } // namespace
31
25 using chrome::MediaFileSystemRegistry; 32 using chrome::MediaFileSystemRegistry;
26 using content::ChildProcessSecurityPolicy; 33 using content::ChildProcessSecurityPolicy;
27 34
28 GetMediaFileSystemsFunction::~GetMediaFileSystemsFunction() {} 35 namespace MediaGalleries = extensions::api::experimental_media_galleries;
36 namespace GetMediaFileSystems = MediaGalleries::GetMediaFileSystems;
29 37
30 bool GetMediaFileSystemsFunction::RunImpl() { 38 MediaGalleriesGetMediaFileSystemsFunction::
39 ~MediaGalleriesGetMediaFileSystemsFunction() {}
40
41 bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() {
42 scoped_ptr<GetMediaFileSystems::Params> params(
43 GetMediaFileSystems::Params::Create(*args_));
44 EXTENSION_FUNCTION_VALIDATE(params.get());
45 MediaGalleries::GetMediaFileSystemsInteractivity interactive = "no";
46 if (params->details.get() && params->details->interactive.get())
47 interactive = *params->details->interactive;
48
49 if (interactive == "yes") {
50 // TODO(estade): implement.
51 } else if (interactive == "if_needed") {
52 // TODO(estade): implement.
53 } else if (interactive != "no") {
54 error_ = kInvalidInteractive;
55 SetResult(false);
56 return true;
57 }
58
31 const content::RenderProcessHost* rph = render_view_host()->GetProcess(); 59 const content::RenderProcessHost* rph = render_view_host()->GetProcess();
32 chrome::MediaFileSystemRegistry* media_fs_registry = 60 chrome::MediaFileSystemRegistry* media_fs_registry =
33 MediaFileSystemRegistry::GetInstance(); 61 MediaFileSystemRegistry::GetInstance();
34 const std::vector<MediaFileSystemRegistry::MediaFSIDAndPath> filesystems = 62 const std::vector<MediaFileSystemRegistry::MediaFSIDAndPath> filesystems =
35 media_fs_registry->GetMediaFileSystems(rph); 63 media_fs_registry->GetMediaFileSystems(rph);
36 64
37 const int child_id = rph->GetID(); 65 const int child_id = rph->GetID();
38 base::ListValue* list = new base::ListValue(); 66 base::ListValue* list = new base::ListValue();
39 for (size_t i = 0; i < filesystems.size(); i++) { 67 for (size_t i = 0; i < filesystems.size(); i++) {
40 // TODO(thestig) Check permissions to file systems when that capability 68 // TODO(thestig) Check permissions to file systems when that capability
(...skipping 15 matching lines...) Expand all
56 ChildProcessSecurityPolicy::GetInstance(); 84 ChildProcessSecurityPolicy::GetInstance();
57 if (!policy->CanReadFile(child_id, path)) 85 if (!policy->CanReadFile(child_id, path))
58 policy->GrantReadFile(child_id, path); 86 policy->GrantReadFile(child_id, path);
59 policy->GrantReadFileSystem(child_id, fsid); 87 policy->GrantReadFileSystem(child_id, fsid);
60 } 88 }
61 89
62 SetResult(list); 90 SetResult(list);
63 return true; 91 return true;
64 } 92 }
65 93
66 OpenMediaGalleryManagerFunction::~OpenMediaGalleryManagerFunction() {} 94 MediaGalleriesAssembleMediaFileFunction::
95 ~MediaGalleriesAssembleMediaFileFunction() {}
67 96
68 bool OpenMediaGalleryManagerFunction::RunImpl() { 97 bool MediaGalleriesAssembleMediaFileFunction::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. 98 // TODO(vandebo) Update the metadata and return the new file.
78 SetResult(Value::CreateNullValue()); 99 SetResult(Value::CreateNullValue());
79 return true; 100 return true;
80 } 101 }
81 102
82 } // namespace extensions 103 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698