blob: 7fd556787b3fca09e865e9fb6f85198c3024b9d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// 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/file_browser_handler_custom_bindings.h"
#include <string>
#include "base/basictypes.h"
#include "base/logging.h"
#include "grit/renderer_resources.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystem.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystemType.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
namespace extensions {
FileBrowserHandlerCustomBindings::FileBrowserHandlerCustomBindings(
Dispatcher* dispatcher, v8::Handle<v8::Context> context)
: ChromeV8Extension(dispatcher, context) {
RouteFunction(
"GetExternalFileEntry",
base::Bind(&FileBrowserHandlerCustomBindings::GetExternalFileEntry,
base::Unretained(this)));
}
v8::Handle<v8::Value> FileBrowserHandlerCustomBindings::GetExternalFileEntry(
const v8::Arguments& args) {
// TODO(zelidrag): Make this magic work on other platforms when file browser
// matures enough on ChromeOS.
#if defined(OS_CHROMEOS)
CHECK(args.Length() == 1);
CHECK(args[0]->IsObject());
v8::Local<v8::Object> file_def = args[0]->ToObject();
std::string file_system_name(
*v8::String::Utf8Value(file_def->Get(
v8::String::New("fileSystemName"))));
std::string file_system_path(
*v8::String::Utf8Value(file_def->Get(
v8::String::New("fileSystemRoot"))));
std::string file_full_path(
*v8::String::Utf8Value(file_def->Get(
v8::String::New("fileFullPath"))));
bool is_directory =
file_def->Get(v8::String::New("fileIsDirectory"))->ToBoolean()->Value();
WebKit::WebFrame* webframe =
WebKit::WebFrame::frameForContext(v8_context());
return webframe->createFileEntry(
WebKit::WebFileSystemTypeExternal,
WebKit::WebString::fromUTF8(file_system_name.c_str()),
WebKit::WebString::fromUTF8(file_system_path.c_str()),
WebKit::WebString::fromUTF8(file_full_path.c_str()),
is_directory);
#else
return v8::Undefined();
#endif
}
} // namespace extensions
|