Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / chrome / renderer / extensions / file_browser_handler_custom_bindings.cc
blob73937a552e2b49d5909f6f90cc9a1afe8f5bc78c
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_browser_handler_custom_bindings.h"
7 #include <string>
9 #include "base/basictypes.h"
10 #include "base/logging.h"
11 #include "chrome/renderer/extensions/chrome_v8_context.h"
12 #include "grit/renderer_resources.h"
13 #include "third_party/WebKit/public/platform/WebFileSystem.h"
14 #include "third_party/WebKit/public/platform/WebFileSystemType.h"
15 #include "third_party/WebKit/public/platform/WebString.h"
16 #include "third_party/WebKit/public/web/WebFrame.h"
18 namespace extensions {
20 FileBrowserHandlerCustomBindings::FileBrowserHandlerCustomBindings(
21 Dispatcher* dispatcher, ChromeV8Context* context)
22 : ChromeV8Extension(dispatcher, context) {
23 RouteFunction(
24 "GetExternalFileEntry",
25 base::Bind(&FileBrowserHandlerCustomBindings::GetExternalFileEntry,
26 base::Unretained(this)));
29 void FileBrowserHandlerCustomBindings::GetExternalFileEntry(
30 const v8::FunctionCallbackInfo<v8::Value>& args) {
31 // TODO(zelidrag): Make this magic work on other platforms when file browser
32 // matures enough on ChromeOS.
33 #if defined(OS_CHROMEOS)
34 CHECK(args.Length() == 1);
35 CHECK(args[0]->IsObject());
36 v8::Local<v8::Object> file_def = args[0]->ToObject();
37 std::string file_system_name(
38 *v8::String::Utf8Value(file_def->Get(
39 v8::String::NewFromUtf8(args.GetIsolate(), "fileSystemName"))));
40 std::string file_system_path(
41 *v8::String::Utf8Value(file_def->Get(
42 v8::String::NewFromUtf8(args.GetIsolate(), "fileSystemRoot"))));
43 std::string file_full_path(
44 *v8::String::Utf8Value(file_def->Get(
45 v8::String::NewFromUtf8(args.GetIsolate(), "fileFullPath"))));
46 bool is_directory = file_def->Get(v8::String::NewFromUtf8(
47 args.GetIsolate(), "fileIsDirectory"))->ToBoolean()->Value();
48 blink::WebFrame* webframe =
49 blink::WebFrame::frameForContext(context()->v8_context());
50 args.GetReturnValue().Set(webframe->createFileEntry(
51 blink::WebFileSystemTypeExternal,
52 blink::WebString::fromUTF8(file_system_name.c_str()),
53 blink::WebString::fromUTF8(file_system_path.c_str()),
54 blink::WebString::fromUTF8(file_full_path.c_str()),
55 is_directory));
56 #endif
59 } // namespace extensions