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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 void HistoryMenuBridge::GotFaviconData(FaviconService::Handle handle, | 464 void HistoryMenuBridge::GotFaviconData(FaviconService::Handle handle, |
465 history::FaviconData favicon) { | 465 history::FaviconData favicon) { |
466 // Since we're going to do Cocoa-y things, make sure this is the main thread. | 466 // Since we're going to do Cocoa-y things, make sure this is the main thread. |
467 DCHECK([NSThread isMainThread]); | 467 DCHECK([NSThread isMainThread]); |
468 | 468 |
469 HistoryItem* item = | 469 HistoryItem* item = |
470 favicon_consumer_.GetClientData( | 470 favicon_consumer_.GetClientData( |
471 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); | 471 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); |
472 DCHECK(item); | 472 DCHECK(item); |
473 item->icon_requested = false; | 473 item->icon_requested = false; |
474 item->icon_handle = NULL; | 474 item->icon_handle = 0; |
475 | 475 |
476 // Convert the raw data to Skia and then to a NSImage. | 476 // Convert the raw data to Skia and then to a NSImage. |
477 // TODO(rsesek): Is there an easier way to do this? | 477 // TODO(rsesek): Is there an easier way to do this? |
478 SkBitmap icon; | 478 SkBitmap icon; |
479 if (favicon.is_valid() && | 479 if (favicon.is_valid() && |
480 gfx::PNGCodec::Decode(favicon.image_data->front(), | 480 gfx::PNGCodec::Decode(favicon.image_data->front(), |
481 favicon.image_data->size(), &icon)) { | 481 favicon.image_data->size(), &icon)) { |
482 NSImage* image = gfx::SkBitmapToNSImage(icon); | 482 NSImage* image = gfx::SkBitmapToNSImage(icon); |
483 if (image) { | 483 if (image) { |
484 // The conversion was successful. | 484 // The conversion was successful. |
485 item->icon.reset([image retain]); | 485 item->icon.reset([image retain]); |
486 [item->menu_item setImage:item->icon.get()]; | 486 [item->menu_item setImage:item->icon.get()]; |
487 } | 487 } |
488 } | 488 } |
489 } | 489 } |
490 | 490 |
491 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { | 491 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { |
492 DCHECK(item); | 492 DCHECK(item); |
493 if (item->icon_requested) { | 493 if (item->icon_requested) { |
494 FaviconService* service = | 494 FaviconService* service = |
495 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 495 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); |
496 service->CancelRequest(item->icon_handle); | 496 service->CancelRequest(item->icon_handle); |
497 item->icon_requested = false; | 497 item->icon_requested = false; |
498 item->icon_handle = NULL; | 498 item->icon_handle = 0; |
499 } | 499 } |
500 } | 500 } |
OLD | NEW |