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/bookmarks/bookmark_html_writer.h" | 5 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 if (bookmark_urls_.empty()) { | 450 if (bookmark_urls_.empty()) { |
451 return false; | 451 return false; |
452 } | 452 } |
453 do { | 453 do { |
454 std::string url = bookmark_urls_.front(); | 454 std::string url = bookmark_urls_.front(); |
455 // Filter out urls that we've already got favicon for. | 455 // Filter out urls that we've already got favicon for. |
456 URLFaviconMap::const_iterator iter = favicons_map_->find(url); | 456 URLFaviconMap::const_iterator iter = favicons_map_->find(url); |
457 if (favicons_map_->end() == iter) { | 457 if (favicons_map_->end() == iter) { |
458 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 458 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
459 profile_, Profile::EXPLICIT_ACCESS); | 459 profile_, Profile::EXPLICIT_ACCESS); |
460 favicon_service->GetRawFaviconForURL( | 460 favicon_service->GetRawFaviconForPageURL( |
461 FaviconService::FaviconForURLParams( | 461 FaviconService::FaviconForPageURLParams( |
462 GURL(url), favicon_base::FAVICON, gfx::kFaviconSize), | 462 GURL(url), favicon_base::FAVICON, gfx::kFaviconSize), |
463 ui::SCALE_FACTOR_100P, | 463 ui::SCALE_FACTOR_100P, |
464 base::Bind(&BookmarkFaviconFetcher::OnFaviconDataAvailable, | 464 base::Bind(&BookmarkFaviconFetcher::OnFaviconDataAvailable, |
465 base::Unretained(this)), | 465 base::Unretained(this)), |
466 &cancelable_task_tracker_); | 466 &cancelable_task_tracker_); |
467 return true; | 467 return true; |
468 } else { | 468 } else { |
469 bookmark_urls_.pop_front(); | 469 bookmark_urls_.pop_front(); |
470 } | 470 } |
471 } while (!bookmark_urls_.empty()); | 471 } while (!bookmark_urls_.empty()); |
472 return false; | 472 return false; |
473 } | 473 } |
474 | 474 |
475 void BookmarkFaviconFetcher::OnFaviconDataAvailable( | 475 void BookmarkFaviconFetcher::OnFaviconDataAvailable( |
476 const favicon_base::FaviconBitmapResult& bitmap_result) { | 476 const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
477 GURL url; | 477 GURL url; |
478 if (!bookmark_urls_.empty()) { | 478 if (!bookmark_urls_.empty()) { |
479 url = GURL(bookmark_urls_.front()); | 479 url = GURL(bookmark_urls_.front()); |
480 bookmark_urls_.pop_front(); | 480 bookmark_urls_.pop_front(); |
481 } | 481 } |
482 if (bitmap_result.is_valid() && !url.is_empty()) { | 482 if (bitmap_result.is_valid() && !url.is_empty()) { |
483 favicons_map_->insert( | 483 favicons_map_->insert( |
484 make_pair(url.spec(), bitmap_result.bitmap_data)); | 484 make_pair(url.spec(), bitmap_result.bitmap_data)); |
485 } | 485 } |
486 | 486 |
(...skipping 11 matching lines...) Expand all Loading... |
498 // BookmarkModel isn't thread safe (nor would we want to lock it down | 498 // BookmarkModel isn't thread safe (nor would we want to lock it down |
499 // for the duration of the write), as such we make a copy of the | 499 // for the duration of the write), as such we make a copy of the |
500 // BookmarkModel using BookmarkCodec then write from that. | 500 // BookmarkModel using BookmarkCodec then write from that. |
501 if (fetcher == NULL) { | 501 if (fetcher == NULL) { |
502 fetcher = new BookmarkFaviconFetcher(profile, path, observer); | 502 fetcher = new BookmarkFaviconFetcher(profile, path, observer); |
503 fetcher->ExportBookmarks(); | 503 fetcher->ExportBookmarks(); |
504 } | 504 } |
505 } | 505 } |
506 | 506 |
507 } // namespace bookmark_html_writer | 507 } // namespace bookmark_html_writer |
OLD | NEW |