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_galleries/media_galleries_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> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 MediaGalleriesGetMediaFileSystemsFunction:: | 63 MediaGalleriesGetMediaFileSystemsFunction:: |
64 ~MediaGalleriesGetMediaFileSystemsFunction() {} | 64 ~MediaGalleriesGetMediaFileSystemsFunction() {} |
65 | 65 |
66 bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() { | 66 bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() { |
67 if (!ApiIsAccessible(&error_)) | 67 if (!ApiIsAccessible(&error_)) |
68 return false; | 68 return false; |
69 | 69 |
70 scoped_ptr<GetMediaFileSystems::Params> params( | 70 scoped_ptr<GetMediaFileSystems::Params> params( |
71 GetMediaFileSystems::Params::Create(*args_)); | 71 GetMediaFileSystems::Params::Create(*args_)); |
72 EXTENSION_FUNCTION_VALIDATE(params.get()); | 72 EXTENSION_FUNCTION_VALIDATE(params.get()); |
73 MediaGalleries::GetMediaFileSystemsInteractivity interactive = "no"; | 73 MediaGalleries::GetMediaFileSystemsInteractivity interactive = |
74 if (params->details.get() && params->details->interactive.get()) | 74 MediaGalleries::GETMEDIAFILESYSTEMSINTERACTIVITY_NO; |
not at google - send to devlin
2012/09/14 01:44:51
wow... what happened here? something funky with th
cduvall
2012/09/17 22:07:46
Done.
| |
75 interactive = *params->details->interactive; | 75 if (params->details.get() && params->details->interactive != |
76 MediaGalleries::GETMEDIAFILESYSTEMSINTERACTIVITY_NONE) { | |
77 interactive = params->details->interactive; | |
78 } | |
not at google - send to devlin
2012/09/14 01:44:51
also this can use switch now that it's an enum.
cduvall
2012/09/17 22:07:46
Done.
| |
76 | 79 |
77 if (interactive == "yes") { | 80 if (interactive == MediaGalleries::GETMEDIAFILESYSTEMSINTERACTIVITY_YES) { |
78 ShowDialog(); | 81 ShowDialog(); |
79 return true; | 82 return true; |
80 } else if (interactive == "if_needed") { | 83 } else if (interactive == |
84 MediaGalleries::GETMEDIAFILESYSTEMSINTERACTIVITY_IF_NEEDED) { | |
81 std::vector<MediaFileSystemRegistry::MediaFSInfo> filesystems = | 85 std::vector<MediaFileSystemRegistry::MediaFSInfo> filesystems = |
82 MediaFileSystemRegistry::GetInstance()->GetMediaFileSystemsForExtension( | 86 MediaFileSystemRegistry::GetInstance()->GetMediaFileSystemsForExtension( |
83 render_view_host(), GetExtension()); | 87 render_view_host(), GetExtension()); |
84 if (filesystems.empty()) | 88 if (filesystems.empty()) |
85 ShowDialog(); | 89 ShowDialog(); |
86 else | 90 else |
87 ReturnGalleries(filesystems); | 91 ReturnGalleries(filesystems); |
88 | 92 |
89 return true; | 93 return true; |
90 } else if (interactive == "no") { | 94 } else if (interactive == |
95 MediaGalleries::GETMEDIAFILESYSTEMSINTERACTIVITY_NO) { | |
91 GetAndReturnGalleries(); | 96 GetAndReturnGalleries(); |
92 return true; | 97 return true; |
93 } | 98 } |
94 | 99 |
95 error_ = kInvalidInteractive; | 100 error_ = kInvalidInteractive; |
96 return false; | 101 return false; |
97 } | 102 } |
98 | 103 |
99 void MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries() { | 104 void MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries() { |
100 std::vector<MediaFileSystemRegistry::MediaFSInfo> filesystems = | 105 std::vector<MediaFileSystemRegistry::MediaFSInfo> filesystems = |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { | 166 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { |
162 if (!ApiIsAccessible(&error_)) | 167 if (!ApiIsAccessible(&error_)) |
163 return false; | 168 return false; |
164 | 169 |
165 // TODO(vandebo) Update the metadata and return the new file. | 170 // TODO(vandebo) Update the metadata and return the new file. |
166 SetResult(Value::CreateNullValue()); | 171 SetResult(Value::CreateNullValue()); |
167 return true; | 172 return true; |
168 } | 173 } |
169 | 174 |
170 } // namespace extensions | 175 } // namespace extensions |
OLD | NEW |