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 <Cocoa/Cocoa.h> | 5 #include <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "chrome/browser/importer/safari_importer.h" | 7 #include "chrome/utility/importer/safari_importer.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/mac/mac_util.h" | 13 #include "base/mac/mac_util.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "chrome/browser/importer/importer_bridge.h" | |
19 #include "chrome/browser/importer/reencode_favicon.h" | |
20 #include "chrome/common/importer/imported_bookmark_entry.h" | 18 #include "chrome/common/importer/imported_bookmark_entry.h" |
21 #include "chrome/common/importer/imported_favicon_usage.h" | 19 #include "chrome/common/importer/imported_favicon_usage.h" |
| 20 #include "chrome/common/importer/importer_bridge.h" |
22 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 22 #include "chrome/utility/importer/favicon_reencode.h" |
23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
24 #include "net/base/data_url.h" | 24 #include "net/base/data_url.h" |
25 #include "sql/statement.h" | 25 #include "sql/statement.h" |
26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // A function like this is used by other importers in order to filter out | 30 // A function like this is used by other importers in order to filter out |
31 // URLS we don't want to import. | 31 // URLS we don't want to import. |
32 // For now it's pretty basic, but I've split it out so it's easy to slot | 32 // For now it's pretty basic, but I've split it out so it's easy to slot |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 usage.favicon_url = GURL(s.ColumnString(0)); | 170 usage.favicon_url = GURL(s.ColumnString(0)); |
171 if (!usage.favicon_url.is_valid()) | 171 if (!usage.favicon_url.is_valid()) |
172 continue; // Don't bother importing favicons with invalid URLs. | 172 continue; // Don't bother importing favicons with invalid URLs. |
173 | 173 |
174 std::vector<unsigned char> data; | 174 std::vector<unsigned char> data; |
175 s.ColumnBlobAsVector(1, &data); | 175 s.ColumnBlobAsVector(1, &data); |
176 if (data.empty()) | 176 if (data.empty()) |
177 continue; // Data definitely invalid. | 177 continue; // Data definitely invalid. |
178 | 178 |
179 if (!ReencodeFavicon(&data[0], data.size(), &usage.png_data)) | 179 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) |
180 continue; // Unable to decode. | 180 continue; // Unable to decode. |
181 | 181 |
182 usage.urls = i->second; | 182 usage.urls = i->second; |
183 favicons->push_back(usage); | 183 favicons->push_back(usage); |
184 } | 184 } |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 void SafariImporter::RecursiveReadBookmarksFolder( | 188 void SafariImporter::RecursiveReadBookmarksFolder( |
189 NSDictionary* bookmark_folder, | 189 NSDictionary* bookmark_folder, |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 if (!last_visit_str) | 390 if (!last_visit_str) |
391 continue; | 391 continue; |
392 | 392 |
393 // Convert Safari's last visit time to Unix Epoch time. | 393 // Convert Safari's last visit time to Unix Epoch time. |
394 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str); | 394 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str); |
395 row.last_visit = base::Time::FromDoubleT(seconds_since_unix_epoch); | 395 row.last_visit = base::Time::FromDoubleT(seconds_since_unix_epoch); |
396 | 396 |
397 history_items->push_back(row); | 397 history_items->push_back(row); |
398 } | 398 } |
399 } | 399 } |
OLD | NEW |