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

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

Issue 6746014: importer: Cleanup, remove all remaining using declarations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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
« no previous file with comments | « chrome/browser/importer/nss_decryptor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 DCHECK(services_supported); 54 DCHECK(services_supported);
55 *services_supported = importer::NONE; 55 *services_supported = importer::NONE;
56 56
57 // Import features are toggled by the following: 57 // Import features are toggled by the following:
58 // bookmarks import: existence of ~/Library/Safari/Bookmarks.plist file. 58 // bookmarks import: existence of ~/Library/Safari/Bookmarks.plist file.
59 // history import: existence of ~/Library/Safari/History.plist file. 59 // history import: existence of ~/Library/Safari/History.plist file.
60 FilePath safari_dir = library_dir.Append("Safari"); 60 FilePath safari_dir = library_dir.Append("Safari");
61 FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist"); 61 FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist");
62 FilePath history_path = safari_dir.Append("History.plist"); 62 FilePath history_path = safari_dir.Append("History.plist");
63 63
64 using file_util::PathExists; 64 if (file_util::PathExists(bookmarks_path))
65 if (PathExists(bookmarks_path))
66 *services_supported |= importer::FAVORITES; 65 *services_supported |= importer::FAVORITES;
67 if (PathExists(history_path)) 66 if (file_util::PathExists(history_path))
68 *services_supported |= importer::HISTORY; 67 *services_supported |= importer::HISTORY;
69 68
70 return *services_supported != importer::NONE; 69 return *services_supported != importer::NONE;
71 } 70 }
72 71
73 void SafariImporter::StartImport(const importer::ProfileInfo& profile_info, 72 void SafariImporter::StartImport(const importer::ProfileInfo& profile_info,
74 uint16 services_supported, 73 uint16 services_supported,
75 ImporterBridge* bridge) { 74 ImporterBridge* bridge) {
76 bridge_ = bridge; 75 bridge_ = bridge;
77 // The order here is important! 76 // The order here is important!
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // Load the plist file. 338 // Load the plist file.
340 NSDictionary* history_dict = [NSDictionary 339 NSDictionary* history_dict = [NSDictionary
341 dictionaryWithContentsOfFile:history_plist]; 340 dictionaryWithContentsOfFile:history_plist];
342 if (!history_dict) 341 if (!history_dict)
343 return; 342 return;
344 343
345 NSArray* safari_history_items = [history_dict 344 NSArray* safari_history_items = [history_dict
346 objectForKey:@"WebHistoryDates"]; 345 objectForKey:@"WebHistoryDates"];
347 346
348 for (NSDictionary* history_item in safari_history_items) { 347 for (NSDictionary* history_item in safari_history_items) {
349 using base::SysNSStringToUTF8;
350 using base::SysNSStringToUTF16;
351 NSString* url_ns = [history_item objectForKey:@""]; 348 NSString* url_ns = [history_item objectForKey:@""];
352 if (!url_ns) 349 if (!url_ns)
353 continue; 350 continue;
354 351
355 GURL url(SysNSStringToUTF8(url_ns)); 352 GURL url(base::SysNSStringToUTF8(url_ns));
356 353
357 if (!CanImportSafariURL(url)) 354 if (!CanImportSafariURL(url))
358 continue; 355 continue;
359 356
360 history::URLRow row(url); 357 history::URLRow row(url);
361 NSString* title_ns = [history_item objectForKey:@"title"]; 358 NSString* title_ns = [history_item objectForKey:@"title"];
362 359
363 // Sometimes items don't have a title, in which case we just substitue 360 // Sometimes items don't have a title, in which case we just substitue
364 // the url. 361 // the url.
365 if (!title_ns) 362 if (!title_ns)
366 title_ns = url_ns; 363 title_ns = url_ns;
367 364
368 row.set_title(SysNSStringToUTF16(title_ns)); 365 row.set_title(base::SysNSStringToUTF16(title_ns));
369 int visit_count = [[history_item objectForKey:@"visitCount"] 366 int visit_count = [[history_item objectForKey:@"visitCount"]
370 intValue]; 367 intValue];
371 row.set_visit_count(visit_count); 368 row.set_visit_count(visit_count);
372 // Include imported URLs in autocompletion - don't hide them. 369 // Include imported URLs in autocompletion - don't hide them.
373 row.set_hidden(0); 370 row.set_hidden(0);
374 // Item was never typed before in the omnibox. 371 // Item was never typed before in the omnibox.
375 row.set_typed_count(0); 372 row.set_typed_count(0);
376 373
377 NSString* last_visit_str = [history_item objectForKey:@"lastVisitedDate"]; 374 NSString* last_visit_str = [history_item objectForKey:@"lastVisitedDate"];
378 // The last visit time should always be in the history item, but if not 375 // The last visit time should always be in the history item, but if not
379 /// just continue without this item. 376 /// just continue without this item.
380 DCHECK(last_visit_str); 377 DCHECK(last_visit_str);
381 if (!last_visit_str) 378 if (!last_visit_str)
382 continue; 379 continue;
383 380
384 // Convert Safari's last visit time to Unix Epoch time. 381 // Convert Safari's last visit time to Unix Epoch time.
385 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str); 382 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str);
386 row.set_last_visit(base::Time::FromDoubleT(seconds_since_unix_epoch)); 383 row.set_last_visit(base::Time::FromDoubleT(seconds_since_unix_epoch));
387 384
388 history_items->push_back(row); 385 history_items->push_back(row);
389 } 386 }
390 } 387 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/nss_decryptor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698