| 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 #include "chrome/renderer/extensions/file_system_natives.h" | 5 #include "chrome/renderer/extensions/file_system_natives.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); | 28 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); |
| 29 DCHECK(webframe); | 29 DCHECK(webframe); |
| 30 | 30 |
| 31 GURL context_url = | 31 GURL context_url = |
| 32 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe); | 32 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe); |
| 33 CHECK(context_url.SchemeIs(extensions::kExtensionScheme)); | 33 CHECK(context_url.SchemeIs(extensions::kExtensionScheme)); |
| 34 | 34 |
| 35 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(), | 35 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(), |
| 36 file_system_id)); | 36 file_system_id)); |
| 37 | 37 |
| 38 std::string root(fileapi::GetFileSystemRootURI( | |
| 39 context_url.GetOrigin(), | |
| 40 fileapi::kFileSystemTypeIsolated).spec()); | |
| 41 root.append(file_system_id); | |
| 42 root.append("/"); | |
| 43 | |
| 44 // The optional second argument is the subfolder within the isolated file | 38 // The optional second argument is the subfolder within the isolated file |
| 45 // system at which to root the DOMFileSystem we're returning to the caller. | 39 // system at which to root the DOMFileSystem we're returning to the caller. |
| 40 std::string optional_root_name; |
| 46 if (args.Length() == 2) { | 41 if (args.Length() == 2) { |
| 47 DCHECK(args[1]->IsString()); | 42 DCHECK(args[1]->IsString()); |
| 48 name = *v8::String::Utf8Value(args[1]); | 43 optional_root_name = *v8::String::Utf8Value(args[1]); |
| 49 root.append(name); | |
| 50 root.append("/"); | |
| 51 } | 44 } |
| 52 | 45 |
| 46 std::string root(fileapi::GetIsolatedFileSystemRootURIString( |
| 47 context_url.GetOrigin(), |
| 48 file_system_id, |
| 49 optional_root_name)); |
| 50 |
| 53 return webframe->createFileSystem( | 51 return webframe->createFileSystem( |
| 54 WebKit::WebFileSystem::TypeIsolated, | 52 WebKit::WebFileSystem::TypeIsolated, |
| 55 WebKit::WebString::fromUTF8(name), | 53 WebKit::WebString::fromUTF8(name), |
| 56 WebKit::WebString::fromUTF8(root)); | 54 WebKit::WebString::fromUTF8(root)); |
| 57 } | 55 } |
| 58 | 56 |
| 59 } // namespace | 57 } // namespace |
| 60 | 58 |
| 61 namespace extensions { | 59 namespace extensions { |
| 62 | 60 |
| 63 FileSystemNatives::FileSystemNatives() | 61 FileSystemNatives::FileSystemNatives() |
| 64 : ChromeV8Extension(NULL) { | 62 : ChromeV8Extension(NULL) { |
| 65 RouteStaticFunction("GetIsolatedFileSystem", &GetIsolatedFileSystem); | 63 RouteStaticFunction("GetIsolatedFileSystem", &GetIsolatedFileSystem); |
| 66 } | 64 } |
| 67 | 65 |
| 68 } // namespace extensions | 66 } // namespace extensions |
| OLD | NEW |