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 24 matching lines...) Expand all Loading... |
35 RouteFunction("GetDOMError", | 35 RouteFunction("GetDOMError", |
36 base::Bind(&FileSystemNatives::GetDOMError, | 36 base::Bind(&FileSystemNatives::GetDOMError, |
37 base::Unretained(this))); | 37 base::Unretained(this))); |
38 } | 38 } |
39 | 39 |
40 void FileSystemNatives::GetIsolatedFileSystem( | 40 void FileSystemNatives::GetIsolatedFileSystem( |
41 const v8::FunctionCallbackInfo<v8::Value>& args) { | 41 const v8::FunctionCallbackInfo<v8::Value>& args) { |
42 DCHECK(args.Length() == 1 || args.Length() == 2); | 42 DCHECK(args.Length() == 1 || args.Length() == 2); |
43 DCHECK(args[0]->IsString()); | 43 DCHECK(args[0]->IsString()); |
44 std::string file_system_id(*v8::String::Utf8Value(args[0])); | 44 std::string file_system_id(*v8::String::Utf8Value(args[0])); |
45 blink::WebFrame* webframe = | 45 blink::WebLocalFrame* webframe = |
46 blink::WebFrame::frameForContext(context()->v8_context()); | 46 blink::WebLocalFrame::frameForContext(context()->v8_context()); |
47 DCHECK(webframe); | 47 DCHECK(webframe); |
48 | 48 |
49 GURL context_url = | 49 GURL context_url = |
50 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe); | 50 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe); |
51 CHECK(context_url.SchemeIs(extensions::kExtensionScheme)); | 51 CHECK(context_url.SchemeIs(extensions::kExtensionScheme)); |
52 | 52 |
53 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(), | 53 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(), |
54 file_system_id)); | 54 file_system_id)); |
55 | 55 |
56 // The optional second argument is the subfolder within the isolated file | 56 // The optional second argument is the subfolder within the isolated file |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 GURL file_system_root_url(*v8::String::Utf8Value(args[2]->ToString())); | 93 GURL file_system_root_url(*v8::String::Utf8Value(args[2]->ToString())); |
94 std::string file_path_string(*v8::String::Utf8Value(args[3]->ToString())); | 94 std::string file_path_string(*v8::String::Utf8Value(args[3]->ToString())); |
95 base::FilePath file_path = base::FilePath::FromUTF8Unsafe(file_path_string); | 95 base::FilePath file_path = base::FilePath::FromUTF8Unsafe(file_path_string); |
96 DCHECK(fileapi::VirtualPath::IsAbsolute(file_path.value())); | 96 DCHECK(fileapi::VirtualPath::IsAbsolute(file_path.value())); |
97 | 97 |
98 DCHECK(args[4]->IsBoolean()); | 98 DCHECK(args[4]->IsBoolean()); |
99 blink::WebDOMFileSystem::EntryType entry_type = args[4]->BooleanValue() | 99 blink::WebDOMFileSystem::EntryType entry_type = args[4]->BooleanValue() |
100 ? blink::WebDOMFileSystem::EntryTypeDirectory | 100 ? blink::WebDOMFileSystem::EntryTypeDirectory |
101 : blink::WebDOMFileSystem::EntryTypeFile; | 101 : blink::WebDOMFileSystem::EntryTypeFile; |
102 | 102 |
103 blink::WebFrame* webframe = | 103 blink::WebLocalFrame* webframe = |
104 blink::WebFrame::frameForContext(context()->v8_context()); | 104 blink::WebLocalFrame::frameForContext(context()->v8_context()); |
105 DCHECK(webframe); | 105 DCHECK(webframe); |
106 args.GetReturnValue().Set( | 106 args.GetReturnValue().Set( |
107 blink::WebDOMFileSystem::create( | 107 blink::WebDOMFileSystem::create( |
108 webframe, type, | 108 webframe, type, |
109 blink::WebString::fromUTF8(file_system_name), | 109 blink::WebString::fromUTF8(file_system_name), |
110 file_system_root_url).createV8Entry( | 110 file_system_root_url).createV8Entry( |
111 blink::WebString::fromUTF8(file_path_string), | 111 blink::WebString::fromUTF8(file_path_string), |
112 entry_type)); | 112 entry_type)); |
113 } | 113 } |
114 | 114 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 std::string message(*v8::String::Utf8Value(args[1])); | 150 std::string message(*v8::String::Utf8Value(args[1])); |
151 // message is optional hence empty is fine. | 151 // message is optional hence empty is fine. |
152 | 152 |
153 blink::WebDOMError dom_error = blink::WebDOMError::create( | 153 blink::WebDOMError dom_error = blink::WebDOMError::create( |
154 blink::WebString::fromUTF8(name), | 154 blink::WebString::fromUTF8(name), |
155 blink::WebString::fromUTF8(message)); | 155 blink::WebString::fromUTF8(message)); |
156 args.GetReturnValue().Set(dom_error.toV8Value()); | 156 args.GetReturnValue().Set(dom_error.toV8Value()); |
157 } | 157 } |
158 | 158 |
159 } // namespace extensions | 159 } // namespace extensions |
OLD | NEW |