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/ui/intents/web_intent_picker_controller.h" | 5 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 void WebIntentPickerController::AddServiceToModel( | 497 void WebIntentPickerController::AddServiceToModel( |
498 const webkit_glue::WebIntentServiceData& service) { | 498 const webkit_glue::WebIntentServiceData& service) { |
499 FaviconService* favicon_service = GetFaviconService(tab_contents_); | 499 FaviconService* favicon_service = GetFaviconService(tab_contents_); |
500 | 500 |
501 picker_model_->AddInstalledService( | 501 picker_model_->AddInstalledService( |
502 service.title, | 502 service.title, |
503 service.service_url, | 503 service.service_url, |
504 service.disposition); | 504 service.disposition); |
505 | 505 |
506 pending_async_count_++; | 506 pending_async_count_++; |
507 FaviconService::Handle handle = favicon_service->GetFaviconForURL( | 507 FaviconService::Handle handle = favicon_service->GetFaviconImageForURL( |
508 tab_contents_->profile(), | 508 tab_contents_->profile(), |
509 service.service_url, | 509 service.service_url, |
510 history::FAVICON, | 510 history::FAVICON, |
| 511 gfx::kFaviconSize, |
511 &favicon_consumer_, | 512 &favicon_consumer_, |
512 base::Bind( | 513 base::Bind( |
513 &WebIntentPickerController::OnFaviconDataAvailable, | 514 &WebIntentPickerController::OnFaviconDataAvailable, |
514 weak_ptr_factory_.GetWeakPtr())); | 515 weak_ptr_factory_.GetWeakPtr())); |
515 favicon_consumer_.SetClientData( | 516 favicon_consumer_.SetClientData( |
516 favicon_service, handle, picker_model_->GetInstalledServiceCount() - 1); | 517 favicon_service, handle, picker_model_->GetInstalledServiceCount() - 1); |
517 } | 518 } |
518 | 519 |
519 void WebIntentPickerController::OnWebIntentServicesAvailable( | 520 void WebIntentPickerController::OnWebIntentServicesAvailable( |
520 const std::vector<webkit_glue::WebIntentServiceData>& services) { | 521 const std::vector<webkit_glue::WebIntentServiceData>& services) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 InvokeService(*default_service); | 575 InvokeService(*default_service); |
575 return; | 576 return; |
576 } | 577 } |
577 } | 578 } |
578 | 579 |
579 OnPickerEvent(kPickerEventRegistryDataComplete); | 580 OnPickerEvent(kPickerEventRegistryDataComplete); |
580 OnIntentDataArrived(); | 581 OnIntentDataArrived(); |
581 } | 582 } |
582 | 583 |
583 void WebIntentPickerController::OnFaviconDataAvailable( | 584 void WebIntentPickerController::OnFaviconDataAvailable( |
584 FaviconService::Handle handle, history::FaviconData favicon_data) { | 585 FaviconService::Handle handle, |
| 586 const history::FaviconImageResult& image_result) { |
585 size_t index = favicon_consumer_.GetClientDataForCurrentRequest(); | 587 size_t index = favicon_consumer_.GetClientDataForCurrentRequest(); |
586 if (favicon_data.is_valid()) { | 588 if (!image_result.image.IsEmpty()) { |
587 SkBitmap icon_bitmap; | 589 picker_model_->UpdateFaviconAt(index, image_result.image); |
588 | 590 return; |
589 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(), | |
590 favicon_data.image_data->size(), | |
591 &icon_bitmap)) { | |
592 gfx::Image icon_image(icon_bitmap); | |
593 picker_model_->UpdateFaviconAt(index, icon_image); | |
594 return; | |
595 } | |
596 } | 591 } |
597 | 592 |
598 AsyncOperationFinished(); | 593 AsyncOperationFinished(); |
599 } | 594 } |
600 | 595 |
601 void WebIntentPickerController::OnCWSIntentServicesAvailable( | 596 void WebIntentPickerController::OnCWSIntentServicesAvailable( |
602 const CWSIntentsRegistry::IntentExtensionList& extensions) { | 597 const CWSIntentsRegistry::IntentExtensionList& extensions) { |
603 ExtensionServiceInterface* extension_service = | 598 ExtensionServiceInterface* extension_service = |
604 tab_contents_->profile()->GetExtensionService(); | 599 tab_contents_->profile()->GetExtensionService(); |
605 | 600 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 picker_->SetActionString(GetIntentActionString( | 937 picker_->SetActionString(GetIntentActionString( |
943 UTF16ToUTF8(picker_model_->action()))); | 938 UTF16ToUTF8(picker_model_->action()))); |
944 picker_shown_ = true; | 939 picker_shown_ = true; |
945 } | 940 } |
946 | 941 |
947 void WebIntentPickerController::ClosePicker() { | 942 void WebIntentPickerController::ClosePicker() { |
948 SetDialogState(kPickerHidden); | 943 SetDialogState(kPickerHidden); |
949 if (picker_) | 944 if (picker_) |
950 picker_->Close(); | 945 picker_->Close(); |
951 } | 946 } |
OLD | NEW |