| 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/importer.h" | 5 #include "chrome/browser/importer/importer.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 ProfileType firefox_type; | 640 ProfileType firefox_type; |
| 641 if (version == 2) { | 641 if (version == 2) { |
| 642 firefox_type = FIREFOX2; | 642 firefox_type = FIREFOX2; |
| 643 } else if (version == 3) { | 643 } else if (version == 3) { |
| 644 firefox_type = FIREFOX3; | 644 firefox_type = FIREFOX3; |
| 645 } else { | 645 } else { |
| 646 // Ignores other versions of firefox. | 646 // Ignores other versions of firefox. |
| 647 return; | 647 return; |
| 648 } | 648 } |
| 649 | 649 |
| 650 DictionaryValue root; |
| 651 #if defined(OS_WIN) |
| 650 std::wstring ini_file = GetProfilesINI(); | 652 std::wstring ini_file = GetProfilesINI(); |
| 651 DictionaryValue root; | |
| 652 ParseProfileINI(ini_file, &root); | 653 ParseProfileINI(ini_file, &root); |
| 654 #else |
| 655 // TODO(port): Do we need to concern ourselves with profiles on posix? |
| 656 NOTIMPLEMENTED(); |
| 657 #endif |
| 653 | 658 |
| 654 std::wstring source_path; | 659 std::wstring source_path; |
| 655 for (int i = 0; ; ++i) { | 660 for (int i = 0; ; ++i) { |
| 656 std::wstring current_profile = L"Profile" + IntToWString(i); | 661 std::wstring current_profile = L"Profile" + IntToWString(i); |
| 657 if (!root.HasKey(current_profile)) { | 662 if (!root.HasKey(current_profile)) { |
| 658 // Profiles are continuously numbered. So we exit when we can't | 663 // Profiles are continuously numbered. So we exit when we can't |
| 659 // find the i-th one. | 664 // find the i-th one. |
| 660 break; | 665 break; |
| 661 } | 666 } |
| 662 std::wstring is_relative, path, profile_path; | 667 std::wstring is_relative, path, profile_path; |
| 663 if (root.GetString(current_profile + L".IsRelative", &is_relative) && | 668 if (root.GetString(current_profile + L".IsRelative", &is_relative) && |
| 664 root.GetString(current_profile + L".Path", &path)) { | 669 root.GetString(current_profile + L".Path", &path)) { |
| 665 ReplaceSubstringsAfterOffset(&path, 0, L"/", L"\\"); | 670 ReplaceSubstringsAfterOffset(&path, 0, L"/", L"\\"); |
| 666 | 671 |
| 672 #if defined(OS_WIN) |
| 667 // IsRelative=1 means the folder path would be relative to the | 673 // IsRelative=1 means the folder path would be relative to the |
| 668 // path of profiles.ini. IsRelative=0 refers to a custom profile | 674 // path of profiles.ini. IsRelative=0 refers to a custom profile |
| 669 // location. | 675 // location. |
| 670 if (is_relative == L"1") { | 676 if (is_relative == L"1") { |
| 671 profile_path = file_util::GetDirectoryFromPath(ini_file); | 677 profile_path = file_util::GetDirectoryFromPath(ini_file); |
| 672 file_util::AppendToPath(&profile_path, path); | 678 file_util::AppendToPath(&profile_path, path); |
| 673 } else { | 679 } else { |
| 674 profile_path = path; | 680 profile_path = path; |
| 675 } | 681 } |
| 682 #endif |
| 676 | 683 |
| 677 // We only import the default profile when multiple profiles exist, | 684 // We only import the default profile when multiple profiles exist, |
| 678 // since the other profiles are used mostly by developers for testing. | 685 // since the other profiles are used mostly by developers for testing. |
| 679 // Otherwise, Profile0 will be imported. | 686 // Otherwise, Profile0 will be imported. |
| 680 std::wstring is_default; | 687 std::wstring is_default; |
| 681 if ((root.GetString(current_profile + L".Default", &is_default) && | 688 if ((root.GetString(current_profile + L".Default", &is_default) && |
| 682 is_default == L"1") || i == 0) { | 689 is_default == L"1") || i == 0) { |
| 683 source_path = profile_path; | 690 source_path = profile_path; |
| 684 // We break out of the loop when we have found the default profile. | 691 // We break out of the loop when we have found the default profile. |
| 685 if (is_default == L"1") | 692 if (is_default == L"1") |
| 686 break; | 693 break; |
| 687 } | 694 } |
| 688 } | 695 } |
| 689 } | 696 } |
| 690 | 697 |
| 691 if (!source_path.empty()) { | 698 if (!source_path.empty()) { |
| 692 ProfileInfo* firefox = new ProfileInfo(); | 699 ProfileInfo* firefox = new ProfileInfo(); |
| 693 firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX); | 700 firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX); |
| 694 firefox->browser_type = firefox_type; | 701 firefox->browser_type = firefox_type; |
| 695 firefox->source_path = source_path; | 702 firefox->source_path = source_path; |
| 696 firefox->app_path = GetFirefoxInstallPath(); | 703 firefox->app_path = GetFirefoxInstallPath(); |
| 697 firefox->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | | 704 firefox->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | |
| 698 SEARCH_ENGINES; | 705 SEARCH_ENGINES; |
| 699 source_profiles_.push_back(firefox); | 706 source_profiles_.push_back(firefox); |
| 700 } | 707 } |
| 701 } | 708 } |
| OLD | NEW |