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.
5 #include "chrome/renderer/extensions/file_manager_private_custom_bindings.h"
9 #include "base/basictypes.h"
10 #include "base/logging.h"
11 #include "extensions/renderer/script_context.h"
12 #include "third_party/WebKit/public/platform/WebString.h"
13 #include "third_party/WebKit/public/web/WebDOMFileSystem.h"
14 #include "third_party/WebKit/public/web/WebLocalFrame.h"
16 namespace extensions
{
18 FileManagerPrivateCustomBindings::FileManagerPrivateCustomBindings(
19 ScriptContext
* context
)
20 : ObjectBackedNativeHandler(context
) {
23 base::Bind(&FileManagerPrivateCustomBindings::GetFileSystem
,
24 base::Unretained(this)));
27 void FileManagerPrivateCustomBindings::GetFileSystem(
28 const v8::FunctionCallbackInfo
<v8::Value
>& args
) {
29 DCHECK(args
.Length() == 2);
30 DCHECK(args
[0]->IsString());
31 DCHECK(args
[1]->IsString());
32 std::string
name(*v8::String::Utf8Value(args
[0]));
33 std::string
root_url(*v8::String::Utf8Value(args
[1]));
35 blink::WebLocalFrame
* webframe
=
36 blink::WebLocalFrame::frameForContext(context()->v8_context());
38 args
.GetReturnValue().Set(
39 blink::WebDOMFileSystem::create(webframe
,
40 blink::WebFileSystemTypeExternal
,
41 blink::WebString::fromUTF8(name
),
43 .toV8Value(args
.Holder(), args
.GetIsolate()));
46 } // namespace extensions