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/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/common/autocomplete_match_type.h" |
12 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
13 #include "chrome/common/instant_types.h" | 14 #include "chrome/common/instant_types.h" |
14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
15 #include "chrome/renderer/searchbox/searchbox.h" | 16 #include "chrome/renderer/searchbox/searchbox.h" |
16 #include "content/public/renderer/render_view.h" | 17 #include "content/public/renderer/render_view.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 #include "grit/renderer_resources.h" | 19 #include "grit/renderer_resources.h" |
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 137 |
137 // Populates a Javascript NativeSuggestions object from |result|. | 138 // Populates a Javascript NativeSuggestions object from |result|. |
138 // NOTE: Includes properties like "contents" which should be erased before the | 139 // NOTE: Includes properties like "contents" which should be erased before the |
139 // suggestion is returned to the Instant page. | 140 // suggestion is returned to the Instant page. |
140 v8::Handle<v8::Object> GenerateNativeSuggestion( | 141 v8::Handle<v8::Object> GenerateNativeSuggestion( |
141 const string16& query, | 142 const string16& query, |
142 InstantRestrictedID restricted_id, | 143 InstantRestrictedID restricted_id, |
143 const InstantAutocompleteResult& result) { | 144 const InstantAutocompleteResult& result) { |
144 v8::Handle<v8::Object> obj = v8::Object::New(); | 145 v8::Handle<v8::Object> obj = v8::Object::New(); |
145 obj->Set(v8::String::New("provider"), UTF16ToV8String(result.provider)); | 146 obj->Set(v8::String::New("provider"), UTF16ToV8String(result.provider)); |
146 obj->Set(v8::String::New("type"), UTF16ToV8String(result.type)); | 147 obj->Set(v8::String::New("type"), |
| 148 UTF8ToV8String(AutocompleteMatchType::ToString(result.type))); |
147 obj->Set(v8::String::New("description"), UTF16ToV8String(result.description)); | 149 obj->Set(v8::String::New("description"), UTF16ToV8String(result.description)); |
148 obj->Set(v8::String::New("destination_url"), | 150 obj->Set(v8::String::New("destination_url"), |
149 UTF16ToV8String(result.destination_url)); | 151 UTF16ToV8String(result.destination_url)); |
150 if (result.search_query.empty()) { | 152 if (result.search_query.empty()) { |
151 string16 url = result.destination_url; | 153 string16 url = result.destination_url; |
152 FormatURLForDisplay(&url, query); | 154 FormatURLForDisplay(&url, query); |
153 obj->Set(v8::String::New("contents"), UTF16ToV8String(url)); | 155 obj->Set(v8::String::New("contents"), UTF16ToV8String(url)); |
154 } else { | 156 } else { |
155 obj->Set(v8::String::New("contents"), UTF16ToV8String(result.search_query)); | 157 obj->Set(v8::String::New("contents"), UTF16ToV8String(result.search_query)); |
156 obj->Set(v8::String::New("is_search"), v8::Boolean::New(true)); | 158 obj->Set(v8::String::New("is_search"), v8::Boolean::New(true)); |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 WebKit::WebFrame* frame) { | 1454 WebKit::WebFrame* frame) { |
1453 Dispatch(frame, kDispatchMostVisitedChangedScript); | 1455 Dispatch(frame, kDispatchMostVisitedChangedScript); |
1454 } | 1456 } |
1455 | 1457 |
1456 // static | 1458 // static |
1457 void SearchBoxExtension::DispatchBarsHidden(WebKit::WebFrame* frame) { | 1459 void SearchBoxExtension::DispatchBarsHidden(WebKit::WebFrame* frame) { |
1458 Dispatch(frame, kDispatchBarsHiddenEventScript); | 1460 Dispatch(frame, kDispatchBarsHiddenEventScript); |
1459 } | 1461 } |
1460 | 1462 |
1461 } // namespace extensions_v8 | 1463 } // namespace extensions_v8 |
OLD | NEW |