Chromium Code Reviews| Index: chrome/renderer/extensions/pepper_request_natives.cc | 
| diff --git a/chrome/renderer/extensions/pepper_request_natives.cc b/chrome/renderer/extensions/pepper_request_natives.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..5458b5b612326863e779fb93e39bbf0c31357745 | 
| --- /dev/null | 
| +++ b/chrome/renderer/extensions/pepper_request_natives.cc | 
| @@ -0,0 +1,46 @@ | 
| +// 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/pepper_request_natives.h" | 
| + | 
| +#include "base/values.h" | 
| 
 
yzshen1
2013/11/26 19:33:11
nit: please include what this file uses:
logging.h
 
Sam McNally
2013/11/27 23:40:26
Done.
 
 | 
| +#include "chrome/renderer/extensions/chrome_v8_context.h" | 
| +#include "content/public/renderer/v8_value_converter.h" | 
| + | 
| +namespace extensions { | 
| + | 
| +PepperRequestNatives::PepperRequestNatives(ChromeV8Context* context) | 
| + : ObjectBackedNativeHandler(context) { | 
| + RouteFunction( | 
| + "SendResponse", | 
| + base::Bind(&PepperRequestNatives::SendResponse, base::Unretained(this))); | 
| +} | 
| + | 
| +void PepperRequestNatives::SendResponse( | 
| + const v8::FunctionCallbackInfo<v8::Value>& args) { | 
| + DCHECK(args.Length() == 3); | 
| + DCHECK(args[0]->IsInt32()); | 
| + int request_id = args[0]->Int32Value(); | 
| + bool success = true; | 
| + std::string error; | 
| + if (args[2]->IsString()) { | 
| + error = *v8::String::Utf8Value(args[2]); | 
| + success = false; | 
| + } | 
| + scoped_ptr<content::V8ValueConverter> converter( | 
| + content::V8ValueConverter::create()); | 
| + scoped_ptr<const base::Value> result( | 
| + converter->FromV8Value(args[1], context()->v8_context())); | 
| + if (!result) { | 
| + result.reset(new base::ListValue); | 
| + success = false; | 
| + } | 
| + const base::ListValue* result_list = NULL; | 
| + if (!result->GetAsList(&result_list)) | 
| + NOTREACHED(); | 
| + context()->pepper_request_proxy()->OnResponse( | 
| + request_id, success, *result_list, error); | 
| +} | 
| + | 
| +} // namespace extensions |