Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/renderer/extensions/file_system_provider_natives.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "third_party/WebKit/public/platform/WebString.h" | |
| 10 #include "third_party/WebKit/public/web/WebDOMError.h" | |
| 11 #include "v8/include/v8.h" | |
| 12 | |
| 13 namespace extensions { | |
| 14 | |
| 15 fileSystemProviderNatives::fileSystemProviderNatives( | |
| 16 ChromeV8Context* context) | |
| 17 : ObjectBackedNativeHandler(context) { | |
| 18 RouteFunction( | |
| 19 "GetDOMError", | |
| 20 base::Bind(&fileSystemProviderNatives::GetDOMError, | |
| 21 base::Unretained(this))); | |
| 22 } | |
| 23 | |
| 24 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.
| |
| 25 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 26 if (args.Length() != 2) { | |
| 27 NOTREACHED(); | |
| 28 return; | |
| 29 } | |
| 30 if (!args[0]->IsString()) { | |
| 31 NOTREACHED(); | |
| 32 return; | |
| 33 } | |
| 34 if (!args[1]->IsString()) { | |
| 35 NOTREACHED(); | |
| 36 return; | |
| 37 } | |
| 38 | |
| 39 std::string name(*v8::String::Utf8Value(args[0])); | |
| 40 if (name.empty()) { | |
| 41 NOTREACHED(); | |
| 42 return; | |
| 43 } | |
| 44 std::string message(*v8::String::Utf8Value(args[1])); | |
| 45 // message is optional hence empty is fine. | |
| 46 | |
| 47 blink::WebDOMError dom_error = blink::WebDOMError::create( | |
| 48 blink::WebString::fromUTF8(name), | |
| 49 blink::WebString::fromUTF8(message)); | |
| 50 args.GetReturnValue().Set(dom_error.toV8Value()); | |
| 51 } | |
| 52 | |
| 53 } // namespace extensions | |
| OLD | NEW |