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

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

Issue 326024: Mac: remove some now-dead code and add a comment. (Closed)
Patch Set: Further changes as requested by Jeremy. Created 11 years, 2 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 SafariImporter::~SafariImporter() { 46 SafariImporter::~SafariImporter() {
47 } 47 }
48 48
49 // static 49 // static
50 bool SafariImporter::CanImport(const FilePath& library_dir, 50 bool SafariImporter::CanImport(const FilePath& library_dir,
51 uint16 *services_supported) { 51 uint16 *services_supported) {
52 DCHECK(services_supported); 52 DCHECK(services_supported);
53 *services_supported = NONE; 53 *services_supported = NONE;
54 54
55 // Import features are toggled by the following: 55 // Import features are toggled by the following:
56 // bookmarks import: existance of ~/Library/Safari/Bookmarks.plist file. 56 // bookmarks import: existence of ~/Library/Safari/Bookmarks.plist file.
57 // history import: existance of ~/Library/Safari/History.plist file. 57 // history import: existence of ~/Library/Safari/History.plist file.
58 // homepage import: existance of appropriate key in defaults.
59 FilePath safari_dir = library_dir.Append("Safari"); 58 FilePath safari_dir = library_dir.Append("Safari");
60 FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist"); 59 FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist");
61 FilePath history_path = safari_dir.Append("History.plist"); 60 FilePath history_path = safari_dir.Append("History.plist");
62 61
63 using file_util::PathExists; 62 using file_util::PathExists;
64 if (PathExists(bookmarks_path)) 63 if (PathExists(bookmarks_path))
65 *services_supported |= FAVORITES; 64 *services_supported |= FAVORITES;
66 if (PathExists(history_path)) 65 if (PathExists(history_path))
67 *services_supported |= HISTORY; 66 *services_supported |= HISTORY;
68 67
69 const scoped_nsobject<NSString> homepage_ns(
70 reinterpret_cast<const NSString*>(
71 CFPreferencesCopyAppValue(CFSTR("HomePage"),
72 CFSTR("com.apple.Safari"))));
73 if (homepage_ns.get())
74 *services_supported |= HOME_PAGE;
75
76 return *services_supported != NONE; 68 return *services_supported != NONE;
77 } 69 }
78 70
79 void SafariImporter::StartImport(ProfileInfo profile_info, 71 void SafariImporter::StartImport(ProfileInfo profile_info,
80 uint16 services_supported, 72 uint16 services_supported,
81 ImporterBridge* bridge) { 73 ImporterBridge* bridge) {
82 bridge_ = bridge; 74 bridge_ = bridge;
83 75
84 // The order here is important! 76 // The order here is important!
85 bridge_->NotifyStarted(); 77 bridge_->NotifyStarted();
86 // In keeping with import on other platforms (and for other browsers), we 78 // In keeping with import on other platforms (and for other browsers), we
87 // don't import the home page (since it may lead to a useless homepage). 79 // don't import the home page (since it may lead to a useless homepage); see
80 // crbug.com/25603.
88 if ((services_supported & HISTORY) && !cancelled()) { 81 if ((services_supported & HISTORY) && !cancelled()) {
89 bridge_->NotifyItemStarted(HISTORY); 82 bridge_->NotifyItemStarted(HISTORY);
90 ImportHistory(); 83 ImportHistory();
91 bridge_->NotifyItemEnded(HISTORY); 84 bridge_->NotifyItemEnded(HISTORY);
92 } 85 }
93 if ((services_supported & FAVORITES) && !cancelled()) { 86 if ((services_supported & FAVORITES) && !cancelled()) {
94 bridge_->NotifyItemStarted(FAVORITES); 87 bridge_->NotifyItemStarted(FAVORITES);
95 ImportBookmarks(); 88 ImportBookmarks();
96 bridge_->NotifyItemEnded(FAVORITES); 89 bridge_->NotifyItemEnded(FAVORITES);
97 } 90 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 if (!last_visit_str) 379 if (!last_visit_str)
387 continue; 380 continue;
388 381
389 // Convert Safari's last visit time to Unix Epoch time. 382 // Convert Safari's last visit time to Unix Epoch time.
390 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str); 383 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str);
391 row.set_last_visit(base::Time::FromDoubleT(seconds_since_unix_epoch)); 384 row.set_last_visit(base::Time::FromDoubleT(seconds_since_unix_epoch));
392 385
393 history_items->push_back(row); 386 history_items->push_back(row);
394 } 387 }
395 } 388 }
396
397 void SafariImporter::ImportHomepage() {
398 const scoped_nsobject<NSString> homepage_ns(
399 reinterpret_cast<const NSString*>(
400 CFPreferencesCopyAppValue(CFSTR("HomePage"),
401 CFSTR("com.apple.Safari"))));
402 if (!homepage_ns.get())
403 return;
404
405 string16 hompeage_str = base::SysNSStringToUTF16(homepage_ns.get());
406 GURL homepage(hompeage_str);
407 if (homepage.is_valid()) {
408 bridge_->AddHomePage(homepage);
409 }
410 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/safari_importer.h ('k') | chrome/browser/importer/safari_importer_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698