OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/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/message_loop.h" | 14 #include "base/message_loop.h" |
14 #include "base/scoped_nsobject.h" | 15 #include "base/scoped_nsobject.h" |
15 #include "base/string16.h" | 16 #include "base/string16.h" |
16 #include "base/sys_string_conversions.h" | 17 #include "base/sys_string_conversions.h" |
17 #include "base/time.h" | 18 #include "base/time.h" |
18 #include "base/values.h" | 19 #include "base/values.h" |
19 #include "chrome/browser/history/history_types.h" | 20 #include "chrome/browser/history/history_types.h" |
20 #include "chrome/browser/importer/importer_bridge.h" | 21 #include "chrome/browser/importer/importer_bridge.h" |
21 #include "chrome/browser/importer/importer_data_types.h" | 22 #include "chrome/browser/importer/importer_data_types.h" |
22 #include "chrome/common/sqlite_utils.h" | 23 #include "chrome/common/sqlite_utils.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (!rows.empty() && !cancelled()) { | 320 if (!rows.empty() && !cancelled()) { |
320 bridge_->SetHistoryItems(rows, history::SOURCE_SAFARI_IMPORTED); | 321 bridge_->SetHistoryItems(rows, history::SOURCE_SAFARI_IMPORTED); |
321 } | 322 } |
322 } | 323 } |
323 | 324 |
324 double SafariImporter::HistoryTimeToEpochTime(NSString* history_time) { | 325 double SafariImporter::HistoryTimeToEpochTime(NSString* history_time) { |
325 DCHECK(history_time); | 326 DCHECK(history_time); |
326 // Add Difference between Unix epoch and CFAbsoluteTime epoch in seconds. | 327 // Add Difference between Unix epoch and CFAbsoluteTime epoch in seconds. |
327 // Unix epoch is 1970-01-01 00:00:00.0 UTC, | 328 // Unix epoch is 1970-01-01 00:00:00.0 UTC, |
328 // CF epoch is 2001-01-01 00:00:00.0 UTC. | 329 // CF epoch is 2001-01-01 00:00:00.0 UTC. |
329 return CFStringGetDoubleValue(reinterpret_cast<CFStringRef>(history_time)) + | 330 return CFStringGetDoubleValue(base::mac::NSToCFCast(history_time)) + |
330 kCFAbsoluteTimeIntervalSince1970; | 331 kCFAbsoluteTimeIntervalSince1970; |
331 } | 332 } |
332 | 333 |
333 void SafariImporter::ParseHistoryItems( | 334 void SafariImporter::ParseHistoryItems( |
334 std::vector<history::URLRow>* history_items) { | 335 std::vector<history::URLRow>* history_items) { |
335 DCHECK(history_items); | 336 DCHECK(history_items); |
336 | 337 |
337 // Construct ~/Library/Safari/History.plist path | 338 // Construct ~/Library/Safari/History.plist path |
338 NSString* library_dir = [NSString | 339 NSString* library_dir = [NSString |
339 stringWithUTF8String:library_dir_.value().c_str()]; | 340 stringWithUTF8String:library_dir_.value().c_str()]; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 if (!last_visit_str) | 388 if (!last_visit_str) |
388 continue; | 389 continue; |
389 | 390 |
390 // Convert Safari's last visit time to Unix Epoch time. | 391 // Convert Safari's last visit time to Unix Epoch time. |
391 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str); | 392 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str); |
392 row.set_last_visit(base::Time::FromDoubleT(seconds_since_unix_epoch)); | 393 row.set_last_visit(base::Time::FromDoubleT(seconds_since_unix_epoch)); |
393 | 394 |
394 history_items->push_back(row); | 395 history_items->push_back(row); |
395 } | 396 } |
396 } | 397 } |
OLD | NEW |