Chromium Code Reviews| Index: chrome/renderer/extensions/experimental.app_custom_bindings.cc |
| diff --git a/chrome/renderer/extensions/experimental.app_custom_bindings.cc b/chrome/renderer/extensions/experimental.app_custom_bindings.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..08cd4341e0f231074febb8ad0994eba378baabda |
| --- /dev/null |
| +++ b/chrome/renderer/extensions/experimental.app_custom_bindings.cc |
| @@ -0,0 +1,54 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/renderer/extensions/experimental.app_custom_bindings.h" |
| + |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/logging.h" |
| +#include "chrome/renderer/extensions/user_script_slave.h" |
| +#include "grit/renderer_resources.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| + |
| +namespace { |
| + |
| +static v8::Handle<v8::Value> GetIsolatedFileSystem( |
| + const v8::Arguments& args) { |
| + DCHECK(args.Length() == 1); |
| + DCHECK(args[0]->IsString()); |
| + std::string file_system_id(*v8::String::Utf8Value(args[0])); |
| + WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); |
| + DCHECK(webframe); |
| + |
| + GURL context_url = UserScriptSlave::GetDataSourceURLForFrame(webframe); |
|
Mihai Parparita -not on Chrome
2012/05/18 04:26:04
Might be safe to add a CHECK that this is an exten
benwells
2012/05/22 13:15:03
Done.
|
| + std::string name = context_url.GetOrigin().spec(); |
| + name.append("isolated/"); |
|
Mihai Parparita -not on Chrome
2012/05/18 04:26:04
Seems like you can use GetFileSystemRootURI(contex
benwells
2012/05/18 04:56:55
That isn't implemented for isolated file systems,
kinuko
2012/05/18 10:22:17
It was correct, but I just added the minimal suppo
benwells
2012/05/22 13:15:03
Nice! Done.
|
| + name.append(file_system_id); |
| + |
| + std::string root; |
| + root.append("filesystem:"); |
| + root.append(context_url.GetOrigin().spec()); |
| + root.append("isolated/"); |
| + root.append(file_system_id); |
| + root.append("/"); |
| + |
| + return webframe->createFileSystem( |
| + WebKit::WebFileSystem::TypeIsolated, |
| + WebKit::WebString::fromUTF8(name.c_str()), |
| + WebKit::WebString::fromUTF8(root.c_str())); |
| +} |
| + |
| +} // namespace |
| + |
| +namespace extensions { |
| + |
| +ExperimentalAppCustomBindings::ExperimentalAppCustomBindings() |
| + : ChromeV8Extension(NULL) { |
| + RouteStaticFunction("GetIsolatedFileSystem", &GetIsolatedFileSystem); |
| +} |
| + |
| +} // namespace extensions |