| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/searchbox_extension.h" | 5 #include "chrome/renderer/searchbox_extension.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // } | 286 // } |
| 287 // static | 287 // static |
| 288 v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetSuggestions( | 288 v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetSuggestions( |
| 289 const v8::Arguments& args) { | 289 const v8::Arguments& args) { |
| 290 std::vector<std::string> suggestions; | 290 std::vector<std::string> suggestions; |
| 291 InstantCompleteBehavior behavior = INSTANT_COMPLETE_NOW; | 291 InstantCompleteBehavior behavior = INSTANT_COMPLETE_NOW; |
| 292 | 292 |
| 293 if (args.Length() && args[0]->IsArray()) { | 293 if (args.Length() && args[0]->IsArray()) { |
| 294 // For backwards compatibility, also accept an array of strings. | 294 // For backwards compatibility, also accept an array of strings. |
| 295 // TODO(tonyg): Remove this when it is confirmed to be unused. | 295 // TODO(tonyg): Remove this when it is confirmed to be unused. |
| 296 v8::Array* suggestions_array = static_cast<v8::Array*>(*args[0]); | 296 v8::Array* suggestions_array = v8::Array::Cast(*args[0]); |
| 297 uint32_t length = suggestions_array->Length(); | 297 uint32_t length = suggestions_array->Length(); |
| 298 for (uint32_t i = 0; i < length; i++) { | 298 for (uint32_t i = 0; i < length; i++) { |
| 299 std::string suggestion = *v8::String::Utf8Value( | 299 std::string suggestion = *v8::String::Utf8Value( |
| 300 suggestions_array->Get(v8::Integer::New(i))->ToString()); | 300 suggestions_array->Get(v8::Integer::New(i))->ToString()); |
| 301 if (!suggestion.length()) continue; | 301 if (!suggestion.length()) continue; |
| 302 suggestions.push_back(suggestion); | 302 suggestions.push_back(suggestion); |
| 303 } | 303 } |
| 304 } else if (args.Length() && args[0]->IsObject()) { | 304 } else if (args.Length() && args[0]->IsObject()) { |
| 305 // Standard version, object argument. | 305 // Standard version, object argument. |
| 306 v8::Object* suggestion_json = static_cast<v8::Object*>(*args[0]); | 306 v8::Object* suggestion_json = static_cast<v8::Object*>(*args[0]); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 426 |
| 427 return supports_searchbox_api || supports_deprecated_api; | 427 return supports_searchbox_api || supports_deprecated_api; |
| 428 } | 428 } |
| 429 | 429 |
| 430 // static | 430 // static |
| 431 v8::Extension* SearchBoxExtension::Get() { | 431 v8::Extension* SearchBoxExtension::Get() { |
| 432 return new SearchBoxExtensionWrapper(); | 432 return new SearchBoxExtensionWrapper(); |
| 433 } | 433 } |
| 434 | 434 |
| 435 } // namespace extensions_v8 | 435 } // namespace extensions_v8 |
| OLD | NEW |