| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/firefox_importer_utils.h" | 5 #include "chrome/browser/importer/firefox_importer_utils.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // Profile=mozilla/firefox | 314 // Profile=mozilla/firefox |
| 315 // Version=3.5.16 | 315 // Version=3.5.16 |
| 316 // BuildID=20120421070307 | 316 // BuildID=20120421070307 |
| 317 // Copyright=Copyright (c) 1998 - 2010 mozilla.org | 317 // Copyright=Copyright (c) 1998 - 2010 mozilla.org |
| 318 // ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384} | 318 // ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384} |
| 319 // ......................................... | 319 // ......................................... |
| 320 // In this example the function returns "Iceweasel" (or a localized equivalent). | 320 // In this example the function returns "Iceweasel" (or a localized equivalent). |
| 321 string16 GetFirefoxImporterName(const base::FilePath& app_path) { | 321 string16 GetFirefoxImporterName(const base::FilePath& app_path) { |
| 322 const base::FilePath app_ini_file = app_path.AppendASCII("application.ini"); | 322 const base::FilePath app_ini_file = app_path.AppendASCII("application.ini"); |
| 323 std::string branding_name; | 323 std::string branding_name; |
| 324 if (file_util::PathExists(app_ini_file)) { | 324 if (base::PathExists(app_ini_file)) { |
| 325 std::string content; | 325 std::string content; |
| 326 file_util::ReadFileToString(app_ini_file, &content); | 326 file_util::ReadFileToString(app_ini_file, &content); |
| 327 std::vector<std::string> lines; | 327 std::vector<std::string> lines; |
| 328 base::SplitString(content, '\n', &lines); | 328 base::SplitString(content, '\n', &lines); |
| 329 const std::string name_attr("Name="); | 329 const std::string name_attr("Name="); |
| 330 bool in_app_section = false; | 330 bool in_app_section = false; |
| 331 for (size_t i = 0; i < lines.size(); ++i) { | 331 for (size_t i = 0; i < lines.size(); ++i) { |
| 332 TrimWhitespace(lines[i], TRIM_ALL, &lines[i]); | 332 TrimWhitespace(lines[i], TRIM_ALL, &lines[i]); |
| 333 if (lines[i] == "[App]") { | 333 if (lines[i] == "[App]") { |
| 334 in_app_section = true; | 334 in_app_section = true; |
| 335 } else if (in_app_section) { | 335 } else if (in_app_section) { |
| 336 if (lines[i].find(name_attr) == 0) { | 336 if (lines[i].find(name_attr) == 0) { |
| 337 branding_name = lines[i].substr(name_attr.size()); | 337 branding_name = lines[i].substr(name_attr.size()); |
| 338 break; | 338 break; |
| 339 } else if (lines[i].length() > 0 && lines[i][0] == '[') { | 339 } else if (lines[i].length() > 0 && lines[i][0] == '[') { |
| 340 // No longer in the [App] section. | 340 // No longer in the [App] section. |
| 341 break; | 341 break; |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 StringToLowerASCII(&branding_name); | 347 StringToLowerASCII(&branding_name); |
| 348 if (branding_name.find("iceweasel") != std::string::npos) | 348 if (branding_name.find("iceweasel") != std::string::npos) |
| 349 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_ICEWEASEL); | 349 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_ICEWEASEL); |
| 350 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX); | 350 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX); |
| 351 } | 351 } |
| OLD | NEW |