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/web_intents_registry.h" | 5 #include "chrome/browser/intents/web_intents_registry.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 258 |
259 // Filter out all services not matching the query type. | 259 // Filter out all services not matching the query type. |
260 FilterServicesByType(params.type_, &matching_services); | 260 FilterServicesByType(params.type_, &matching_services); |
261 | 261 |
262 // Collapse intents that are equivalent for all but |type|. | 262 // Collapse intents that are equivalent for all but |type|. |
263 CollapseIntents(&matching_services); | 263 CollapseIntents(&matching_services); |
264 | 264 |
265 callback.Run(matching_services); | 265 callback.Run(matching_services); |
266 } | 266 } |
267 | 267 |
| 268 void WebIntentsRegistry::OnAllDefaultIntentServicesReceived( |
| 269 const DefaultIntentServicesCallback& callback, |
| 270 const WDTypedResult* result) { |
| 271 DCHECK(result); |
| 272 DCHECK(result->GetType() == WEB_INTENTS_DEFAULTS_RESULT); |
| 273 |
| 274 const std::vector<DefaultWebIntentService> services = static_cast< |
| 275 const WDResult<std::vector<DefaultWebIntentService> >*>(result)-> |
| 276 GetValue(); |
| 277 |
| 278 callback.Run(services); |
| 279 } |
| 280 |
268 void WebIntentsRegistry::OnWebIntentsDefaultsResultReceived( | 281 void WebIntentsRegistry::OnWebIntentsDefaultsResultReceived( |
269 const QueryParams& params, | 282 const QueryParams& params, |
270 const DefaultQueryCallback& callback, | 283 const DefaultQueryCallback& callback, |
271 const WDTypedResult* result) { | 284 const WDTypedResult* result) { |
272 DCHECK(result); | 285 DCHECK(result); |
273 DCHECK(result->GetType() == WEB_INTENTS_DEFAULTS_RESULT); | 286 DCHECK(result->GetType() == WEB_INTENTS_DEFAULTS_RESULT); |
274 | 287 |
275 std::vector<DefaultWebIntentService> services = static_cast< | 288 std::vector<DefaultWebIntentService> services = static_cast< |
276 const WDResult<std::vector<DefaultWebIntentService> >*>(result)-> | 289 const WDResult<std::vector<DefaultWebIntentService> >*>(result)-> |
277 GetValue(); | 290 GetValue(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 const ResultsHandler handler = base::Bind( | 365 const ResultsHandler handler = base::Bind( |
353 &WebIntentsRegistry::OnWebIntentsResultReceived, | 366 &WebIntentsRegistry::OnWebIntentsResultReceived, |
354 base::Unretained(this), | 367 base::Unretained(this), |
355 params, | 368 params, |
356 callback); | 369 callback); |
357 | 370 |
358 QueryAdapter* query = new QueryAdapter(this, handler); | 371 QueryAdapter* query = new QueryAdapter(this, handler); |
359 query->query_handle_ = wds_->GetAllWebIntentServices(query); | 372 query->query_handle_ = wds_->GetAllWebIntentServices(query); |
360 } | 373 } |
361 | 374 |
| 375 void WebIntentsRegistry::GetAllDefaultIntentServices( |
| 376 const DefaultIntentServicesCallback& callback) { |
| 377 DCHECK(!callback.is_null()); |
| 378 |
| 379 ResultsHandler handler = base::Bind( |
| 380 &WebIntentsRegistry::OnAllDefaultIntentServicesReceived, |
| 381 base::Unretained(this), |
| 382 callback); |
| 383 |
| 384 QueryAdapter* query = new QueryAdapter(this, handler); |
| 385 query->query_handle_ = |
| 386 wds_->GetAllDefaultWebIntentServices(query); |
| 387 } |
| 388 |
362 void WebIntentsRegistry::IntentServiceExists( | 389 void WebIntentsRegistry::IntentServiceExists( |
363 const WebIntentServiceData& service, | 390 const WebIntentServiceData& service, |
364 const base::Callback<void(bool)>& callback) { | 391 const base::Callback<void(bool)>& callback) { |
365 DCHECK(!callback.is_null()); | 392 DCHECK(!callback.is_null()); |
366 | 393 |
367 ResultsHandler handler = base::Bind( | 394 ResultsHandler handler = base::Bind( |
368 &ExistenceCallback, | 395 &ExistenceCallback, |
369 service, | 396 service, |
370 callback); | 397 callback); |
371 | 398 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { | 534 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { |
508 QueryVector::iterator it = std::find( | 535 QueryVector::iterator it = std::find( |
509 pending_queries_.begin(), pending_queries_.end(), query); | 536 pending_queries_.begin(), pending_queries_.end(), query); |
510 if (it != pending_queries_.end()) { | 537 if (it != pending_queries_.end()) { |
511 pending_queries_.erase(it); | 538 pending_queries_.erase(it); |
512 delete query; | 539 delete query; |
513 } else { | 540 } else { |
514 NOTREACHED(); | 541 NOTREACHED(); |
515 } | 542 } |
516 } | 543 } |
OLD | NEW |