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 <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 ~MediaGalleriesGetMediaFileSystemsFunction() {} | 70 ~MediaGalleriesGetMediaFileSystemsFunction() {} |
71 | 71 |
72 bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() { | 72 bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() { |
73 if (!ApiIsAccessible(&error_)) | 73 if (!ApiIsAccessible(&error_)) |
74 return false; | 74 return false; |
75 | 75 |
76 scoped_ptr<GetMediaFileSystems::Params> params( | 76 scoped_ptr<GetMediaFileSystems::Params> params( |
77 GetMediaFileSystems::Params::Create(*args_)); | 77 GetMediaFileSystems::Params::Create(*args_)); |
78 EXTENSION_FUNCTION_VALIDATE(params.get()); | 78 EXTENSION_FUNCTION_VALIDATE(params.get()); |
79 MediaGalleries::GetMediaFileSystemsInteractivity interactive = | 79 MediaGalleries::GetMediaFileSystemsInteractivity interactive = |
80 MediaGalleries::MEDIA_GALLERIES_GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NO; | 80 MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NO; |
81 if (params->details.get() && params->details->interactive != MediaGalleries:: | 81 if (params->details.get() && params->details->interactive != MediaGalleries:: |
82 MEDIA_GALLERIES_GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NONE) { | 82 GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NONE) { |
83 interactive = params->details->interactive; | 83 interactive = params->details->interactive; |
84 } | 84 } |
85 | 85 |
86 switch (interactive) { | 86 switch (interactive) { |
87 case MediaGalleries:: | 87 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_YES: |
88 MEDIA_GALLERIES_GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_YES: | |
89 ShowDialog(); | 88 ShowDialog(); |
90 return true; | 89 return true; |
91 case MediaGalleries:: | 90 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_IF_NEEDED: { |
92 MEDIA_GALLERIES_GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_IF_NEEDED: { | |
93 MediaFileSystemRegistry* registry = | 91 MediaFileSystemRegistry* registry = |
94 g_browser_process->media_file_system_registry(); | 92 g_browser_process->media_file_system_registry(); |
95 registry->GetMediaFileSystemsForExtension( | 93 registry->GetMediaFileSystemsForExtension( |
96 render_view_host(), GetExtension(), base::Bind( | 94 render_view_host(), GetExtension(), base::Bind( |
97 &MediaGalleriesGetMediaFileSystemsFunction:: | 95 &MediaGalleriesGetMediaFileSystemsFunction:: |
98 ShowDialogIfNoGalleries, | 96 ShowDialogIfNoGalleries, |
99 this)); | 97 this)); |
100 return true; | 98 return true; |
101 } | 99 } |
102 case MediaGalleries:: | 100 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NO: |
103 MEDIA_GALLERIES_GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NO: | |
104 GetAndReturnGalleries(); | 101 GetAndReturnGalleries(); |
105 return true; | 102 return true; |
106 case MediaGalleries:: | 103 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NONE: |
107 MEDIA_GALLERIES_GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NONE: | |
108 NOTREACHED(); | 104 NOTREACHED(); |
109 } | 105 } |
110 error_ = kInvalidInteractive; | 106 error_ = kInvalidInteractive; |
111 return false; | 107 return false; |
112 } | 108 } |
113 | 109 |
114 void MediaGalleriesGetMediaFileSystemsFunction::ShowDialogIfNoGalleries( | 110 void MediaGalleriesGetMediaFileSystemsFunction::ShowDialogIfNoGalleries( |
115 const std::vector<MediaFileSystemInfo>& filesystems) { | 111 const std::vector<MediaFileSystemInfo>& filesystems) { |
116 if (filesystems.empty()) | 112 if (filesystems.empty()) |
117 ShowDialog(); | 113 ShowDialog(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { | 215 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { |
220 if (!ApiIsAccessible(&error_)) | 216 if (!ApiIsAccessible(&error_)) |
221 return false; | 217 return false; |
222 | 218 |
223 // TODO(vandebo) Update the metadata and return the new file. | 219 // TODO(vandebo) Update the metadata and return the new file. |
224 SetResult(base::Value::CreateNullValue()); | 220 SetResult(base::Value::CreateNullValue()); |
225 return true; | 221 return true; |
226 } | 222 } |
227 | 223 |
228 } // namespace extensions | 224 } // namespace extensions |
OLD | NEW |