OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/file_system_natives.h" | 5 #include "extensions/renderer/file_system_natives.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "extensions/common/constants.h" | 9 #include "extensions/common/constants.h" |
10 #include "extensions/renderer/script_context.h" | 10 #include "extensions/renderer/script_context.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 GURL root_url(storage::GetIsolatedFileSystemRootURIString( | 60 GURL root_url(storage::GetIsolatedFileSystemRootURIString( |
61 context_url.GetOrigin(), file_system_id, optional_root_name)); | 61 context_url.GetOrigin(), file_system_id, optional_root_name)); |
62 | 62 |
63 args.GetReturnValue().Set( | 63 args.GetReturnValue().Set( |
64 blink::WebDOMFileSystem::create(webframe, | 64 blink::WebDOMFileSystem::create(webframe, |
65 blink::WebFileSystemTypeIsolated, | 65 blink::WebFileSystemTypeIsolated, |
66 blink::WebString::fromUTF8(name), | 66 blink::WebString::fromUTF8(name), |
67 root_url) | 67 root_url) |
68 .toV8Value(args.Holder(), args.GetIsolate())); | 68 .toV8Value(context()->v8_context()->Global(), args.GetIsolate())); |
69 } | 69 } |
70 | 70 |
71 void FileSystemNatives::GetFileEntry( | 71 void FileSystemNatives::GetFileEntry( |
72 const v8::FunctionCallbackInfo<v8::Value>& args) { | 72 const v8::FunctionCallbackInfo<v8::Value>& args) { |
73 DCHECK(args.Length() == 5); | 73 DCHECK(args.Length() == 5); |
74 DCHECK(args[0]->IsString()); | 74 DCHECK(args[0]->IsString()); |
75 std::string type_string = *v8::String::Utf8Value(args[0]); | 75 std::string type_string = *v8::String::Utf8Value(args[0]); |
76 blink::WebFileSystemType type; | 76 blink::WebFileSystemType type; |
77 bool is_valid_type = storage::GetFileSystemPublicType(type_string, &type); | 77 bool is_valid_type = storage::GetFileSystemPublicType(type_string, &type); |
78 DCHECK(is_valid_type); | 78 DCHECK(is_valid_type); |
(...skipping 19 matching lines...) Expand all Loading... |
98 blink::WebLocalFrame::frameForContext(context()->v8_context()); | 98 blink::WebLocalFrame::frameForContext(context()->v8_context()); |
99 DCHECK(webframe); | 99 DCHECK(webframe); |
100 args.GetReturnValue().Set( | 100 args.GetReturnValue().Set( |
101 blink::WebDOMFileSystem::create( | 101 blink::WebDOMFileSystem::create( |
102 webframe, | 102 webframe, |
103 type, | 103 type, |
104 blink::WebString::fromUTF8(file_system_name), | 104 blink::WebString::fromUTF8(file_system_name), |
105 file_system_root_url) | 105 file_system_root_url) |
106 .createV8Entry(blink::WebString::fromUTF8(file_path_string), | 106 .createV8Entry(blink::WebString::fromUTF8(file_path_string), |
107 entry_type, | 107 entry_type, |
108 args.Holder(), | 108 context()->v8_context()->Global(), |
109 args.GetIsolate())); | 109 args.GetIsolate())); |
110 } | 110 } |
111 | 111 |
112 void FileSystemNatives::CrackIsolatedFileSystemName( | 112 void FileSystemNatives::CrackIsolatedFileSystemName( |
113 const v8::FunctionCallbackInfo<v8::Value>& args) { | 113 const v8::FunctionCallbackInfo<v8::Value>& args) { |
114 DCHECK_EQ(args.Length(), 1); | 114 DCHECK_EQ(args.Length(), 1); |
115 DCHECK(args[0]->IsString()); | 115 DCHECK(args[0]->IsString()); |
116 std::string filesystem_name = *v8::String::Utf8Value(args[0]); | 116 std::string filesystem_name = *v8::String::Utf8Value(args[0]); |
117 std::string filesystem_id; | 117 std::string filesystem_id; |
118 if (!storage::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) | 118 if (!storage::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) |
(...skipping 24 matching lines...) Expand all Loading... |
143 if (name.empty()) { | 143 if (name.empty()) { |
144 NOTREACHED(); | 144 NOTREACHED(); |
145 return; | 145 return; |
146 } | 146 } |
147 std::string message(*v8::String::Utf8Value(args[1])); | 147 std::string message(*v8::String::Utf8Value(args[1])); |
148 // message is optional hence empty is fine. | 148 // message is optional hence empty is fine. |
149 | 149 |
150 blink::WebDOMError dom_error = blink::WebDOMError::create( | 150 blink::WebDOMError dom_error = blink::WebDOMError::create( |
151 blink::WebString::fromUTF8(name), blink::WebString::fromUTF8(message)); | 151 blink::WebString::fromUTF8(name), blink::WebString::fromUTF8(message)); |
152 args.GetReturnValue().Set( | 152 args.GetReturnValue().Set( |
153 dom_error.toV8Value(args.Holder(), args.GetIsolate())); | 153 dom_error.toV8Value(context()->v8_context()->Global(), |
| 154 args.GetIsolate())); |
154 } | 155 } |
155 | 156 |
156 } // namespace extensions | 157 } // namespace extensions |
OLD | NEW |