Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: chrome/renderer/extensions/file_system_natives.cc

Issue 14607023: Add support for persistent file access in apps. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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))
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
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/file_system_natives.h ('k') | chrome/renderer/resources/extensions/app_runtime_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698