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/searchbox/searchbox_extension.h" | 5 #include "chrome/renderer/searchbox/searchbox_extension.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 // Resize the preview to the given height. | 223 // Resize the preview to the given height. |
224 // Deprecated, use Show(). | 224 // Deprecated, use Show(). |
225 // TODO(jered): Delete this once it is no longer called. | 225 // TODO(jered): Delete this once it is no longer called. |
226 static v8::Handle<v8::Value> SetPreviewHeight(const v8::Arguments& args); | 226 static v8::Handle<v8::Value> SetPreviewHeight(const v8::Arguments& args); |
227 | 227 |
228 // Requests the preview be shown with the specified contents and height. | 228 // Requests the preview be shown with the specified contents and height. |
229 static v8::Handle<v8::Value> Show(const v8::Arguments& args); | 229 static v8::Handle<v8::Value> Show(const v8::Arguments& args); |
230 | 230 |
231 private: | 231 private: |
232 DISALLOW_IMPLICIT_CONSTRUCTORS(SearchBoxExtensionWrapper); | 232 DISALLOW_COPY_AND_ASSIGN(SearchBoxExtensionWrapper); |
233 }; | 233 }; |
234 | 234 |
235 SearchBoxExtensionWrapper::SearchBoxExtensionWrapper( | 235 SearchBoxExtensionWrapper::SearchBoxExtensionWrapper( |
236 const base::StringPiece& code) | 236 const base::StringPiece& code) |
237 : v8::Extension(kSearchBoxExtensionName, code.data(), 0, 0, code.size()) { | 237 : v8::Extension(kSearchBoxExtensionName, code.data(), 0, 0, code.size()) { |
238 } | 238 } |
239 | 239 |
240 v8::Handle<v8::FunctionTemplate> SearchBoxExtensionWrapper::GetNativeFunction( | 240 v8::Handle<v8::FunctionTemplate> SearchBoxExtensionWrapper::GetNativeFunction( |
241 v8::Handle<v8::String> name) { | 241 v8::Handle<v8::String> name) { |
242 if (name->Equals(v8::String::New("GetQuery"))) { | 242 if (name->Equals(v8::String::New("GetQuery"))) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 442 |
443 InstantCompleteBehavior behavior = INSTANT_COMPLETE_NOW; | 443 InstantCompleteBehavior behavior = INSTANT_COMPLETE_NOW; |
444 InstantSuggestionType type = INSTANT_SUGGESTION_SEARCH; | 444 InstantSuggestionType type = INSTANT_SUGGESTION_SEARCH; |
445 v8::Handle<v8::Value> complete_value = | 445 v8::Handle<v8::Value> complete_value = |
446 suggestion_json->Get(v8::String::New("complete_behavior")); | 446 suggestion_json->Get(v8::String::New("complete_behavior")); |
447 if (complete_value->IsString()) { | 447 if (complete_value->IsString()) { |
448 if (complete_value->Equals(v8::String::New("now"))) { | 448 if (complete_value->Equals(v8::String::New("now"))) { |
449 behavior = INSTANT_COMPLETE_NOW; | 449 behavior = INSTANT_COMPLETE_NOW; |
450 } else if (complete_value->Equals(v8::String::New("never"))) { | 450 } else if (complete_value->Equals(v8::String::New("never"))) { |
451 behavior = INSTANT_COMPLETE_NEVER; | 451 behavior = INSTANT_COMPLETE_NEVER; |
452 } else if (complete_value->Equals(v8::String::New("delayed"))) { | |
453 behavior = INSTANT_COMPLETE_DELAYED; | |
454 } else if (complete_value->Equals(v8::String::New("replace"))) { | 452 } else if (complete_value->Equals(v8::String::New("replace"))) { |
455 behavior = INSTANT_COMPLETE_REPLACE; | 453 behavior = INSTANT_COMPLETE_REPLACE; |
456 } else { | 454 } else { |
457 VLOG(1) << "Unsupported complete behavior '" | 455 VLOG(1) << "Unsupported complete behavior '" |
458 << *v8::String::Utf8Value(complete_value) << "'"; | 456 << *v8::String::Utf8Value(complete_value) << "'"; |
459 } | 457 } |
460 } | 458 } |
461 v8::Handle<v8::Value> suggestions_field = | 459 v8::Handle<v8::Value> suggestions_field = |
462 suggestion_json->Get(v8::String::New("suggestions")); | 460 suggestion_json->Get(v8::String::New("suggestions")); |
463 if (suggestions_field->IsArray()) { | 461 if (suggestions_field->IsArray()) { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 728 |
731 // static | 729 // static |
732 v8::Extension* SearchBoxExtension::Get() { | 730 v8::Extension* SearchBoxExtension::Get() { |
733 const base::StringPiece code = | 731 const base::StringPiece code = |
734 ResourceBundle::GetSharedInstance().GetRawDataResource( | 732 ResourceBundle::GetSharedInstance().GetRawDataResource( |
735 IDR_SEARCHBOX_API, ui::SCALE_FACTOR_NONE); | 733 IDR_SEARCHBOX_API, ui::SCALE_FACTOR_NONE); |
736 return new SearchBoxExtensionWrapper(code); | 734 return new SearchBoxExtensionWrapper(code); |
737 } | 735 } |
738 | 736 |
739 } // namespace extensions_v8 | 737 } // namespace extensions_v8 |
OLD | NEW |