| 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" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/ref_counted_memory.h" | 13 #include "base/memory/ref_counted_memory.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
| 17 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
| 18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/browser/bookmarks/bookmark_codec.h" | 20 #include "chrome/browser/bookmarks/bookmark_codec.h" |
| 21 #include "chrome/browser/bookmarks/bookmark_model.h" | 21 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 23 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 23 #include "chrome/browser/history/history_types.h" | 24 #include "chrome/browser/history/history_types.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
| 28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 29 #include "net/base/escape.h" | 30 #include "net/base/escape.h" |
| 30 #include "net/base/file_stream.h" | 31 #include "net/base/file_stream.h" |
| 31 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 451 |
| 451 bool BookmarkFaviconFetcher::FetchNextFavicon() { | 452 bool BookmarkFaviconFetcher::FetchNextFavicon() { |
| 452 if (bookmark_urls_.empty()) { | 453 if (bookmark_urls_.empty()) { |
| 453 return false; | 454 return false; |
| 454 } | 455 } |
| 455 do { | 456 do { |
| 456 std::string url = bookmark_urls_.front(); | 457 std::string url = bookmark_urls_.front(); |
| 457 // Filter out urls that we've already got favicon for. | 458 // Filter out urls that we've already got favicon for. |
| 458 URLFaviconMap::const_iterator iter = favicons_map_->find(url); | 459 URLFaviconMap::const_iterator iter = favicons_map_->find(url); |
| 459 if (favicons_map_->end() == iter) { | 460 if (favicons_map_->end() == iter) { |
| 460 FaviconService* favicon_service = | 461 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
| 461 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 462 profile_, Profile::EXPLICIT_ACCESS); |
| 462 favicon_service->GetFaviconForURL(GURL(url), history::FAVICON, | 463 favicon_service->GetFaviconForURL(profile_, GURL(url), history::FAVICON, |
| 463 &favicon_consumer_, | 464 &favicon_consumer_, |
| 464 base::Bind(&BookmarkFaviconFetcher::OnFaviconDataAvailable, | 465 base::Bind(&BookmarkFaviconFetcher::OnFaviconDataAvailable, |
| 465 base::Unretained(this))); | 466 base::Unretained(this))); |
| 466 return true; | 467 return true; |
| 467 } else { | 468 } else { |
| 468 bookmark_urls_.pop_front(); | 469 bookmark_urls_.pop_front(); |
| 469 } | 470 } |
| 470 } while (!bookmark_urls_.empty()); | 471 } while (!bookmark_urls_.empty()); |
| 471 return false; | 472 return false; |
| 472 } | 473 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 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 |