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" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 const string16& mimetype, | 204 const string16& mimetype, |
205 const ResultsCallback& cb) { | 205 const ResultsCallback& cb) { |
206 scoped_ptr<IntentsQuery> query(new IntentsQuery); | 206 scoped_ptr<IntentsQuery> query(new IntentsQuery); |
207 query->callback = cb; | 207 query->callback = cb; |
208 query->url_fetcher.reset(net::URLFetcher::Create( | 208 query->url_fetcher.reset(net::URLFetcher::Create( |
209 0, BuildQueryURL(action,mimetype), net::URLFetcher::GET, this)); | 209 0, BuildQueryURL(action,mimetype), net::URLFetcher::GET, this)); |
210 | 210 |
211 if (query->url_fetcher.get() == NULL) | 211 if (query->url_fetcher.get() == NULL) |
212 return; | 212 return; |
213 | 213 |
214 query->url_fetcher->SetRequestContext(request_context_); | 214 query->url_fetcher->SetRequestContext(request_context_.get()); |
215 query->url_fetcher->SetLoadFlags( | 215 query->url_fetcher->SetLoadFlags( |
216 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); | 216 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); |
217 | 217 |
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 = chrome_common_net::AppendQueryParameter(request, "intent", |
229 UTF16ToUTF8(action)); | 229 UTF16ToUTF8(action)); |
230 request = chrome_common_net::AppendQueryParameter(request, "mime_types", | 230 request = chrome_common_net::AppendQueryParameter(request, "mime_types", |
231 UTF16ToUTF8(type)); | 231 UTF16ToUTF8(type)); |
232 request = chrome_common_net::AppendQueryParameter(request, "start_index", | 232 request = chrome_common_net::AppendQueryParameter(request, "start_index", |
233 "0"); | 233 "0"); |
234 request = chrome_common_net::AppendQueryParameter(request, "num_results", | 234 request = chrome_common_net::AppendQueryParameter(request, "num_results", |
235 kMaxSuggestions); | 235 kMaxSuggestions); |
236 request = chrome_common_net::AppendQueryParameter(request, "key", | 236 request = chrome_common_net::AppendQueryParameter(request, "key", |
237 google_apis::GetAPIKey()); | 237 google_apis::GetAPIKey()); |
238 | 238 |
239 return request; | 239 return request; |
240 } | 240 } |
OLD | NEW |