| 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 void WebIntentPickerController::AddServiceToModel( | 490 void WebIntentPickerController::AddServiceToModel( |
| 491 const webkit_glue::WebIntentServiceData& service) { | 491 const webkit_glue::WebIntentServiceData& service) { |
| 492 FaviconService* favicon_service = GetFaviconService(tab_contents_); | 492 FaviconService* favicon_service = GetFaviconService(tab_contents_); |
| 493 | 493 |
| 494 picker_model_->AddInstalledService( | 494 picker_model_->AddInstalledService( |
| 495 service.title, | 495 service.title, |
| 496 service.service_url, | 496 service.service_url, |
| 497 service.disposition); | 497 service.disposition); |
| 498 | 498 |
| 499 pending_async_count_++; | 499 pending_async_count_++; |
| 500 FaviconService::Handle handle = favicon_service->GetFaviconForURL( | 500 FaviconService::Handle handle = favicon_service->GetFaviconImageForURL( |
| 501 tab_contents_->profile(), | 501 tab_contents_->profile(), |
| 502 service.service_url, | 502 service.service_url, |
| 503 history::FAVICON, | 503 history::FAVICON, |
| 504 gfx::kFaviconSize, |
| 504 &favicon_consumer_, | 505 &favicon_consumer_, |
| 505 base::Bind( | 506 base::Bind( |
| 506 &WebIntentPickerController::OnFaviconDataAvailable, | 507 &WebIntentPickerController::OnFaviconDataAvailable, |
| 507 weak_ptr_factory_.GetWeakPtr())); | 508 weak_ptr_factory_.GetWeakPtr())); |
| 508 favicon_consumer_.SetClientData( | 509 favicon_consumer_.SetClientData( |
| 509 favicon_service, handle, picker_model_->GetInstalledServiceCount() - 1); | 510 favicon_service, handle, picker_model_->GetInstalledServiceCount() - 1); |
| 510 } | 511 } |
| 511 | 512 |
| 512 void WebIntentPickerController::OnWebIntentServicesAvailable( | 513 void WebIntentPickerController::OnWebIntentServicesAvailable( |
| 513 const std::vector<webkit_glue::WebIntentServiceData>& services) { | 514 const std::vector<webkit_glue::WebIntentServiceData>& services) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 InvokeService(*default_service); | 568 InvokeService(*default_service); |
| 568 return; | 569 return; |
| 569 } | 570 } |
| 570 } | 571 } |
| 571 | 572 |
| 572 OnPickerEvent(kPickerEventRegistryDataComplete); | 573 OnPickerEvent(kPickerEventRegistryDataComplete); |
| 573 OnIntentDataArrived(); | 574 OnIntentDataArrived(); |
| 574 } | 575 } |
| 575 | 576 |
| 576 void WebIntentPickerController::OnFaviconDataAvailable( | 577 void WebIntentPickerController::OnFaviconDataAvailable( |
| 577 FaviconService::Handle handle, history::FaviconData favicon_data) { | 578 FaviconService::Handle handle, |
| 579 const history::FaviconImageResult& image_result) { |
| 578 size_t index = favicon_consumer_.GetClientDataForCurrentRequest(); | 580 size_t index = favicon_consumer_.GetClientDataForCurrentRequest(); |
| 579 if (favicon_data.is_valid()) { | 581 if (!image_result.image.IsEmpty()) { |
| 580 SkBitmap icon_bitmap; | 582 picker_model_->UpdateFaviconAt(index, image_result.image); |
| 581 | 583 return; |
| 582 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(), | |
| 583 favicon_data.image_data->size(), | |
| 584 &icon_bitmap)) { | |
| 585 gfx::Image icon_image(icon_bitmap); | |
| 586 picker_model_->UpdateFaviconAt(index, icon_image); | |
| 587 return; | |
| 588 } | |
| 589 } | 584 } |
| 590 | 585 |
| 591 AsyncOperationFinished(); | 586 AsyncOperationFinished(); |
| 592 } | 587 } |
| 593 | 588 |
| 594 void WebIntentPickerController::OnCWSIntentServicesAvailable( | 589 void WebIntentPickerController::OnCWSIntentServicesAvailable( |
| 595 const CWSIntentsRegistry::IntentExtensionList& extensions) { | 590 const CWSIntentsRegistry::IntentExtensionList& extensions) { |
| 596 ExtensionServiceInterface* extension_service = | 591 ExtensionServiceInterface* extension_service = |
| 597 tab_contents_->profile()->GetExtensionService(); | 592 tab_contents_->profile()->GetExtensionService(); |
| 598 | 593 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 picker_->SetActionString(GetIntentActionString( | 929 picker_->SetActionString(GetIntentActionString( |
| 935 UTF16ToUTF8(picker_model_->action()))); | 930 UTF16ToUTF8(picker_model_->action()))); |
| 936 picker_shown_ = true; | 931 picker_shown_ = true; |
| 937 } | 932 } |
| 938 | 933 |
| 939 void WebIntentPickerController::ClosePicker() { | 934 void WebIntentPickerController::ClosePicker() { |
| 940 SetDialogState(kPickerHidden); | 935 SetDialogState(kPickerHidden); |
| 941 if (picker_) | 936 if (picker_) |
| 942 picker_->Close(); | 937 picker_->Close(); |
| 943 } | 938 } |
| OLD | NEW |