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/browser/intents/cws_intents_registry.h" | 5 #include "chrome/browser/intents/cws_intents_registry.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/common/extensions/extension_l10n_util.h" | 13 #include "chrome/common/extensions/extension_l10n_util.h" |
14 #include "chrome/common/extensions/message_bundle.h" | 14 #include "chrome/common/extensions/message_bundle.h" |
15 #include "chrome/browser/net/chrome_url_request_context.h" | 15 #include "chrome/browser/net/chrome_url_request_context.h" |
16 #include "chrome/browser/webdata/web_data_service.h" | 16 #include "chrome/browser/webdata/web_data_service.h" |
17 #include "chrome/common/net/url_util.h" | |
18 #include "google_apis/google_api_keys.h" | 17 #include "google_apis/google_api_keys.h" |
19 #include "net/base/load_flags.h" | 18 #include "net/base/load_flags.h" |
20 #include "net/base/mime_util.h" | 19 #include "net/base/mime_util.h" |
| 20 #include "net/base/url_util.h" |
21 #include "net/url_request/url_fetcher.h" | 21 #include "net/url_request/url_fetcher.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Limit for the number of suggestions we fix from CWS. Ideally, the registry | 25 // Limit for the number of suggestions we fix from CWS. Ideally, the registry |
26 // simply get all of them, but there is a) chunking on the CWS side, and b) | 26 // simply get all of them, but there is a) chunking on the CWS side, and b) |
27 // there is a cost with suggestions fetched. (Network overhead for favicons, | 27 // there is a cost with suggestions fetched. (Network overhead for favicons, |
28 // roundtrips to registry to check if installed). | 28 // roundtrips to registry to check if installed). |
29 // | 29 // |
30 // Since the picker limits the number of suggestions displayed to 5, 15 means | 30 // Since the picker limits the number of suggestions displayed to 5, 15 means |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 URLFetcherHandle handle = reinterpret_cast<URLFetcherHandle>( | 218 URLFetcherHandle handle = reinterpret_cast<URLFetcherHandle>( |
219 query->url_fetcher.get()); | 219 query->url_fetcher.get()); |
220 queries_[handle] = query.release(); | 220 queries_[handle] = query.release(); |
221 queries_[handle]->url_fetcher->Start(); | 221 queries_[handle]->url_fetcher->Start(); |
222 } | 222 } |
223 | 223 |
224 // static | 224 // static |
225 GURL CWSIntentsRegistry::BuildQueryURL(const string16& action, | 225 GURL CWSIntentsRegistry::BuildQueryURL(const string16& action, |
226 const string16& type) { | 226 const string16& type) { |
227 GURL request(kCWSIntentServiceURL); | 227 GURL request(kCWSIntentServiceURL); |
228 request = chrome_common_net::AppendQueryParameter(request, "intent", | 228 request = net::AppendQueryParameter(request, "intent", UTF16ToUTF8(action)); |
229 UTF16ToUTF8(action)); | 229 request = net::AppendQueryParameter(request, "mime_types", UTF16ToUTF8(type)); |
230 request = chrome_common_net::AppendQueryParameter(request, "mime_types", | 230 request = net::AppendQueryParameter(request, "start_index", "0"); |
231 UTF16ToUTF8(type)); | 231 request = net::AppendQueryParameter(request, "num_results", kMaxSuggestions); |
232 request = chrome_common_net::AppendQueryParameter(request, "start_index", | 232 request = net::AppendQueryParameter(request, "key", google_apis::GetAPIKey()); |
233 "0"); | |
234 request = chrome_common_net::AppendQueryParameter(request, "num_results", | |
235 kMaxSuggestions); | |
236 request = chrome_common_net::AppendQueryParameter(request, "key", | |
237 google_apis::GetAPIKey()); | |
238 | 233 |
239 return request; | 234 return request; |
240 } | 235 } |
OLD | NEW |