| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/importer/bookmark_html_reader.h" | 5 #include "chrome/utility/importer/bookmark_html_reader.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/i18n/icu_string_conversions.h" | 9 #include "base/i18n/icu_string_conversions.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "chrome/browser/importer/reencode_favicon.h" | |
| 15 #include "chrome/common/importer/imported_bookmark_entry.h" | 14 #include "chrome/common/importer/imported_bookmark_entry.h" |
| 16 #include "chrome/common/importer/imported_favicon_usage.h" | 15 #include "chrome/common/importer/imported_favicon_usage.h" |
| 16 #include "chrome/utility/importer/favicon_reencode.h" |
| 17 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
| 18 #include "net/base/data_url.h" | 18 #include "net/base/data_url.h" |
| 19 #include "net/base/escape.h" | 19 #include "net/base/escape.h" |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Fetches the given |attribute| value from the |attribute_list|. Returns true | 24 // Fetches the given |attribute| value from the |attribute_list|. Returns true |
| 25 // if successful, and |value| will contain the value. | 25 // if successful, and |value| will contain the value. |
| 26 bool GetAttribute(const std::string& attribute_list, | 26 bool GetAttribute(const std::string& attribute_list, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 !favicon_data.SchemeIs(chrome::kDataScheme)) | 60 !favicon_data.SchemeIs(chrome::kDataScheme)) |
| 61 return; | 61 return; |
| 62 | 62 |
| 63 // Parse the data URL. | 63 // Parse the data URL. |
| 64 std::string mime_type, char_set, data; | 64 std::string mime_type, char_set, data; |
| 65 if (!net::DataURL::Parse(favicon_data, &mime_type, &char_set, &data) || | 65 if (!net::DataURL::Parse(favicon_data, &mime_type, &char_set, &data) || |
| 66 data.empty()) | 66 data.empty()) |
| 67 return; | 67 return; |
| 68 | 68 |
| 69 ImportedFaviconUsage usage; | 69 ImportedFaviconUsage usage; |
| 70 if (!ReencodeFavicon(reinterpret_cast<const uint8*>(&data[0]), | 70 if (!importer::ReencodeFavicon( |
| 71 data.size(), &usage.png_data)) | 71 reinterpret_cast<const unsigned char*>(&data[0]), |
| 72 data.size(), &usage.png_data)) |
| 72 return; // Unable to decode. | 73 return; // Unable to decode. |
| 73 | 74 |
| 74 // We need to make up a URL for the favicon. We use a version of the page's | 75 // We need to make up a URL for the favicon. We use a version of the page's |
| 75 // URL so that we can be sure it will not collide. | 76 // URL so that we can be sure it will not collide. |
| 76 usage.favicon_url = GURL(std::string("made-up-favicon:") + link_url.spec()); | 77 usage.favicon_url = GURL(std::string("made-up-favicon:") + link_url.spec()); |
| 77 | 78 |
| 78 // We only have one URL per favicon for Firefox 2 bookmarks. | 79 // We only have one URL per favicon for Firefox 2 bookmarks. |
| 79 usage.urls.insert(link_url); | 80 usage.urls.insert(link_url); |
| 80 | 81 |
| 81 favicons->push_back(usage); | 82 favicons->push_back(usage); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 *url = GURL(value); | 423 *url = GURL(value); |
| 423 } | 424 } |
| 424 } | 425 } |
| 425 | 426 |
| 426 return true; | 427 return true; |
| 427 } | 428 } |
| 428 | 429 |
| 429 } // namespace internal | 430 } // namespace internal |
| 430 | 431 |
| 431 } // namespace bookmark_html_reader | 432 } // namespace bookmark_html_reader |
| OLD | NEW |