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/common/importer/firefox_importer_utils.h" | 5 #include "chrome/common/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 |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/ini_parser.h" | |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
16 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
19 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/common/ini_parser.h" |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // Retrieves the file system path of the profile name. | 26 // Retrieves the file system path of the profile name. |
27 base::FilePath GetProfilePath(const base::DictionaryValue& root, | 27 base::FilePath GetProfilePath(const base::DictionaryValue& root, |
28 const std::string& profile_name) { | 28 const std::string& profile_name) { |
29 base::string16 path16; | 29 base::string16 path16; |
(...skipping 24 matching lines...) Expand all Loading... |
54 root.GetStringASCII(profile_name + ".Default", &is_default); | 54 root.GetStringASCII(profile_name + ".Default", &is_default); |
55 return is_default == "1"; | 55 return is_default == "1"; |
56 } | 56 } |
57 | 57 |
58 } // namespace | 58 } // namespace |
59 | 59 |
60 base::FilePath GetFirefoxProfilePath() { | 60 base::FilePath GetFirefoxProfilePath() { |
61 base::FilePath ini_file = GetProfilesINI(); | 61 base::FilePath ini_file = GetProfilesINI(); |
62 std::string content; | 62 std::string content; |
63 base::ReadFileToString(ini_file, &content); | 63 base::ReadFileToString(ini_file, &content); |
64 base::DictionaryValueINIParser ini_parser; | 64 DictionaryValueINIParser ini_parser; |
65 ini_parser.Parse(content); | 65 ini_parser.Parse(content); |
66 return GetFirefoxProfilePathFromDictionary(ini_parser.root()); | 66 return GetFirefoxProfilePathFromDictionary(ini_parser.root()); |
67 } | 67 } |
68 | 68 |
69 base::FilePath GetFirefoxProfilePathFromDictionary( | 69 base::FilePath GetFirefoxProfilePathFromDictionary( |
70 const base::DictionaryValue& root) { | 70 const base::DictionaryValue& root) { |
71 std::vector<std::string> profiles; | 71 std::vector<std::string> profiles; |
72 for (int i = 0; ; ++i) { | 72 for (int i = 0; ; ++i) { |
73 std::string current_profile = base::StringPrintf("Profile%d", i); | 73 std::string current_profile = base::StringPrintf("Profile%d", i); |
74 if (root.HasKey(current_profile)) { | 74 if (root.HasKey(current_profile)) { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 } | 320 } |
321 } | 321 } |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 base::StringToLowerASCII(&branding_name); | 325 base::StringToLowerASCII(&branding_name); |
326 if (branding_name.find("iceweasel") != std::string::npos) | 326 if (branding_name.find("iceweasel") != std::string::npos) |
327 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_ICEWEASEL); | 327 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_ICEWEASEL); |
328 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX); | 328 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX); |
329 } | 329 } |
OLD | NEW |