OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/importer/firefox3_importer.h" | 5 #include "chrome/browser/importer/firefox3_importer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 std::vector<history::URLRow> rows; | 97 std::vector<history::URLRow> rows; |
98 while (s.step() == SQLITE_ROW && !cancelled()) { | 98 while (s.step() == SQLITE_ROW && !cancelled()) { |
99 GURL url(s.column_string(0)); | 99 GURL url(s.column_string(0)); |
100 | 100 |
101 // Filter out unwanted URLs. | 101 // Filter out unwanted URLs. |
102 if (!CanImportURL(url)) | 102 if (!CanImportURL(url)) |
103 continue; | 103 continue; |
104 | 104 |
105 history::URLRow row(url); | 105 history::URLRow row(url); |
106 row.set_title(s.column_string16(1)); | 106 row.set_title(s.column_wstring(1)); |
107 row.set_visit_count(s.column_int(2)); | 107 row.set_visit_count(s.column_int(2)); |
108 row.set_hidden(s.column_int(3) == 1); | 108 row.set_hidden(s.column_int(3) == 1); |
109 row.set_typed_count(s.column_int(4)); | 109 row.set_typed_count(s.column_int(4)); |
110 row.set_last_visit(Time::FromTimeT(s.column_int64(5)/1000000)); | 110 row.set_last_visit(Time::FromTimeT(s.column_int64(5)/1000000)); |
111 | 111 |
112 rows.push_back(row); | 112 rows.push_back(row); |
113 } | 113 } |
114 if (!rows.empty() && !cancelled()) { | 114 if (!rows.empty() && !cancelled()) { |
115 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, | 115 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, |
116 &ProfileWriter::AddHistoryPage, rows)); | 116 &ProfileWriter::AddHistoryPage, rows)); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 "WHERE b.type = 2 AND b.id = ? " | 414 "WHERE b.type = 2 AND b.id = ? " |
415 "ORDER BY b.position"; | 415 "ORDER BY b.position"; |
416 if (s.prepare(db, stmt) != SQLITE_OK) | 416 if (s.prepare(db, stmt) != SQLITE_OK) |
417 return; | 417 return; |
418 | 418 |
419 s.bind_int(0, folder_id); | 419 s.bind_int(0, folder_id); |
420 if (s.step() == SQLITE_ROW) { | 420 if (s.step() == SQLITE_ROW) { |
421 BookmarkItem* item = new BookmarkItem; | 421 BookmarkItem* item = new BookmarkItem; |
422 item->parent = -1; // The top level folder has no parent. | 422 item->parent = -1; // The top level folder has no parent. |
423 item->id = folder_id; | 423 item->id = folder_id; |
424 item->title = s.column_string16(0); | 424 item->title = s.column_wstring(0); |
425 item->type = 2; | 425 item->type = 2; |
426 item->favicon = 0; | 426 item->favicon = 0; |
427 list->push_back(item); | 427 list->push_back(item); |
428 } | 428 } |
429 } | 429 } |
430 | 430 |
431 void Firefox3Importer::GetWholeBookmarkFolder(sqlite3* db, BookmarkList* list, | 431 void Firefox3Importer::GetWholeBookmarkFolder(sqlite3* db, BookmarkList* list, |
432 size_t position) { | 432 size_t position) { |
433 if (position >= list->size()) { | 433 if (position >= list->size()) { |
434 NOTREACHED(); | 434 NOTREACHED(); |
(...skipping 11 matching lines...) Expand all Loading... |
446 if (s.prepare(db, stmt) != SQLITE_OK) | 446 if (s.prepare(db, stmt) != SQLITE_OK) |
447 return; | 447 return; |
448 | 448 |
449 s.bind_int(0, (*list)[position]->id); | 449 s.bind_int(0, (*list)[position]->id); |
450 BookmarkList temp_list; | 450 BookmarkList temp_list; |
451 while (s.step() == SQLITE_ROW) { | 451 while (s.step() == SQLITE_ROW) { |
452 BookmarkItem* item = new BookmarkItem; | 452 BookmarkItem* item = new BookmarkItem; |
453 item->parent = static_cast<int>(position); | 453 item->parent = static_cast<int>(position); |
454 item->id = s.column_int(0); | 454 item->id = s.column_int(0); |
455 item->url = GURL(s.column_string(1)); | 455 item->url = GURL(s.column_string(1)); |
456 item->title = s.column_string16(2); | 456 item->title = s.column_wstring(2); |
457 item->type = s.column_int(3); | 457 item->type = s.column_int(3); |
458 item->keyword = s.column_string(4); | 458 item->keyword = s.column_string(4); |
459 item->date_added = Time::FromTimeT(s.column_int64(5)/1000000); | 459 item->date_added = Time::FromTimeT(s.column_int64(5)/1000000); |
460 item->favicon = s.column_int64(6); | 460 item->favicon = s.column_int64(6); |
461 | 461 |
462 temp_list.push_back(item); | 462 temp_list.push_back(item); |
463 } | 463 } |
464 | 464 |
465 // Appends all items to the list. | 465 // Appends all items to the list. |
466 for (BookmarkList::iterator i = temp_list.begin(); | 466 for (BookmarkList::iterator i = temp_list.begin(); |
(...skipping 30 matching lines...) Expand all Loading... |
497 | 497 |
498 if (!ReencodeFavicon(&data[0], data.size(), &usage.png_data)) | 498 if (!ReencodeFavicon(&data[0], data.size(), &usage.png_data)) |
499 continue; // Unable to decode. | 499 continue; // Unable to decode. |
500 | 500 |
501 usage.urls = i->second; | 501 usage.urls = i->second; |
502 favicons->push_back(usage); | 502 favicons->push_back(usage); |
503 } | 503 } |
504 s.reset(); | 504 s.reset(); |
505 } | 505 } |
506 } | 506 } |
OLD | NEW |