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

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

Issue 119833002: [Import] [OSX] Don't create an empty folder when importing from Safari with an empty Bookmarks Menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove extraneous files, update READMEs Created 6 years, 11 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 NOTREACHED() << "Type=(" 187 NOTREACHED() << "Type=("
188 << (type ? base::SysNSStringToUTF8(type) : "Null type") 188 << (type ? base::SysNSStringToUTF8(type) : "Null type")
189 << ") Title=(" 189 << ") Title=("
190 << (title ? base::SysNSStringToUTF8(title) : "Null title") 190 << (title ? base::SysNSStringToUTF8(title) : "Null title")
191 << ")"; 191 << ")";
192 return; 192 return;
193 } 193 }
194 } 194 }
195 195
196 NSArray* elements = [bookmark_folder objectForKey:@"Children"]; 196 NSArray* elements = [bookmark_folder objectForKey:@"Children"];
197 if (!elements && (!parent_path_elements.empty() || !is_in_toolbar)) { 197 if (!elements &&
198 // This is an empty folder, so add it explicitly; but don't add the toolbar 198 (!parent_path_elements.empty() || !is_in_toolbar) &&
199 // folder if it is empty. Note that all non-empty folders are added 199 ![title isEqualToString:@"BookmarksMenu"]) {
200 // This is an empty folder, so add it explicitly. Note that the condition
201 // above prevents either the toolbar folder or the bookmarks menu from being
202 // added if either is empty. Note also that all non-empty folders are added
200 // implicitly when their children are added. 203 // implicitly when their children are added.
201 ImportedBookmarkEntry entry; 204 ImportedBookmarkEntry entry;
202 // Safari doesn't specify a creation time for the folder. 205 // Safari doesn't specify a creation time for the folder.
203 entry.creation_time = base::Time::Now(); 206 entry.creation_time = base::Time::Now();
204 entry.title = base::SysNSStringToUTF16(title); 207 entry.title = base::SysNSStringToUTF16(title);
205 entry.path = parent_path_elements; 208 entry.path = parent_path_elements;
206 entry.in_toolbar = is_in_toolbar; 209 entry.in_toolbar = is_in_toolbar;
207 entry.is_folder = true; 210 entry.is_folder = true;
208 211
209 out_bookmarks->push_back(entry); 212 out_bookmarks->push_back(entry);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 if (!last_visit_str) 372 if (!last_visit_str)
370 continue; 373 continue;
371 374
372 // Convert Safari's last visit time to Unix Epoch time. 375 // Convert Safari's last visit time to Unix Epoch time.
373 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str); 376 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str);
374 row.last_visit = base::Time::FromDoubleT(seconds_since_unix_epoch); 377 row.last_visit = base::Time::FromDoubleT(seconds_since_unix_epoch);
375 378
376 history_items->push_back(row); 379 history_items->push_back(row);
377 } 380 }
378 } 381 }
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