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/cocoa/history_menu_bridge.h" | 5 #include "chrome/browser/ui/cocoa/history_menu_bridge.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 HistoryItem* item = | 463 HistoryItem* item = |
464 favicon_consumer_.GetClientData( | 464 favicon_consumer_.GetClientData( |
465 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); | 465 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); |
466 DCHECK(item); | 466 DCHECK(item); |
467 item->icon_requested = false; | 467 item->icon_requested = false; |
468 item->icon_handle = NULL; | 468 item->icon_handle = NULL; |
469 | 469 |
470 // Convert the raw data to Skia and then to a NSImage. | 470 // Convert the raw data to Skia and then to a NSImage. |
471 // TODO(rsesek): Is there an easier way to do this? | 471 // TODO(rsesek): Is there an easier way to do this? |
472 SkBitmap icon; | 472 SkBitmap icon; |
473 if (favicon.is_valid() && | 473 if (favicon.is_valid() && favicon.variants.size() > 0 && |
474 gfx::PNGCodec::Decode(favicon.bitmap_data->front(), | 474 gfx::PNGCodec::Decode(favicon.variants[0].bitmap_data->front(), |
475 favicon.bitmap_data->size(), &icon)) { | 475 favicon.variants[0].bitmap_data->size(), &icon)) { |
476 NSImage* image = gfx::SkBitmapToNSImage(icon); | 476 NSImage* image = gfx::SkBitmapToNSImage(icon); |
477 if (image) { | 477 if (image) { |
478 // The conversion was successful. | 478 // The conversion was successful. |
479 item->icon.reset([image retain]); | 479 item->icon.reset([image retain]); |
480 [item->menu_item setImage:item->icon.get()]; | 480 [item->menu_item setImage:item->icon.get()]; |
481 } | 481 } |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { | 485 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { |
486 DCHECK(item); | 486 DCHECK(item); |
487 if (item->icon_requested) { | 487 if (item->icon_requested) { |
488 FaviconService* service = | 488 FaviconService* service = |
489 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 489 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); |
490 service->CancelRequest(item->icon_handle); | 490 service->CancelRequest(item->icon_handle); |
491 item->icon_requested = false; | 491 item->icon_requested = false; |
492 item->icon_handle = NULL; | 492 item->icon_handle = NULL; |
493 } | 493 } |
494 } | 494 } |
OLD | NEW |