| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/extensions/chrome_v8_context.h" | 5 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 bool success, | 136 bool success, |
| 137 const base::ListValue& response, | 137 const base::ListValue& response, |
| 138 const std::string& error) { | 138 const std::string& error) { |
| 139 v8::HandleScope handle_scope(isolate()); | 139 v8::HandleScope handle_scope(isolate()); |
| 140 | 140 |
| 141 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 141 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 142 v8::Handle<v8::Value> argv[] = { | 142 v8::Handle<v8::Value> argv[] = { |
| 143 v8::Integer::New(request_id), | 143 v8::Integer::New(request_id), |
| 144 v8::String::New(name.c_str()), | 144 v8::String::New(name.c_str()), |
| 145 v8::Boolean::New(success), | 145 v8::Boolean::New(success), |
| 146 converter->ToV8Value(&response, v8_context_.get()), | 146 converter->ToV8Value(&response, v8_context_.NewHandle(isolate())), |
| 147 v8::String::New(error.c_str()) | 147 v8::String::New(error.c_str()) |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 v8::Handle<v8::Value> retval = module_system_->CallModuleMethod( | 150 v8::Handle<v8::Value> retval = module_system_->CallModuleMethod( |
| 151 "sendRequest", "handleResponse", arraysize(argv), argv); | 151 "sendRequest", "handleResponse", arraysize(argv), argv); |
| 152 | 152 |
| 153 // In debug, the js will validate the callback parameters and return a | 153 // In debug, the js will validate the callback parameters and return a |
| 154 // string if a validation error has occured. | 154 // string if a validation error has occured. |
| 155 if (DCHECK_IS_ON()) { | 155 if (DCHECK_IS_ON()) { |
| 156 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 156 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
| 157 std::string error = *v8::String::AsciiValue(retval); | 157 std::string error = *v8::String::AsciiValue(retval); |
| 158 DCHECK(false) << error; | 158 DCHECK(false) << error; |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace extensions | 163 } // namespace extensions |
| OLD | NEW |