| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 | 522 |
| 523 void WebIntentPickerController::OnFaviconDataAvailable( | 523 void WebIntentPickerController::OnFaviconDataAvailable( |
| 524 FaviconService::Handle handle, history::FaviconData favicon_data) { | 524 FaviconService::Handle handle, history::FaviconData favicon_data) { |
| 525 size_t index = favicon_consumer_.GetClientDataForCurrentRequest(); | 525 size_t index = favicon_consumer_.GetClientDataForCurrentRequest(); |
| 526 if (favicon_data.is_valid()) { | 526 if (favicon_data.is_valid()) { |
| 527 SkBitmap icon_bitmap; | 527 SkBitmap icon_bitmap; |
| 528 | 528 |
| 529 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(), | 529 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(), |
| 530 favicon_data.image_data->size(), | 530 favicon_data.image_data->size(), |
| 531 &icon_bitmap)) { | 531 &icon_bitmap)) { |
| 532 gfx::Image icon_image(new SkBitmap(icon_bitmap)); | 532 gfx::Image icon_image(icon_bitmap); |
| 533 picker_model_->UpdateFaviconAt(index, icon_image); | 533 picker_model_->UpdateFaviconAt(index, icon_image); |
| 534 return; | 534 return; |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 | 537 |
| 538 AsyncOperationFinished(); | 538 AsyncOperationFinished(); |
| 539 } | 539 } |
| 540 | 540 |
| 541 void WebIntentPickerController::OnCWSIntentServicesAvailable( | 541 void WebIntentPickerController::OnCWSIntentServicesAvailable( |
| 542 const CWSIntentsRegistry::IntentExtensionList& extensions) { | 542 const CWSIntentsRegistry::IntentExtensionList& extensions) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 const base::Closure& unavailable_callback) { | 626 const base::Closure& unavailable_callback) { |
| 627 SkBitmap icon_bitmap; | 627 SkBitmap icon_bitmap; |
| 628 if (gfx::PNGCodec::Decode( | 628 if (gfx::PNGCodec::Decode( |
| 629 reinterpret_cast<const unsigned char*>(icon_response->data()), | 629 reinterpret_cast<const unsigned char*>(icon_response->data()), |
| 630 icon_response->length(), | 630 icon_response->length(), |
| 631 &icon_bitmap)) { | 631 &icon_bitmap)) { |
| 632 SkBitmap resized_icon = skia::ImageOperations::Resize( | 632 SkBitmap resized_icon = skia::ImageOperations::Resize( |
| 633 icon_bitmap, | 633 icon_bitmap, |
| 634 skia::ImageOperations::RESIZE_BEST, | 634 skia::ImageOperations::RESIZE_BEST, |
| 635 gfx::kFaviconSize, gfx::kFaviconSize); | 635 gfx::kFaviconSize, gfx::kFaviconSize); |
| 636 gfx::Image icon_image(new SkBitmap(resized_icon)); | 636 gfx::Image icon_image(resized_icon); |
| 637 | 637 |
| 638 content::BrowserThread::PostTask( | 638 content::BrowserThread::PostTask( |
| 639 content::BrowserThread::UI, | 639 content::BrowserThread::UI, |
| 640 FROM_HERE, | 640 FROM_HERE, |
| 641 base::Bind(callback, icon_image)); | 641 base::Bind(callback, icon_image)); |
| 642 } else { | 642 } else { |
| 643 content::BrowserThread::PostTask( | 643 content::BrowserThread::PostTask( |
| 644 content::BrowserThread::UI, | 644 content::BrowserThread::UI, |
| 645 FROM_HERE, | 645 FROM_HERE, |
| 646 unavailable_callback); | 646 unavailable_callback); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 // If picker is non-NULL, it was set by a test. | 684 // If picker is non-NULL, it was set by a test. |
| 685 if (picker_ == NULL) | 685 if (picker_ == NULL) |
| 686 picker_ = WebIntentPicker::Create(wrapper_, this, picker_model_.get()); | 686 picker_ = WebIntentPicker::Create(wrapper_, this, picker_model_.get()); |
| 687 picker_shown_ = true; | 687 picker_shown_ = true; |
| 688 } | 688 } |
| 689 | 689 |
| 690 void WebIntentPickerController::ClosePicker() { | 690 void WebIntentPickerController::ClosePicker() { |
| 691 if (picker_) | 691 if (picker_) |
| 692 picker_->Close(); | 692 picker_->Close(); |
| 693 } | 693 } |
| OLD | NEW |