| OLD | NEW | 
|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" | 
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" | 
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" | 
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" | 
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 780   if (!result) return v8::Undefined(); | 780   if (!result) return v8::Undefined(); | 
| 781 | 781 | 
| 782   // We only support selecting autocomplete results that are URLs. | 782   // We only support selecting autocomplete results that are URLs. | 
| 783   string16 text = result->destination_url; | 783   string16 text = result->destination_url; | 
| 784   InstantCompleteBehavior behavior = INSTANT_COMPLETE_NOW; | 784   InstantCompleteBehavior behavior = INSTANT_COMPLETE_NOW; | 
| 785   InstantSuggestionType type = INSTANT_SUGGESTION_URL; | 785   InstantSuggestionType type = INSTANT_SUGGESTION_URL; | 
| 786 | 786 | 
| 787   std::vector<InstantSuggestion> suggestions; | 787   std::vector<InstantSuggestion> suggestions; | 
| 788   suggestions.push_back(InstantSuggestion(text, behavior, type)); | 788   suggestions.push_back(InstantSuggestion(text, behavior, type)); | 
| 789   SearchBox::Get(render_view)->SetSuggestions(suggestions); | 789   SearchBox::Get(render_view)->SetSuggestions(suggestions); | 
|  | 790   // Clear the SearchBox's query text explicitly since this is a restricted | 
|  | 791   // value. | 
|  | 792   SearchBox::Get(render_view)->ClearQuery(); | 
| 790 | 793 | 
| 791   return v8::Undefined(); | 794   return v8::Undefined(); | 
| 792 } | 795 } | 
| 793 | 796 | 
| 794 // static | 797 // static | 
| 795 v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetQuery( | 798 v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetQuery( | 
| 796     const v8::Arguments& args) { | 799     const v8::Arguments& args) { | 
| 797   content::RenderView* render_view = GetRenderView(); | 800   content::RenderView* render_view = GetRenderView(); | 
| 798   if (!render_view || args.Length() < 2) return v8::Undefined(); | 801   if (!render_view || args.Length() < 2) return v8::Undefined(); | 
| 799 | 802 | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 826   // We only support selecting autocomplete results that are URLs. | 829   // We only support selecting autocomplete results that are URLs. | 
| 827   string16 text = result->destination_url; | 830   string16 text = result->destination_url; | 
| 828   InstantCompleteBehavior behavior = INSTANT_COMPLETE_REPLACE; | 831   InstantCompleteBehavior behavior = INSTANT_COMPLETE_REPLACE; | 
| 829   // TODO(jered): Distinguish between history URLs and search provider | 832   // TODO(jered): Distinguish between history URLs and search provider | 
| 830   // navsuggest URLs so that we can do proper accounting on history URLs. | 833   // navsuggest URLs so that we can do proper accounting on history URLs. | 
| 831   InstantSuggestionType type = INSTANT_SUGGESTION_URL; | 834   InstantSuggestionType type = INSTANT_SUGGESTION_URL; | 
| 832 | 835 | 
| 833   std::vector<InstantSuggestion> suggestions; | 836   std::vector<InstantSuggestion> suggestions; | 
| 834   suggestions.push_back(InstantSuggestion(text, behavior, type)); | 837   suggestions.push_back(InstantSuggestion(text, behavior, type)); | 
| 835   SearchBox::Get(render_view)->SetSuggestions(suggestions); | 838   SearchBox::Get(render_view)->SetSuggestions(suggestions); | 
|  | 839   // Clear the SearchBox's query text explicitly since this is a restricted | 
|  | 840   // value. | 
|  | 841   SearchBox::Get(render_view)->ClearQuery(); | 
| 836 | 842 | 
| 837   return v8::Undefined(); | 843   return v8::Undefined(); | 
| 838 } | 844 } | 
| 839 | 845 | 
| 840 // static | 846 // static | 
| 841 v8::Handle<v8::Value> SearchBoxExtensionWrapper::ShowOverlay( | 847 v8::Handle<v8::Value> SearchBoxExtensionWrapper::ShowOverlay( | 
| 842     const v8::Arguments& args) { | 848     const v8::Arguments& args) { | 
| 843   content::RenderView* render_view = GetRenderView(); | 849   content::RenderView* render_view = GetRenderView(); | 
| 844   if (!render_view || args.Length() < 2) return v8::Undefined(); | 850   if (!render_view || args.Length() < 2) return v8::Undefined(); | 
| 845 | 851 | 
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1028 void SearchBoxExtension::DispatchThemeChange(WebKit::WebFrame* frame) { | 1034 void SearchBoxExtension::DispatchThemeChange(WebKit::WebFrame* frame) { | 
| 1029   Dispatch(frame, kDispatchThemeChangeEventScript); | 1035   Dispatch(frame, kDispatchThemeChangeEventScript); | 
| 1030 } | 1036 } | 
| 1031 | 1037 | 
| 1032 // static | 1038 // static | 
| 1033 void SearchBoxExtension::DispatchMostVisitedChanged( | 1039 void SearchBoxExtension::DispatchMostVisitedChanged( | 
| 1034     WebKit::WebFrame* frame) { | 1040     WebKit::WebFrame* frame) { | 
| 1035   Dispatch(frame, kDispatchMostVisitedChangedScript); | 1041   Dispatch(frame, kDispatchMostVisitedChangedScript); | 
| 1036 } | 1042 } | 
| 1037 }  // namespace extensions_v8 | 1043 }  // namespace extensions_v8 | 
| OLD | NEW | 
|---|