| 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" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 #include "chrome/renderer/extensions/user_script_slave.h" | 12 #include "chrome/renderer/extensions/user_script_slave.h" |
| 13 #include "grit/renderer_resources.h" | 13 #include "grit/renderer_resources.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste
m.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste
m.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 17 #include "webkit/fileapi/file_system_types.h" | 17 #include "webkit/fileapi/file_system_types.h" |
| 18 #include "webkit/fileapi/file_system_util.h" | 18 #include "webkit/fileapi/file_system_util.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 static v8::Handle<v8::Value> GetIsolatedFileSystem( | 22 static v8::Handle<v8::Value> GetIsolatedFileSystem( |
| 23 const v8::Arguments& args) { | 23 const v8::Arguments& args) { |
| 24 DCHECK(args.Length() == 1); | 24 DCHECK(args.Length() == 1); |
| 25 DCHECK(args[0]->IsString()); | 25 DCHECK(args[0]->IsString()); |
| 26 std::string file_system_id(*v8::String::Utf8Value(args[0])); | 26 std::string file_system_id(*v8::String::Utf8Value(args[0])); |
| 27 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); | 27 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); |
| 28 DCHECK(webframe); | 28 DCHECK(webframe); |
| 29 | 29 |
| 30 GURL context_url = UserScriptSlave::GetDataSourceURLForFrame(webframe); | 30 GURL context_url = |
| 31 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe); |
| 31 CHECK(context_url.SchemeIs(chrome::kExtensionScheme)); | 32 CHECK(context_url.SchemeIs(chrome::kExtensionScheme)); |
| 32 | 33 |
| 33 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(), | 34 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(), |
| 34 file_system_id)); | 35 file_system_id)); |
| 35 | 36 |
| 36 std::string root(fileapi::GetFileSystemRootURI(context_url.GetOrigin(), | 37 std::string root(fileapi::GetFileSystemRootURI(context_url.GetOrigin(), |
| 37 fileapi::kFileSystemTypeIsolated).spec()); | 38 fileapi::kFileSystemTypeIsolated).spec()); |
| 38 root.append(file_system_id); | 39 root.append(file_system_id); |
| 39 root.append("/"); | 40 root.append("/"); |
| 40 | 41 |
| 41 return webframe->createFileSystem( | 42 return webframe->createFileSystem( |
| 42 WebKit::WebFileSystem::TypeIsolated, | 43 WebKit::WebFileSystem::TypeIsolated, |
| 43 WebKit::WebString::fromUTF8(name.c_str()), | 44 WebKit::WebString::fromUTF8(name.c_str()), |
| 44 WebKit::WebString::fromUTF8(root.c_str())); | 45 WebKit::WebString::fromUTF8(root.c_str())); |
| 45 } | 46 } |
| 46 | 47 |
| 47 } // namespace | 48 } // namespace |
| 48 | 49 |
| 49 namespace extensions { | 50 namespace extensions { |
| 50 | 51 |
| 51 FileSystemNatives::FileSystemNatives() | 52 FileSystemNatives::FileSystemNatives() |
| 52 : ChromeV8Extension(NULL) { | 53 : ChromeV8Extension(NULL) { |
| 53 RouteStaticFunction("GetIsolatedFileSystem", &GetIsolatedFileSystem); | 54 RouteStaticFunction("GetIsolatedFileSystem", &GetIsolatedFileSystem); |
| 54 } | 55 } |
| 55 | 56 |
| 56 } // namespace extensions | 57 } // namespace extensions |
| OLD | NEW |