OLD | NEW |
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 "chrome/browser/importer/importer_list.h" | 5 #include "chrome/browser/importer/importer_list.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 ie->source_path.clear(); | 111 ie->source_path.clear(); |
112 ie->app_path.clear(); | 112 ie->app_path.clear(); |
113 ie->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | | 113 ie->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | |
114 SEARCH_ENGINES; | 114 SEARCH_ENGINES; |
115 source_profiles_.push_back(ie); | 115 source_profiles_.push_back(ie); |
116 } | 116 } |
117 #endif | 117 #endif |
118 | 118 |
119 void ImporterList::DetectFirefoxProfiles() { | 119 void ImporterList::DetectFirefoxProfiles() { |
120 DictionaryValue root; | 120 DictionaryValue root; |
121 std::wstring ini_file = GetProfilesINI().ToWStringHack(); | 121 FilePath ini_file = GetProfilesINI(); |
122 ParseProfileINI(ini_file, &root); | 122 ParseProfileINI(ini_file, &root); |
123 | 123 |
124 std::wstring source_path; | 124 FilePath source_path; |
125 for (int i = 0; ; ++i) { | 125 for (int i = 0; ; ++i) { |
126 std::wstring current_profile = L"Profile" + IntToWString(i); | 126 std::string current_profile = "Profile" + IntToString(i); |
127 if (!root.HasKey(current_profile)) { | 127 if (!root.HasKeyASCII(current_profile)) { |
128 // Profiles are continuously numbered. So we exit when we can't | 128 // Profiles are continuously numbered. So we exit when we can't |
129 // find the i-th one. | 129 // find the i-th one. |
130 break; | 130 break; |
131 } | 131 } |
132 std::wstring is_relative, path, profile_path; | 132 std::string is_relative; |
133 if (root.GetString(current_profile + L".IsRelative", &is_relative) && | 133 string16 path16; |
134 root.GetString(current_profile + L".Path", &path)) { | 134 FilePath profile_path; |
| 135 if (root.GetStringASCII(current_profile + ".IsRelative", &is_relative) && |
| 136 root.GetString(current_profile + ".Path", &path16)) { |
135 #if defined(OS_WIN) | 137 #if defined(OS_WIN) |
136 string16 path16 = WideToUTF16Hack(path); | |
137 ReplaceSubstringsAfterOffset( | 138 ReplaceSubstringsAfterOffset( |
138 &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\")); | 139 &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\")); |
139 path.assign(UTF16ToWideHack(path16)); | |
140 #endif | 140 #endif |
| 141 FilePath path = FilePath::FromWStringHack(UTF16ToWide(path16)); |
141 | 142 |
142 // IsRelative=1 means the folder path would be relative to the | 143 // IsRelative=1 means the folder path would be relative to the |
143 // path of profiles.ini. IsRelative=0 refers to a custom profile | 144 // path of profiles.ini. IsRelative=0 refers to a custom profile |
144 // location. | 145 // location. |
145 if (is_relative == L"1") { | 146 if (is_relative == "1") { |
146 profile_path = file_util::GetDirectoryFromPath(ini_file); | 147 profile_path = ini_file.DirName().Append(path); |
147 file_util::AppendToPath(&profile_path, path); | |
148 } else { | 148 } else { |
149 profile_path = path; | 149 profile_path = path; |
150 } | 150 } |
151 | 151 |
152 // We only import the default profile when multiple profiles exist, | 152 // We only import the default profile when multiple profiles exist, |
153 // since the other profiles are used mostly by developers for testing. | 153 // since the other profiles are used mostly by developers for testing. |
154 // Otherwise, Profile0 will be imported. | 154 // Otherwise, Profile0 will be imported. |
155 std::wstring is_default; | 155 std::string is_default; |
156 if ((root.GetString(current_profile + L".Default", &is_default) && | 156 if ((root.GetStringASCII(current_profile + ".Default", &is_default) && |
157 is_default == L"1") || i == 0) { | 157 is_default == "1") || i == 0) { |
158 source_path = profile_path; | 158 source_path = profile_path; |
159 // We break out of the loop when we have found the default profile. | 159 // We break out of the loop when we have found the default profile. |
160 if (is_default == L"1") | 160 if (is_default == "1") |
161 break; | 161 break; |
162 } | 162 } |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 // Detects which version of Firefox is installed. | 166 // Detects which version of Firefox is installed. |
167 ProfileType firefox_type; | 167 ProfileType firefox_type; |
168 std::wstring app_path; | 168 FilePath app_path; |
169 int version = 0; | 169 int version = 0; |
170 #if defined(OS_WIN) | 170 #if defined(OS_WIN) |
171 version = GetCurrentFirefoxMajorVersionFromRegistry(); | 171 version = GetCurrentFirefoxMajorVersionFromRegistry(); |
172 #endif | 172 #endif |
173 if (version != 2 && version != 3) | 173 if (version != 2 && version != 3) |
174 GetFirefoxVersionAndPathFromProfile(source_path, &version, &app_path); | 174 GetFirefoxVersionAndPathFromProfile(source_path, &version, &app_path); |
175 | 175 |
176 if (version == 2) { | 176 if (version == 2) { |
177 firefox_type = FIREFOX2; | 177 firefox_type = FIREFOX2; |
178 } else if (version == 3) { | 178 } else if (version == 3) { |
179 firefox_type = FIREFOX3; | 179 firefox_type = FIREFOX3; |
180 } else { | 180 } else { |
181 // Ignores other versions of firefox. | 181 // Ignores other versions of firefox. |
182 return; | 182 return; |
183 } | 183 } |
184 | 184 |
185 if (!source_path.empty()) { | 185 if (!source_path.empty()) { |
186 ProfileInfo* firefox = new ProfileInfo(); | 186 ProfileInfo* firefox = new ProfileInfo(); |
187 firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX); | 187 firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX); |
188 firefox->browser_type = firefox_type; | 188 firefox->browser_type = firefox_type; |
189 firefox->source_path = source_path; | 189 firefox->source_path = source_path.ToWStringHack(); |
190 #if defined(OS_WIN) | 190 #if defined(OS_WIN) |
191 firefox->app_path = GetFirefoxInstallPathFromRegistry(); | 191 firefox->app_path = GetFirefoxInstallPathFromRegistry(); |
192 #endif | 192 #endif |
193 if (firefox->app_path.empty()) | 193 if (firefox->app_path.empty()) |
194 firefox->app_path = app_path; | 194 firefox->app_path = app_path.ToWStringHack(); |
195 firefox->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | | 195 firefox->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | |
196 SEARCH_ENGINES; | 196 SEARCH_ENGINES; |
197 source_profiles_.push_back(firefox); | 197 source_profiles_.push_back(firefox); |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 void ImporterList::DetectGoogleToolbarProfiles() { | 201 void ImporterList::DetectGoogleToolbarProfiles() { |
202 if (!FirstRun::IsChromeFirstRun()) { | 202 if (!FirstRun::IsChromeFirstRun()) { |
203 ProfileInfo* google_toolbar = new ProfileInfo(); | 203 ProfileInfo* google_toolbar = new ProfileInfo(); |
204 google_toolbar->browser_type = GOOGLE_TOOLBAR5; | 204 google_toolbar->browser_type = GOOGLE_TOOLBAR5; |
(...skipping 13 matching lines...) Expand all Loading... |
218 ProfileInfo* safari = new ProfileInfo(); | 218 ProfileInfo* safari = new ProfileInfo(); |
219 safari->browser_type = SAFARI; | 219 safari->browser_type = SAFARI; |
220 safari->description = l10n_util::GetString(IDS_IMPORT_FROM_SAFARI); | 220 safari->description = l10n_util::GetString(IDS_IMPORT_FROM_SAFARI); |
221 safari->source_path.clear(); | 221 safari->source_path.clear(); |
222 safari->app_path.clear(); | 222 safari->app_path.clear(); |
223 safari->services_supported = items; | 223 safari->services_supported = items; |
224 source_profiles_.push_back(safari); | 224 source_profiles_.push_back(safari); |
225 } | 225 } |
226 } | 226 } |
227 #endif // OS_MACOSX | 227 #endif // OS_MACOSX |
OLD | NEW |