OLD | NEW |
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 "chrome/browser/importer/ie_importer.h" | 5 #include "chrome/browser/importer/ie_importer.h" |
6 | 6 |
7 #include <ole2.h> | 7 #include <ole2.h> |
8 #include <intshcut.h> | 8 #include <intshcut.h> |
9 #include <pstore.h> | 9 #include <pstore.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 GURL url = GURL(ResolveInternetShortcut(*it)); | 519 GURL url = GURL(ResolveInternetShortcut(*it)); |
520 if (!url.is_valid()) | 520 if (!url.is_valid()) |
521 continue; | 521 continue; |
522 | 522 |
523 // Make the relative path from the Favorites folder, without the basename. | 523 // Make the relative path from the Favorites folder, without the basename. |
524 // ex. Suppose that the Favorites folder is C:\Users\Foo\Favorites. | 524 // ex. Suppose that the Favorites folder is C:\Users\Foo\Favorites. |
525 // C:\Users\Foo\Favorites\Foo.url -> "" | 525 // C:\Users\Foo\Favorites\Foo.url -> "" |
526 // C:\Users\Foo\Favorites\Links\Bar\Baz.url -> "Links\Bar" | 526 // C:\Users\Foo\Favorites\Links\Bar\Baz.url -> "Links\Bar" |
527 FilePath::StringType relative_string = | 527 FilePath::StringType relative_string = |
528 shortcut.DirName().value().substr(favorites_path_len); | 528 shortcut.DirName().value().substr(favorites_path_len); |
529 if (relative_string.size() > 0 && FilePath::IsSeparator(relative_string[0])) | 529 if (!relative_string.empty() && FilePath::IsSeparator(relative_string[0])) |
530 relative_string = relative_string.substr(1); | 530 relative_string = relative_string.substr(1); |
531 FilePath relative_path(relative_string); | 531 FilePath relative_path(relative_string); |
532 | 532 |
533 ProfileWriter::BookmarkEntry entry; | 533 ProfileWriter::BookmarkEntry entry; |
534 // Remove the dot, the file extension, and the directory path. | 534 // Remove the dot, the file extension, and the directory path. |
535 entry.title = shortcut.RemoveExtension().BaseName().value(); | 535 entry.title = shortcut.RemoveExtension().BaseName().value(); |
536 entry.url = url; | 536 entry.url = url; |
537 entry.creation_time = GetFileCreationTime(*it); | 537 entry.creation_time = GetFileCreationTime(*it); |
538 if (!relative_path.empty()) | 538 if (!relative_path.empty()) |
539 relative_path.GetComponents(&entry.path); | 539 relative_path.GetComponents(&entry.path); |
540 | 540 |
541 // Flatten the bookmarks in Link folder onto bookmark toolbar. Otherwise, | 541 // Flatten the bookmarks in Link folder onto bookmark toolbar. Otherwise, |
542 // put it into "Other bookmarks". | 542 // put it into "Other bookmarks". |
543 if (import_to_bookmark_bar() && | 543 if (import_to_bookmark_bar() && |
544 (entry.path.size() > 0 && entry.path[0] == info.links_folder)) { | 544 (!entry.path.empty() && entry.path[0] == info.links_folder)) { |
545 entry.in_toolbar = true; | 545 entry.in_toolbar = true; |
546 entry.path.erase(entry.path.begin()); | 546 entry.path.erase(entry.path.begin()); |
547 toolbar_bookmarks.push_back(entry); | 547 toolbar_bookmarks.push_back(entry); |
548 } else { | 548 } else { |
549 // We put the bookmarks in a "Imported From IE" | 549 // We put the bookmarks in a "Imported From IE" |
550 // folder, so that we don't mess up the "Other bookmarks". | 550 // folder, so that we don't mess up the "Other bookmarks". |
551 if (!import_to_bookmark_bar()) | 551 if (!import_to_bookmark_bar()) |
552 entry.path.insert(entry.path.begin(), ie_folder); | 552 entry.path.insert(entry.path.begin(), ie_folder); |
553 bookmarks->push_back(entry); | 553 bookmarks->push_back(entry); |
554 } | 554 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 if (version < 0) { | 588 if (version < 0) { |
589 wchar_t buffer[128]; | 589 wchar_t buffer[128]; |
590 DWORD buffer_length = sizeof(buffer); | 590 DWORD buffer_length = sizeof(buffer); |
591 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, | 591 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, |
592 L"Software\\Microsoft\\Internet Explorer", KEY_READ); | 592 L"Software\\Microsoft\\Internet Explorer", KEY_READ); |
593 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 593 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
594 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 594 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
595 } | 595 } |
596 return version; | 596 return version; |
597 } | 597 } |
OLD | NEW |