OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/extensions/file_system_natives.h" | 5 #include "chrome/renderer/extensions/file_system_natives.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 FileSystemNatives::FileSystemNatives(v8::Handle<v8::Context> context) | 24 FileSystemNatives::FileSystemNatives(v8::Handle<v8::Context> context) |
25 : ObjectBackedNativeHandler(context) { | 25 : ObjectBackedNativeHandler(context) { |
26 RouteFunction("GetFileEntry", | 26 RouteFunction("GetFileEntry", |
27 base::Bind(&FileSystemNatives::GetFileEntry, base::Unretained(this))); | 27 base::Bind(&FileSystemNatives::GetFileEntry, base::Unretained(this))); |
28 RouteFunction("GetIsolatedFileSystem", | 28 RouteFunction("GetIsolatedFileSystem", |
29 base::Bind(&FileSystemNatives::GetIsolatedFileSystem, | 29 base::Bind(&FileSystemNatives::GetIsolatedFileSystem, |
30 base::Unretained(this))); | 30 base::Unretained(this))); |
31 RouteFunction("CrackIsolatedFileSystemName", | |
32 base::Bind(&FileSystemNatives::CrackIsolatedFileSystemName, | |
33 base::Unretained(this))); | |
31 } | 34 } |
32 | 35 |
33 v8::Handle<v8::Value> FileSystemNatives::GetIsolatedFileSystem( | 36 v8::Handle<v8::Value> FileSystemNatives::GetIsolatedFileSystem( |
34 const v8::Arguments& args) { | 37 const v8::Arguments& args) { |
35 DCHECK(args.Length() == 1 || args.Length() == 2); | 38 DCHECK(args.Length() == 1 || args.Length() == 2); |
36 DCHECK(args[0]->IsString()); | 39 DCHECK(args[0]->IsString()); |
37 std::string file_system_id(*v8::String::Utf8Value(args[0])); | 40 std::string file_system_id(*v8::String::Utf8Value(args[0])); |
38 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForContext(v8_context()); | 41 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForContext(v8_context()); |
39 DCHECK(webframe); | 42 DCHECK(webframe); |
40 | 43 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForContext(v8_context()); | 94 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForContext(v8_context()); |
92 DCHECK(webframe); | 95 DCHECK(webframe); |
93 return webframe->createFileEntry( | 96 return webframe->createFileEntry( |
94 type, | 97 type, |
95 WebKit::WebString::fromUTF8(file_system_name), | 98 WebKit::WebString::fromUTF8(file_system_name), |
96 WebKit::WebString::fromUTF8(file_system_root_url), | 99 WebKit::WebString::fromUTF8(file_system_root_url), |
97 WebKit::WebString::fromUTF8(file_path_string), | 100 WebKit::WebString::fromUTF8(file_path_string), |
98 is_directory); | 101 is_directory); |
99 } | 102 } |
100 | 103 |
104 v8::Handle<v8::Value> FileSystemNatives::CrackIsolatedFileSystemName( | |
105 const v8::Arguments& args) { | |
106 DCHECK_EQ(args.Length(), 1); | |
107 DCHECK(args[0]->IsString()); | |
108 std::string filesystem_name = *v8::String::Utf8Value(args[0]->ToString()); | |
109 std::string filesystem_id; | |
110 if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) { | |
Matt Giuca
2013/05/20 01:32:57
Nit: Remove braces.
Sam McNally
2013/05/20 04:25:20
Done.
| |
111 return v8::Undefined(); | |
112 } | |
113 return v8::String::New(filesystem_id.c_str(), filesystem_id.size()); | |
114 } | |
115 | |
101 } // namespace extensions | 116 } // namespace extensions |
OLD | NEW |