Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/utility/importer/safari_importer.mm

Issue 19251002: move SafariImporter::CanImport to common (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/utility/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>
(...skipping 30 matching lines...) Expand all
41 41
42 } // namespace 42 } // namespace
43 43
44 SafariImporter::SafariImporter(const base::FilePath& library_dir) 44 SafariImporter::SafariImporter(const base::FilePath& library_dir)
45 : library_dir_(library_dir) { 45 : library_dir_(library_dir) {
46 } 46 }
47 47
48 SafariImporter::~SafariImporter() { 48 SafariImporter::~SafariImporter() {
49 } 49 }
50 50
51 // static
52 bool SafariImporter::CanImport(const base::FilePath& library_dir,
53 uint16* services_supported) {
54 DCHECK(services_supported);
55 *services_supported = importer::NONE;
56
57 // Import features are toggled by the following:
58 // bookmarks import: existence of ~/Library/Safari/Bookmarks.plist file.
59 // history import: existence of ~/Library/Safari/History.plist file.
60 base::FilePath safari_dir = library_dir.Append("Safari");
61 base::FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist");
62 base::FilePath history_path = safari_dir.Append("History.plist");
63
64 if (base::PathExists(bookmarks_path))
65 *services_supported |= importer::FAVORITES;
66 if (base::PathExists(history_path))
67 *services_supported |= importer::HISTORY;
68
69 return *services_supported != importer::NONE;
70 }
71
72 void SafariImporter::StartImport(const importer::SourceProfile& source_profile, 51 void SafariImporter::StartImport(const importer::SourceProfile& source_profile,
73 uint16 items, 52 uint16 items,
74 ImporterBridge* bridge) { 53 ImporterBridge* bridge) {
75 bridge_ = bridge; 54 bridge_ = bridge;
76 // The order here is important! 55 // The order here is important!
77 bridge_->NotifyStarted(); 56 bridge_->NotifyStarted();
78 57
79 // In keeping with import on other platforms (and for other browsers), we 58 // In keeping with import on other platforms (and for other browsers), we
80 // don't import the home page (since it may lead to a useless homepage); see 59 // don't import the home page (since it may lead to a useless homepage); see
81 // crbug.com/25603. 60 // crbug.com/25603.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (!last_visit_str) 369 if (!last_visit_str)
391 continue; 370 continue;
392 371
393 // Convert Safari's last visit time to Unix Epoch time. 372 // Convert Safari's last visit time to Unix Epoch time.
394 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str); 373 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str);
395 row.last_visit = base::Time::FromDoubleT(seconds_since_unix_epoch); 374 row.last_visit = base::Time::FromDoubleT(seconds_since_unix_epoch);
396 375
397 history_items->push_back(row); 376 history_items->push_back(row);
398 } 377 }
399 } 378 }
OLDNEW
« no previous file with comments | « chrome/utility/importer/safari_importer.h ('k') | chrome/utility/importer/safari_importer_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698