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

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

Issue 164442: Fix early return/DCHECK importing Safari bookmarks. (Closed)
Patch Set: Created 11 years, 4 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
« no previous file with comments | « no previous file | 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) 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 NSString* type = [bookmark_folder objectForKey:@"WebBookmarkType"]; 173 NSString* type = [bookmark_folder objectForKey:@"WebBookmarkType"];
174 NSString* title = [bookmark_folder objectForKey:@"Title"]; 174 NSString* title = [bookmark_folder objectForKey:@"Title"];
175 175
176 // Are we the dictionary that contains all other bookmarks? 176 // Are we the dictionary that contains all other bookmarks?
177 // We need to know this so we don't add it to the path. 177 // We need to know this so we don't add it to the path.
178 bool is_top_level_bookmarks_container = [bookmark_folder 178 bool is_top_level_bookmarks_container = [bookmark_folder
179 objectForKey:@"WebBookmarkFileVersion"] != nil; 179 objectForKey:@"WebBookmarkFileVersion"] != nil;
180 180
181 // We're expecting a list of bookmarks here, if that isn't what we got, fail. 181 // We're expecting a list of bookmarks here, if that isn't what we got, fail.
182 if (![type isEqualToString:@"WebBookmarkTypeList"] || !title) { 182 if (!is_top_level_bookmarks_container) {
183 DCHECK(false) << "Type =(" 183 // Top level containers sometimes don't have title attributes.
184 << (type ? base::SysNSStringToUTF8(type) : "Null Type") 184 if (![type isEqualToString:@"WebBookmarkTypeList"] || !title) {
185 << ") Title=(" << (title ? base::SysNSStringToUTF8(title) : "Null title") 185 DCHECK(false) << "Type =("
186 << ")"; 186 << (type ? base::SysNSStringToUTF8(type) : "Null Type")
187 return; 187 << ") Title=(" << (title ? base::SysNSStringToUTF8(title) : "Null title")
188 << ")";
189 return;
190 }
188 } 191 }
189 192
190 std::vector<std::wstring> path_elements(parent_path_elements); 193 std::vector<std::wstring> path_elements(parent_path_elements);
191 // Is this the toolbar folder? 194 // Is this the toolbar folder?
192 if ([title isEqualToString:@"BookmarksBar"]) { 195 if ([title isEqualToString:@"BookmarksBar"]) {
193 // Be defensive, the toolbar items shouldn't have a prepended path. 196 // Be defensive, the toolbar items shouldn't have a prepended path.
194 path_elements.clear(); 197 path_elements.clear();
195 is_in_toolbar = true; 198 is_in_toolbar = true;
196 } else if ([title isEqualToString:@"BookmarksMenu"]) { 199 } else if ([title isEqualToString:@"BookmarksMenu"]) {
197 // top level container for normal bookmarks. 200 // top level container for normal bookmarks.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 if (!homepage_ns.get()) 372 if (!homepage_ns.get())
370 return; 373 return;
371 374
372 string16 hompeage_str = base::SysNSStringToUTF16(homepage_ns.get()); 375 string16 hompeage_str = base::SysNSStringToUTF16(homepage_ns.get());
373 GURL homepage(hompeage_str); 376 GURL homepage(hompeage_str);
374 if (homepage.is_valid()) { 377 if (homepage.is_valid()) {
375 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, 378 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
376 &ProfileWriter::AddHomepage, homepage)); 379 &ProfileWriter::AddHomepage, homepage));
377 } 380 }
378 } 381 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698