Index: chrome/renderer/extensions/file_system_provider_natives.cc |
diff --git a/chrome/renderer/extensions/file_system_provider_natives.cc b/chrome/renderer/extensions/file_system_provider_natives.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..74c613f16f424176da9c23f65a570508bfb729f4 |
--- /dev/null |
+++ b/chrome/renderer/extensions/file_system_provider_natives.cc |
@@ -0,0 +1,53 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/renderer/extensions/file_system_provider_natives.h" |
+ |
+#include <string> |
+ |
+#include "third_party/WebKit/public/platform/WebString.h" |
+#include "third_party/WebKit/public/web/WebDOMError.h" |
+#include "v8/include/v8.h" |
+ |
+namespace extensions { |
+ |
+fileSystemProviderNatives::fileSystemProviderNatives( |
+ ChromeV8Context* context) |
+ : ObjectBackedNativeHandler(context) { |
+ RouteFunction( |
+ "GetDOMError", |
+ base::Bind(&fileSystemProviderNatives::GetDOMError, |
+ base::Unretained(this))); |
+} |
+ |
+void fileSystemProviderNatives::GetDOMError( |
benwells
2013/11/08 03:34:31
This seems like it would be useful to other APIs.
satorux1
2013/11/08 03:57:05
Good idea. Moved to file_system_natives.cc.
|
+ const v8::FunctionCallbackInfo<v8::Value>& args) { |
+ if (args.Length() != 2) { |
+ NOTREACHED(); |
+ return; |
+ } |
+ if (!args[0]->IsString()) { |
+ NOTREACHED(); |
+ return; |
+ } |
+ if (!args[1]->IsString()) { |
+ NOTREACHED(); |
+ return; |
+ } |
+ |
+ std::string name(*v8::String::Utf8Value(args[0])); |
+ if (name.empty()) { |
+ NOTREACHED(); |
+ return; |
+ } |
+ std::string message(*v8::String::Utf8Value(args[1])); |
+ // message is optional hence empty is fine. |
+ |
+ blink::WebDOMError dom_error = blink::WebDOMError::create( |
+ blink::WebString::fromUTF8(name), |
+ blink::WebString::fromUTF8(message)); |
+ args.GetReturnValue().Set(dom_error.toV8Value()); |
+} |
+ |
+} // namespace extensions |