| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 263 |
| 264 std::string favicon_string; | 264 std::string favicon_string; |
| 265 BookmarkFaviconFetcher::URLFaviconMap::iterator itr = | 265 BookmarkFaviconFetcher::URLFaviconMap::iterator itr = |
| 266 favicons_map_->find(url_string); | 266 favicons_map_->find(url_string); |
| 267 if (itr != favicons_map_->end()) { | 267 if (itr != favicons_map_->end()) { |
| 268 scoped_refptr<base::RefCountedMemory> data(itr->second.get()); | 268 scoped_refptr<base::RefCountedMemory> data(itr->second.get()); |
| 269 std::string favicon_data; | 269 std::string favicon_data; |
| 270 favicon_data.assign(reinterpret_cast<const char*>(data->front()), | 270 favicon_data.assign(reinterpret_cast<const char*>(data->front()), |
| 271 data->size()); | 271 data->size()); |
| 272 std::string favicon_base64_encoded; | 272 std::string favicon_base64_encoded; |
| 273 base::Base64Encode(favicon_data, &favicon_base64_encoded); | 273 if (base::Base64Encode(favicon_data, &favicon_base64_encoded)) { |
| 274 GURL favicon_url("data:image/png;base64," + favicon_base64_encoded); | 274 GURL favicon_url("data:image/png;base64," + favicon_base64_encoded); |
| 275 favicon_string = favicon_url.spec(); | 275 favicon_string = favicon_url.spec(); |
| 276 } |
| 276 } | 277 } |
| 277 | 278 |
| 278 if (!WriteIndent() || | 279 if (!WriteIndent() || |
| 279 !Write(kBookmarkStart) || | 280 !Write(kBookmarkStart) || |
| 280 !Write(url_string, ATTRIBUTE_VALUE) || | 281 !Write(url_string, ATTRIBUTE_VALUE) || |
| 281 !Write(kAddDate) || | 282 !Write(kAddDate) || |
| 282 !WriteTime(date_added_string) || | 283 !WriteTime(date_added_string) || |
| 283 (!favicon_string.empty() && | 284 (!favicon_string.empty() && |
| 284 (!Write(kIcon) || | 285 (!Write(kIcon) || |
| 285 !Write(favicon_string, ATTRIBUTE_VALUE))) || | 286 !Write(favicon_string, ATTRIBUTE_VALUE))) || |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // BookmarkModel isn't thread safe (nor would we want to lock it down | 502 // BookmarkModel isn't thread safe (nor would we want to lock it down |
| 502 // for the duration of the write), as such we make a copy of the | 503 // for the duration of the write), as such we make a copy of the |
| 503 // BookmarkModel using BookmarkCodec then write from that. | 504 // BookmarkModel using BookmarkCodec then write from that. |
| 504 if (fetcher == NULL) { | 505 if (fetcher == NULL) { |
| 505 fetcher = new BookmarkFaviconFetcher(profile, path, observer); | 506 fetcher = new BookmarkFaviconFetcher(profile, path, observer); |
| 506 fetcher->ExportBookmarks(); | 507 fetcher->ExportBookmarks(); |
| 507 } | 508 } |
| 508 } | 509 } |
| 509 | 510 |
| 510 } // namespace bookmark_html_writer | 511 } // namespace bookmark_html_writer |
| OLD | NEW |