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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 502 |
503 void WebIntentPickerController::OnFaviconDataAvailable( | 503 void WebIntentPickerController::OnFaviconDataAvailable( |
504 FaviconService::Handle handle, history::FaviconData favicon_data) { | 504 FaviconService::Handle handle, history::FaviconData favicon_data) { |
505 size_t index = favicon_consumer_.GetClientDataForCurrentRequest(); | 505 size_t index = favicon_consumer_.GetClientDataForCurrentRequest(); |
506 if (favicon_data.is_valid()) { | 506 if (favicon_data.is_valid()) { |
507 SkBitmap icon_bitmap; | 507 SkBitmap icon_bitmap; |
508 | 508 |
509 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(), | 509 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(), |
510 favicon_data.image_data->size(), | 510 favicon_data.image_data->size(), |
511 &icon_bitmap)) { | 511 &icon_bitmap)) { |
512 gfx::Image icon_image(new SkBitmap(icon_bitmap)); | 512 gfx::Image icon_image(icon_bitmap); |
513 picker_model_->UpdateFaviconAt(index, icon_image); | 513 picker_model_->UpdateFaviconAt(index, icon_image); |
514 return; | 514 return; |
515 } | 515 } |
516 } | 516 } |
517 | 517 |
518 AsyncOperationFinished(); | 518 AsyncOperationFinished(); |
519 } | 519 } |
520 | 520 |
521 void WebIntentPickerController::OnCWSIntentServicesAvailable( | 521 void WebIntentPickerController::OnCWSIntentServicesAvailable( |
522 const CWSIntentsRegistry::IntentExtensionList& extensions) { | 522 const CWSIntentsRegistry::IntentExtensionList& extensions) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 const base::Closure& unavailable_callback) { | 606 const base::Closure& unavailable_callback) { |
607 SkBitmap icon_bitmap; | 607 SkBitmap icon_bitmap; |
608 if (gfx::PNGCodec::Decode( | 608 if (gfx::PNGCodec::Decode( |
609 reinterpret_cast<const unsigned char*>(icon_response->data()), | 609 reinterpret_cast<const unsigned char*>(icon_response->data()), |
610 icon_response->length(), | 610 icon_response->length(), |
611 &icon_bitmap)) { | 611 &icon_bitmap)) { |
612 SkBitmap resized_icon = skia::ImageOperations::Resize( | 612 SkBitmap resized_icon = skia::ImageOperations::Resize( |
613 icon_bitmap, | 613 icon_bitmap, |
614 skia::ImageOperations::RESIZE_BEST, | 614 skia::ImageOperations::RESIZE_BEST, |
615 gfx::kFaviconSize, gfx::kFaviconSize); | 615 gfx::kFaviconSize, gfx::kFaviconSize); |
616 gfx::Image icon_image(new SkBitmap(resized_icon)); | 616 gfx::Image icon_image(resized_icon); |
617 | 617 |
618 content::BrowserThread::PostTask( | 618 content::BrowserThread::PostTask( |
619 content::BrowserThread::UI, | 619 content::BrowserThread::UI, |
620 FROM_HERE, | 620 FROM_HERE, |
621 base::Bind(callback, icon_image)); | 621 base::Bind(callback, icon_image)); |
622 } else { | 622 } else { |
623 content::BrowserThread::PostTask( | 623 content::BrowserThread::PostTask( |
624 content::BrowserThread::UI, | 624 content::BrowserThread::UI, |
625 FROM_HERE, | 625 FROM_HERE, |
626 unavailable_callback); | 626 unavailable_callback); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 // If picker is non-NULL, it was set by a test. | 664 // If picker is non-NULL, it was set by a test. |
665 if (picker_ == NULL) | 665 if (picker_ == NULL) |
666 picker_ = WebIntentPicker::Create(wrapper_, this, picker_model_.get()); | 666 picker_ = WebIntentPicker::Create(wrapper_, this, picker_model_.get()); |
667 picker_shown_ = true; | 667 picker_shown_ = true; |
668 } | 668 } |
669 | 669 |
670 void WebIntentPickerController::ClosePicker() { | 670 void WebIntentPickerController::ClosePicker() { |
671 if (picker_) | 671 if (picker_) |
672 picker_->Close(); | 672 picker_->Close(); |
673 } | 673 } |
OLD | NEW |