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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 return true; | 466 return true; |
467 } else { | 467 } else { |
468 bookmark_urls_.pop_front(); | 468 bookmark_urls_.pop_front(); |
469 } | 469 } |
470 } while (!bookmark_urls_.empty()); | 470 } while (!bookmark_urls_.empty()); |
471 return false; | 471 return false; |
472 } | 472 } |
473 | 473 |
474 void BookmarkFaviconFetcher::OnFaviconDataAvailable( | 474 void BookmarkFaviconFetcher::OnFaviconDataAvailable( |
475 FaviconService::Handle handle, | 475 FaviconService::Handle handle, |
476 history::FaviconData favicon) { | 476 history::FaviconData favicon_data) { |
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 (favicon.is_valid() && !url.is_empty()) { | 482 if (favicon_data.is_valid() && !url.is_empty()) { |
483 favicons_map_->insert(make_pair(url.spec(), favicon.image_data)); | 483 favicons_map_->insert( |
| 484 make_pair(url.spec(), favicon_data.elements[0].bitmap_data)); |
484 } | 485 } |
485 | 486 |
486 if (FetchNextFavicon()) { | 487 if (FetchNextFavicon()) { |
487 return; | 488 return; |
488 } | 489 } |
489 ExecuteWriter(); | 490 ExecuteWriter(); |
490 } | 491 } |
491 | 492 |
492 namespace bookmark_html_writer { | 493 namespace bookmark_html_writer { |
493 | 494 |
494 void WriteBookmarks(Profile* profile, | 495 void WriteBookmarks(Profile* profile, |
495 const FilePath& path, | 496 const FilePath& path, |
496 BookmarksExportObserver* observer) { | 497 BookmarksExportObserver* observer) { |
497 // 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 |
498 // 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 |
499 // BookmarkModel using BookmarkCodec then write from that. | 500 // BookmarkModel using BookmarkCodec then write from that. |
500 if (fetcher == NULL) { | 501 if (fetcher == NULL) { |
501 fetcher = new BookmarkFaviconFetcher(profile, path, observer); | 502 fetcher = new BookmarkFaviconFetcher(profile, path, observer); |
502 fetcher->ExportBookmarks(); | 503 fetcher->ExportBookmarks(); |
503 } | 504 } |
504 } | 505 } |
505 | 506 |
506 } // namespace bookmark_html_writer | 507 } // namespace bookmark_html_writer |
OLD | NEW |