| Index: Source/bindings/v8/custom/V8FileCustom.cpp
|
| diff --git a/Source/bindings/v8/custom/V8BlobCustom.cpp b/Source/bindings/v8/custom/V8FileCustom.cpp
|
| similarity index 81%
|
| copy from Source/bindings/v8/custom/V8BlobCustom.cpp
|
| copy to Source/bindings/v8/custom/V8FileCustom.cpp
|
| index d514a4eff6a71eb5d36f0cdd090baecd2215bb7e..52a0ff6bfbe86a475d1868dafb37933deb07bd14 100644
|
| --- a/Source/bindings/v8/custom/V8BlobCustom.cpp
|
| +++ b/Source/bindings/v8/custom/V8FileCustom.cpp
|
| @@ -1,5 +1,5 @@
|
| /*
|
| - * Copyright (C) 2012 Google Inc. All rights reserved.
|
| + * Copyright (C) 2013 Google Inc. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions are
|
| @@ -29,8 +29,9 @@
|
| */
|
|
|
| #include "config.h"
|
| -#include "V8Blob.h"
|
| +#include "V8File.h"
|
|
|
| +#include "RuntimeEnabledFeatures.h"
|
| #include "bindings/v8/Dictionary.h"
|
| #include "bindings/v8/V8Binding.h"
|
| #include "bindings/v8/V8Utilities.h"
|
| @@ -41,30 +42,38 @@
|
|
|
| namespace WebCore {
|
|
|
| -void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8File::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| - if (!info.Length()) {
|
| - RefPtr<Blob> blob = Blob::create();
|
| - info.GetReturnValue().Set(toV8(blob.get(), info.Holder(), info.GetIsolate()));
|
| + if (!RuntimeEnabledFeatures::fileConstructorEnabled()) {
|
| + throwTypeError("Illegal constructor", info.GetIsolate());
|
| + return;
|
| + }
|
| +
|
| + if (info.Length() < 2) {
|
| + throwTypeError("Constructor requires at least two arguments", info.GetIsolate());
|
| return;
|
| }
|
|
|
| v8::Local<v8::Value> firstArg = info[0];
|
| + // FIXME: handle WebIDL sequences, see http://crbug.com/314755
|
| if (!firstArg->IsArray()) {
|
| throwTypeError("First argument of the constructor is not of type Array", info.GetIsolate());
|
| return;
|
| }
|
|
|
| + v8::Local<v8::Value> secondArg = info[1];
|
| + V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, fileName, secondArg);
|
| +
|
| String type;
|
| String endings = "transparent";
|
|
|
| - if (info.Length() > 1) {
|
| - if (!info[1]->IsObject()) {
|
| - throwTypeError("Second argument of the constructor is not of type Object", info.GetIsolate());
|
| + if (info.Length() > 2) {
|
| + if (!info[2]->IsObject()) {
|
| + throwTypeError("Third argument of the constructor is not of type Object", info.GetIsolate());
|
| return;
|
| }
|
|
|
| - V8TRYCATCH_VOID(Dictionary, dictionary, Dictionary(info[1], info.GetIsolate()));
|
| + V8TRYCATCH_VOID(Dictionary, dictionary, Dictionary(info[2], info.GetIsolate()));
|
|
|
| V8TRYCATCH_VOID(bool, containsEndings, dictionary.get("endings", endings));
|
| if (containsEndings) {
|
| @@ -111,8 +120,8 @@ void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| }
|
| }
|
|
|
| - RefPtr<Blob> blob = blobBuilder.getBlob(type);
|
| - info.GetReturnValue().Set(toV8(blob.get(), info.Holder(), info.GetIsolate()));
|
| + RefPtr<File> file = blobBuilder.createFile(type, fileName, currentTime());
|
| + info.GetReturnValue().Set(toV8(file.get(), info.Holder(), info.GetIsolate()));
|
| }
|
|
|
| } // namespace WebCore
|
|
|