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