Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: chrome/browser/bookmarks/bookmark_html_writer.cc

Issue 6651014: Applied the IconType. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: sync Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/callback.h" 8 #include "base/callback.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (bookmark_urls_.empty()) { 432 if (bookmark_urls_.empty()) {
433 return false; 433 return false;
434 } 434 }
435 do { 435 do {
436 std::string url = bookmark_urls_.front(); 436 std::string url = bookmark_urls_.front();
437 // Filter out urls that we've already got favicon for. 437 // Filter out urls that we've already got favicon for.
438 URLFaviconMap::const_iterator iter = favicons_map_->find(url); 438 URLFaviconMap::const_iterator iter = favicons_map_->find(url);
439 if (favicons_map_->end() == iter) { 439 if (favicons_map_->end() == iter) {
440 FaviconService* favicon_service = 440 FaviconService* favicon_service =
441 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 441 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
442 favicon_service->GetFaviconForURL(GURL(url), &favicon_consumer_, 442 favicon_service->GetFaviconForURL(GURL(url), history::FAVICON,
443 &favicon_consumer_,
443 NewCallback(this, &BookmarkFaviconFetcher::OnFaviconDataAvailable)); 444 NewCallback(this, &BookmarkFaviconFetcher::OnFaviconDataAvailable));
444 return true; 445 return true;
445 } else { 446 } else {
446 bookmark_urls_.pop_front(); 447 bookmark_urls_.pop_front();
447 } 448 }
448 } while (!bookmark_urls_.empty()); 449 } while (!bookmark_urls_.empty());
449 return false; 450 return false;
450 } 451 }
451 452
452 void BookmarkFaviconFetcher::OnFaviconDataAvailable( 453 void BookmarkFaviconFetcher::OnFaviconDataAvailable(
453 FaviconService::Handle handle, 454 FaviconService::Handle handle,
454 bool know_favicon, 455 history::FaviconData favicon) {
455 scoped_refptr<RefCountedMemory> data,
456 bool expired,
457 GURL icon_url) {
458 GURL url; 456 GURL url;
459 if (!bookmark_urls_.empty()) { 457 if (!bookmark_urls_.empty()) {
460 url = GURL(bookmark_urls_.front()); 458 url = GURL(bookmark_urls_.front());
461 bookmark_urls_.pop_front(); 459 bookmark_urls_.pop_front();
462 } 460 }
463 if (know_favicon && data.get() && data->size() && !url.is_empty()) { 461 if (favicon.is_valid() && !url.is_empty()) {
464 favicons_map_->insert(make_pair(url.spec(), data)); 462 favicons_map_->insert(make_pair(url.spec(), favicon.image_data));
465 } 463 }
466 464
467 if (FetchNextFavicon()) { 465 if (FetchNextFavicon()) {
468 return; 466 return;
469 } 467 }
470 ExecuteWriter(); 468 ExecuteWriter();
471 } 469 }
472 470
473 namespace bookmark_html_writer { 471 namespace bookmark_html_writer {
474 472
475 void WriteBookmarks(Profile* profile, 473 void WriteBookmarks(Profile* profile,
476 const FilePath& path, 474 const FilePath& path,
477 BookmarksExportObserver* observer) { 475 BookmarksExportObserver* observer) {
478 // BookmarkModel isn't thread safe (nor would we want to lock it down 476 // BookmarkModel isn't thread safe (nor would we want to lock it down
479 // for the duration of the write), as such we make a copy of the 477 // for the duration of the write), as such we make a copy of the
480 // BookmarkModel using BookmarkCodec then write from that. 478 // BookmarkModel using BookmarkCodec then write from that.
481 if (fetcher == NULL) { 479 if (fetcher == NULL) {
482 fetcher = new BookmarkFaviconFetcher(profile, path, observer); 480 fetcher = new BookmarkFaviconFetcher(profile, path, observer);
483 fetcher->ExportBookmarks(); 481 fetcher->ExportBookmarks();
484 } 482 }
485 } 483 }
486 484
487 } // namespace bookmark_html_writer 485 } // namespace bookmark_html_writer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698