2 Copyright (C) 2012 Samsung Electronics.
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
23 #if ENABLE(TIZEN_MEDIA_STREAM)
24 #include "MediaStream.h"
25 #include "MediaStreamRegistry.h"
26 #endif // ENABLE(TIZEN_MEDIA_STREAM)
28 #if ENABLE(TIZEN_FILE_SYSTEM)
29 #include "AsyncFileSystem.h"
31 #include "BlobRegistryImpl.h"
32 #include "DOMFileSystemBase.h"
33 #include "LocalFileSystem.h"
34 #endif // ENABLE(TIZEN_FILE_SYSTEM)
38 static void crackBlobURI(const String& url)
40 #if ENABLE(TIZEN_MEDIA_STREAM)
41 MediaStreamDescriptor* descriptor = MediaStreamRegistry::registry().lookupMediaStreamDescriptor(url);
43 for (unsigned int i = 0; i < descriptor->numberOfVideoComponents(); i++) {
44 MediaStreamSource* source = descriptor->videoComponent(i)->source();
46 int cameraId = (source->name() == "Self camera") ? 1 : 0;
47 String& mutableUrl = const_cast<String&>(url);
48 String cameraUrl = String::format("camera://%d", cameraId);
49 mutableUrl.swap(cameraUrl);
54 #endif // ENABLE(TIZEN_MEDIA_STREAM)
56 #if ENABLE(TIZEN_FILE_SYSTEM)
57 const KURL blobURL(ParsedURLString, url.utf8().data());
58 RefPtr<BlobStorageData> blobStorage = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(blobURL);
61 for (unsigned int i = 0; i < blobStorage->items().size(); i++) {
62 const BlobDataItem& blobItem = blobStorage->items()[i];
63 if (blobItem.type == BlobDataItem::File) {
64 String& mutableUrl = const_cast<String&>(url);
65 String fileUrl = "file://" + blobItem.path;
66 mutableUrl.swap(fileUrl);
70 #endif // ENABLE(TIZEN_FILE_SYSTEM)
73 static void crackFileSystemURI(const String& url)
75 #if ENABLE(TIZEN_FILE_SYSTEM)
76 const KURL filesystemURL(ParsedURLString, url.utf8().data());
79 DOMFileSystemBase::crackFileSystemURL(filesystemURL, type, filePath);
80 String fileUrl = "file://" + LocalFileSystem::localFileSystem().fileSystemBasePath() + filePath;
81 String& mutableUrl = const_cast<String&>(url);
82 mutableUrl.swap(fileUrl);
83 #endif // ENABLE(TIZEN_FILE_SYSTEM)
86 void crackURI(const String& url)
88 if (url.contains("blob:"))
90 else if (url.contains("filesystem:"))
91 crackFileSystemURI(url);
94 } // namespace WebCore