| 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/webui/ntp/android/bookmarks_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/android/bookmarks_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 partner_bookmarks_shim_->GetNodeByID(id, is_partner); | 382 partner_bookmarks_shim_->GetNodeByID(id, is_partner); |
| 383 if (!node) | 383 if (!node) |
| 384 return; | 384 return; |
| 385 | 385 |
| 386 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 386 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
| 387 profile, Profile::EXPLICIT_ACCESS); | 387 profile, Profile::EXPLICIT_ACCESS); |
| 388 favicon_service->GetRawFaviconForURL( | 388 favicon_service->GetRawFaviconForURL( |
| 389 FaviconService::FaviconForURLParams( | 389 FaviconService::FaviconForURLParams( |
| 390 profile, | 390 profile, |
| 391 node->url(), | 391 node->url(), |
| 392 history::FAVICON | history::TOUCH_ICON, | 392 history::TOUCH_PRECOMPOSED_ICON | history::TOUCH_ICON | |
| 393 gfx::kFaviconSize), | 393 history::FAVICON, |
| 394 ui::GetMaxScaleFactor(), | 394 0), // request the largest icon. |
| 395 ui::SCALE_FACTOR_100P, // density doesn't matter for the largest icon. |
| 395 base::Bind(&BookmarksHandler::OnShortcutFaviconDataAvailable, | 396 base::Bind(&BookmarksHandler::OnShortcutFaviconDataAvailable, |
| 396 base::Unretained(this), | 397 base::Unretained(this), |
| 397 node), | 398 node), |
| 398 &cancelable_task_tracker_); | 399 &cancelable_task_tracker_); |
| 399 } | 400 } |
| 400 | 401 |
| 401 void BookmarksHandler::OnShortcutFaviconDataAvailable( | 402 void BookmarksHandler::OnShortcutFaviconDataAvailable( |
| 402 const BookmarkNode* node, | 403 const BookmarkNode* node, |
| 403 const history::FaviconBitmapResult& bitmap_result) { | 404 const history::FaviconBitmapResult& bitmap_result) { |
| 404 SkColor color = SK_ColorWHITE; | 405 SkColor color = SK_ColorWHITE; |
| 405 SkBitmap favicon_bitmap; | 406 SkBitmap favicon_bitmap; |
| 406 if (bitmap_result.is_valid()) { | 407 if (bitmap_result.is_valid()) { |
| 407 color = GetDominantColorForFavicon(bitmap_result.bitmap_data); | 408 color = GetDominantColorForFavicon(bitmap_result.bitmap_data); |
| 408 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(), | 409 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(), |
| 409 bitmap_result.bitmap_data->size(), | 410 bitmap_result.bitmap_data->size(), |
| 410 &favicon_bitmap); | 411 &favicon_bitmap); |
| 411 } | 412 } |
| 412 TabAndroid* tab = TabAndroid::FromWebContents(web_ui()->GetWebContents()); | 413 TabAndroid* tab = TabAndroid::FromWebContents(web_ui()->GetWebContents()); |
| 413 if (tab) { | 414 if (tab) { |
| 414 tab->AddShortcutToBookmark(node->url(), node->GetTitle(), | 415 tab->AddShortcutToBookmark(node->url(), node->GetTitle(), |
| 415 favicon_bitmap, SkColorGetR(color), | 416 favicon_bitmap, SkColorGetR(color), |
| 416 SkColorGetG(color), SkColorGetB(color)); | 417 SkColorGetG(color), SkColorGetB(color)); |
| 417 } | 418 } |
| 418 } | 419 } |
| OLD | NEW |