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/utility/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/common/importer/imported_bookmark_entry.h" | 14 #include "chrome/common/importer/imported_bookmark_entry.h" |
15 #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" | 16 #include "chrome/utility/importer/favicon_reencode.h" |
17 #include "content/public/common/url_constants.h" | |
18 #include "net/base/data_url.h" | 17 #include "net/base/data_url.h" |
19 #include "net/base/escape.h" | 18 #include "net/base/escape.h" |
20 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 #include "url/url_constants.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, |
27 const std::string& attribute, | 27 const std::string& attribute, |
28 std::string* value) { | 28 std::string* value) { |
29 const char kQuote[] = "\""; | 29 const char kQuote[] = "\""; |
30 | 30 |
(...skipping 19 matching lines...) Expand all Loading... |
50 return true; | 50 return true; |
51 } | 51 } |
52 | 52 |
53 // Given the URL of a page and a favicon data URL, adds an appropriate record | 53 // Given the URL of a page and a favicon data URL, adds an appropriate record |
54 // to the given favicon usage vector. | 54 // to the given favicon usage vector. |
55 void DataURLToFaviconUsage( | 55 void DataURLToFaviconUsage( |
56 const GURL& link_url, | 56 const GURL& link_url, |
57 const GURL& favicon_data, | 57 const GURL& favicon_data, |
58 std::vector<ImportedFaviconUsage>* favicons) { | 58 std::vector<ImportedFaviconUsage>* favicons) { |
59 if (!link_url.is_valid() || !favicon_data.is_valid() || | 59 if (!link_url.is_valid() || !favicon_data.is_valid() || |
60 !favicon_data.SchemeIs(content::kDataScheme)) | 60 !favicon_data.SchemeIs(url::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 (!importer::ReencodeFavicon( | 70 if (!importer::ReencodeFavicon( |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 *url = GURL(value); | 433 *url = GURL(value); |
434 } | 434 } |
435 } | 435 } |
436 | 436 |
437 return true; | 437 return true; |
438 } | 438 } |
439 | 439 |
440 } // namespace internal | 440 } // namespace internal |
441 | 441 |
442 } // namespace bookmark_html_reader | 442 } // namespace bookmark_html_reader |
OLD | NEW |