| 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 "app/gfx/favicon_size.h" | 10 #include "app/gfx/favicon_size.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 profile_info.browser_type == FIREFOX3) { | 508 profile_info.browser_type == FIREFOX3) { |
| 509 firefox_lock_.reset(new FirefoxProfileLock(profile_info.source_path)); | 509 firefox_lock_.reset(new FirefoxProfileLock(profile_info.source_path)); |
| 510 if (!firefox_lock_->HasAcquired()) { | 510 if (!firefox_lock_->HasAcquired()) { |
| 511 // If fail to acquire the lock, we set the source unreadable and | 511 // If fail to acquire the lock, we set the source unreadable and |
| 512 // show a warning dialog. | 512 // show a warning dialog. |
| 513 is_source_readable_ = false; | 513 is_source_readable_ = false; |
| 514 ShowWarningDialog(); | 514 ShowWarningDialog(); |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 | 517 |
| 518 #if defined(OS_WIN) | 518 #if defined(OS_WIN) |
| 519 // For google toolbar import, we need the user to log in and store their GAIA | 519 // For google toolbar import, we need the user to log in and store their GAIA |
| 520 // credentials. | 520 // credentials. |
| 521 if (profile_info.browser_type == GOOGLE_TOOLBAR5) { | 521 if (profile_info.browser_type == GOOGLE_TOOLBAR5) { |
| 522 if (!toolbar_importer_utils::IsGoogleGAIACookieInstalled()) { | 522 if (!toolbar_importer_utils::IsGoogleGAIACookieInstalled()) { |
| 523 win_util::MessageBox( | 523 win_util::MessageBox( |
| 524 NULL, | 524 NULL, |
| 525 l10n_util::GetString(IDS_IMPORTER_GOOGLE_LOGIN_TEXT).c_str(), | 525 l10n_util::GetString(IDS_IMPORTER_GOOGLE_LOGIN_TEXT).c_str(), |
| 526 L"", | 526 L"", |
| 527 MB_OK | MB_TOPMOST); | 527 MB_OK | MB_TOPMOST); |
| 528 | 528 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 ie->browser_type = MS_IE; | 670 ie->browser_type = MS_IE; |
| 671 ie->source_path.clear(); | 671 ie->source_path.clear(); |
| 672 ie->app_path.clear(); | 672 ie->app_path.clear(); |
| 673 ie->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | | 673 ie->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | |
| 674 SEARCH_ENGINES; | 674 SEARCH_ENGINES; |
| 675 source_profiles_.push_back(ie); | 675 source_profiles_.push_back(ie); |
| 676 } | 676 } |
| 677 #endif | 677 #endif |
| 678 | 678 |
| 679 void ImporterHost::DetectFirefoxProfiles() { | 679 void ImporterHost::DetectFirefoxProfiles() { |
| 680 // Detects which version of Firefox is installed. | 680 #if defined(OS_MACOSX) |
| 681 int version = GetCurrentFirefoxMajorVersion(); | 681 NOTIMPLEMENTED(); |
| 682 ProfileType firefox_type; | 682 #else |
| 683 if (version == 2) { | |
| 684 firefox_type = FIREFOX2; | |
| 685 } else if (version == 3) { | |
| 686 firefox_type = FIREFOX3; | |
| 687 } else { | |
| 688 // Ignores other versions of firefox. | |
| 689 return; | |
| 690 } | |
| 691 | |
| 692 DictionaryValue root; | 683 DictionaryValue root; |
| 693 #if defined(OS_WIN) | 684 std::wstring ini_file = GetProfilesINI().ToWStringHack(); |
| 694 std::wstring ini_file = GetProfilesINI(); | |
| 695 ParseProfileINI(ini_file, &root); | 685 ParseProfileINI(ini_file, &root); |
| 696 #else | |
| 697 // TODO(port): Do we need to concern ourselves with profiles on posix? | |
| 698 NOTIMPLEMENTED(); | |
| 699 #endif | |
| 700 | 686 |
| 701 std::wstring source_path; | 687 std::wstring source_path; |
| 702 for (int i = 0; ; ++i) { | 688 for (int i = 0; ; ++i) { |
| 703 std::wstring current_profile = L"Profile" + IntToWString(i); | 689 std::wstring current_profile = L"Profile" + IntToWString(i); |
| 704 if (!root.HasKey(current_profile)) { | 690 if (!root.HasKey(current_profile)) { |
| 705 // Profiles are continuously numbered. So we exit when we can't | 691 // Profiles are continuously numbered. So we exit when we can't |
| 706 // find the i-th one. | 692 // find the i-th one. |
| 707 break; | 693 break; |
| 708 } | 694 } |
| 709 std::wstring is_relative, path, profile_path; | 695 std::wstring is_relative, path, profile_path; |
| 710 if (root.GetString(current_profile + L".IsRelative", &is_relative) && | 696 if (root.GetString(current_profile + L".IsRelative", &is_relative) && |
| 711 root.GetString(current_profile + L".Path", &path)) { | 697 root.GetString(current_profile + L".Path", &path)) { |
| 712 string16 path16 = WideToUTF16Hack(path); | 698 string16 path16 = WideToUTF16Hack(path); |
| 713 ReplaceSubstringsAfterOffset( | 699 ReplaceSubstringsAfterOffset( |
| 714 &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\")); | 700 &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\")); |
| 715 path.assign(UTF16ToWideHack(path16)); | 701 path.assign(UTF16ToWideHack(path16)); |
| 716 | 702 |
| 717 #if defined(OS_WIN) | |
| 718 // IsRelative=1 means the folder path would be relative to the | 703 // IsRelative=1 means the folder path would be relative to the |
| 719 // path of profiles.ini. IsRelative=0 refers to a custom profile | 704 // path of profiles.ini. IsRelative=0 refers to a custom profile |
| 720 // location. | 705 // location. |
| 721 if (is_relative == L"1") { | 706 if (is_relative == L"1") { |
| 722 profile_path = file_util::GetDirectoryFromPath(ini_file); | 707 profile_path = file_util::GetDirectoryFromPath(ini_file); |
| 723 file_util::AppendToPath(&profile_path, path); | 708 file_util::AppendToPath(&profile_path, path); |
| 724 } else { | 709 } else { |
| 725 profile_path = path; | 710 profile_path = path; |
| 726 } | 711 } |
| 727 #endif | |
| 728 | 712 |
| 729 // We only import the default profile when multiple profiles exist, | 713 // We only import the default profile when multiple profiles exist, |
| 730 // since the other profiles are used mostly by developers for testing. | 714 // since the other profiles are used mostly by developers for testing. |
| 731 // Otherwise, Profile0 will be imported. | 715 // Otherwise, Profile0 will be imported. |
| 732 std::wstring is_default; | 716 std::wstring is_default; |
| 733 if ((root.GetString(current_profile + L".Default", &is_default) && | 717 if ((root.GetString(current_profile + L".Default", &is_default) && |
| 734 is_default == L"1") || i == 0) { | 718 is_default == L"1") || i == 0) { |
| 735 source_path = profile_path; | 719 source_path = profile_path; |
| 736 // We break out of the loop when we have found the default profile. | 720 // We break out of the loop when we have found the default profile. |
| 737 if (is_default == L"1") | 721 if (is_default == L"1") |
| 738 break; | 722 break; |
| 739 } | 723 } |
| 740 } | 724 } |
| 741 } | 725 } |
| 742 | 726 |
| 727 // Detects which version of Firefox is installed. |
| 728 ProfileType firefox_type; |
| 729 std::wstring app_path; |
| 730 int version = GetCurrentFirefoxMajorVersion(); |
| 731 if (version != 2 && version != 3) |
| 732 GetFirefoxVersionAndPathFromProfile(source_path, &version, &app_path); |
| 733 if (version == 2) { |
| 734 firefox_type = FIREFOX2; |
| 735 } else if (version == 3) { |
| 736 firefox_type = FIREFOX3; |
| 737 } else { |
| 738 // Ignores other versions of firefox. |
| 739 return; |
| 740 } |
| 741 |
| 743 if (!source_path.empty()) { | 742 if (!source_path.empty()) { |
| 744 ProfileInfo* firefox = new ProfileInfo(); | 743 ProfileInfo* firefox = new ProfileInfo(); |
| 745 firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX); | 744 firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX); |
| 746 firefox->browser_type = firefox_type; | 745 firefox->browser_type = firefox_type; |
| 747 firefox->source_path = source_path; | 746 firefox->source_path = source_path; |
| 748 firefox->app_path = GetFirefoxInstallPath(); | 747 firefox->app_path = GetFirefoxInstallPath(); |
| 748 if (firefox->app_path.empty()) |
| 749 firefox->app_path = app_path; |
| 749 firefox->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | | 750 firefox->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | |
| 750 SEARCH_ENGINES; | 751 SEARCH_ENGINES; |
| 751 source_profiles_.push_back(firefox); | 752 source_profiles_.push_back(firefox); |
| 752 } | 753 } |
| 754 #endif |
| 753 } | 755 } |
| 754 | 756 |
| 755 void ImporterHost::DetectGoogleToolbarProfiles() { | 757 void ImporterHost::DetectGoogleToolbarProfiles() { |
| 756 if (!FirstRun::IsChromeFirstRun()) { | 758 if (!FirstRun::IsChromeFirstRun()) { |
| 757 ProfileInfo* google_toolbar = new ProfileInfo(); | 759 ProfileInfo* google_toolbar = new ProfileInfo(); |
| 758 google_toolbar->browser_type = GOOGLE_TOOLBAR5; | 760 google_toolbar->browser_type = GOOGLE_TOOLBAR5; |
| 759 google_toolbar->description = l10n_util::GetString( | 761 google_toolbar->description = l10n_util::GetString( |
| 760 IDS_IMPORT_FROM_GOOGLE_TOOLBAR); | 762 IDS_IMPORT_FROM_GOOGLE_TOOLBAR); |
| 761 google_toolbar->source_path.clear(); | 763 google_toolbar->source_path.clear(); |
| 762 google_toolbar->app_path.clear(); | 764 google_toolbar->app_path.clear(); |
| 763 google_toolbar->services_supported = FAVORITES; | 765 google_toolbar->services_supported = FAVORITES; |
| 764 source_profiles_.push_back(google_toolbar); | 766 source_profiles_.push_back(google_toolbar); |
| 765 } | 767 } |
| 766 } | 768 } |
| OLD | NEW |