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

Unified Diff: chrome/renderer/extensions/file_system_provider_natives.cc

Issue 50703013: fileSystemProvider: First cut at implementing fileSystemProvider API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: switch to two-callback approach Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..5a48c793a3bce23c8e8e823c483318897c3d337a
--- /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(
+ 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.
+
+ WebKit::WebDOMError dom_error = WebKit::WebDOMError::create(
+ WebKit::WebString::fromUTF8(name),
+ WebKit::WebString::fromUTF8(message));
+ args.GetReturnValue().Set(dom_error.toV8Value());
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698