| 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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 866   if (!result) return v8::Undefined(); | 866   if (!result) return v8::Undefined(); | 
| 867 | 867 | 
| 868   // We only support selecting autocomplete results that are URLs. | 868   // We only support selecting autocomplete results that are URLs. | 
| 869   string16 text = result->destination_url; | 869   string16 text = result->destination_url; | 
| 870   InstantCompleteBehavior behavior = INSTANT_COMPLETE_NOW; | 870   InstantCompleteBehavior behavior = INSTANT_COMPLETE_NOW; | 
| 871   InstantSuggestionType type = INSTANT_SUGGESTION_URL; | 871   InstantSuggestionType type = INSTANT_SUGGESTION_URL; | 
| 872 | 872 | 
| 873   std::vector<InstantSuggestion> suggestions; | 873   std::vector<InstantSuggestion> suggestions; | 
| 874   suggestions.push_back(InstantSuggestion(text, behavior, type)); | 874   suggestions.push_back(InstantSuggestion(text, behavior, type)); | 
| 875   SearchBox::Get(render_view)->SetSuggestions(suggestions); | 875   SearchBox::Get(render_view)->SetSuggestions(suggestions); | 
|  | 876   // Clear the SearchBox's query text explicitly since this is a restricted | 
|  | 877   // value. | 
|  | 878   SearchBox::Get(render_view)->ClearQuery(); | 
| 876 | 879 | 
| 877   return v8::Undefined(); | 880   return v8::Undefined(); | 
| 878 } | 881 } | 
| 879 | 882 | 
| 880 // static | 883 // static | 
| 881 v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetQuery( | 884 v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetQuery( | 
| 882     const v8::Arguments& args) { | 885     const v8::Arguments& args) { | 
| 883   content::RenderView* render_view = GetRenderView(); | 886   content::RenderView* render_view = GetRenderView(); | 
| 884   if (!render_view || args.Length() < 2) return v8::Undefined(); | 887   if (!render_view || args.Length() < 2) return v8::Undefined(); | 
| 885 | 888 | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 912   // We only support selecting autocomplete results that are URLs. | 915   // We only support selecting autocomplete results that are URLs. | 
| 913   string16 text = result->destination_url; | 916   string16 text = result->destination_url; | 
| 914   InstantCompleteBehavior behavior = INSTANT_COMPLETE_REPLACE; | 917   InstantCompleteBehavior behavior = INSTANT_COMPLETE_REPLACE; | 
| 915   // TODO(jered): Distinguish between history URLs and search provider | 918   // TODO(jered): Distinguish between history URLs and search provider | 
| 916   // navsuggest URLs so that we can do proper accounting on history URLs. | 919   // navsuggest URLs so that we can do proper accounting on history URLs. | 
| 917   InstantSuggestionType type = INSTANT_SUGGESTION_URL; | 920   InstantSuggestionType type = INSTANT_SUGGESTION_URL; | 
| 918 | 921 | 
| 919   std::vector<InstantSuggestion> suggestions; | 922   std::vector<InstantSuggestion> suggestions; | 
| 920   suggestions.push_back(InstantSuggestion(text, behavior, type)); | 923   suggestions.push_back(InstantSuggestion(text, behavior, type)); | 
| 921   SearchBox::Get(render_view)->SetSuggestions(suggestions); | 924   SearchBox::Get(render_view)->SetSuggestions(suggestions); | 
|  | 925   // Clear the SearchBox's query text explicitly since this is a restricted | 
|  | 926   // value. | 
|  | 927   SearchBox::Get(render_view)->ClearQuery(); | 
| 922 | 928 | 
| 923   return v8::Undefined(); | 929   return v8::Undefined(); | 
| 924 } | 930 } | 
| 925 | 931 | 
| 926 // static | 932 // static | 
| 927 v8::Handle<v8::Value> SearchBoxExtensionWrapper::ShowOverlay( | 933 v8::Handle<v8::Value> SearchBoxExtensionWrapper::ShowOverlay( | 
| 928     const v8::Arguments& args) { | 934     const v8::Arguments& args) { | 
| 929   content::RenderView* render_view = GetRenderView(); | 935   content::RenderView* render_view = GetRenderView(); | 
| 930   if (!render_view || args.Length() < 2) return v8::Undefined(); | 936   if (!render_view || args.Length() < 2) return v8::Undefined(); | 
| 931 | 937 | 
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1143 void SearchBoxExtension::DispatchThemeChange(WebKit::WebFrame* frame) { | 1149 void SearchBoxExtension::DispatchThemeChange(WebKit::WebFrame* frame) { | 
| 1144   Dispatch(frame, kDispatchThemeChangeEventScript); | 1150   Dispatch(frame, kDispatchThemeChangeEventScript); | 
| 1145 } | 1151 } | 
| 1146 | 1152 | 
| 1147 // static | 1153 // static | 
| 1148 void SearchBoxExtension::DispatchMostVisitedChanged( | 1154 void SearchBoxExtension::DispatchMostVisitedChanged( | 
| 1149     WebKit::WebFrame* frame) { | 1155     WebKit::WebFrame* frame) { | 
| 1150   Dispatch(frame, kDispatchMostVisitedChangedScript); | 1156   Dispatch(frame, kDispatchMostVisitedChangedScript); | 
| 1151 } | 1157 } | 
| 1152 }  // namespace extensions_v8 | 1158 }  // namespace extensions_v8 | 
| OLD | NEW | 
|---|