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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 std::string is_relative; | 65 std::string is_relative; |
66 string16 path16; | 66 string16 path16; |
67 if (root.GetStringASCII(current_profile + ".IsRelative", &is_relative) && | 67 if (root.GetStringASCII(current_profile + ".IsRelative", &is_relative) && |
68 root.GetString(current_profile + ".Path", &path16)) { | 68 root.GetString(current_profile + ".Path", &path16)) { |
69 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
70 ReplaceSubstringsAfterOffset( | 70 ReplaceSubstringsAfterOffset( |
71 &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\")); | 71 &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\")); |
72 #endif | 72 #endif |
73 base::FilePath path = | 73 base::FilePath path = |
74 base::FilePath::FromWStringHack(UTF16ToWide(path16)); | 74 base::FilePath::FromWStringHack(base::UTF16ToWide(path16)); |
75 | 75 |
76 // IsRelative=1 means the folder path would be relative to the | 76 // IsRelative=1 means the folder path would be relative to the |
77 // path of profiles.ini. IsRelative=0 refers to a custom profile | 77 // path of profiles.ini. IsRelative=0 refers to a custom profile |
78 // location. | 78 // location. |
79 if (is_relative == "1") { | 79 if (is_relative == "1") { |
80 path = ini_file.DirName().Append(path); | 80 path = ini_file.DirName().Append(path); |
81 } | 81 } |
82 | 82 |
83 // We only import the default profile when multiple profiles exist, | 83 // We only import the default profile when multiple profiles exist, |
84 // since the other profiles are used mostly by developers for testing. | 84 // since the other profiles are used mostly by developers for testing. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 std::string key = line.substr(0, equal); | 116 std::string key = line.substr(0, equal); |
117 if (key == "LastVersion") { | 117 if (key == "LastVersion") { |
118 base::StringToInt(line.substr(equal + 1), version); | 118 base::StringToInt(line.substr(equal + 1), version); |
119 ret = true; | 119 ret = true; |
120 } else if (key == "LastAppDir") { | 120 } else if (key == "LastAppDir") { |
121 // TODO(evanm): If the path in question isn't convertible to | 121 // TODO(evanm): If the path in question isn't convertible to |
122 // UTF-8, what does Firefox do? If it puts raw bytes in the | 122 // UTF-8, what does Firefox do? If it puts raw bytes in the |
123 // file, we could go straight from bytes -> filepath; | 123 // file, we could go straight from bytes -> filepath; |
124 // otherwise, we're out of luck here. | 124 // otherwise, we're out of luck here. |
125 *app_path = base::FilePath::FromWStringHack( | 125 *app_path = base::FilePath::FromWStringHack( |
126 UTF8ToWide(line.substr(equal + 1))); | 126 base::UTF8ToWide(line.substr(equal + 1))); |
127 } | 127 } |
128 } | 128 } |
129 } | 129 } |
130 return ret; | 130 return ret; |
131 } | 131 } |
132 | 132 |
133 void ParseProfileINI(const base::FilePath& file, DictionaryValue* root) { | 133 void ParseProfileINI(const base::FilePath& file, DictionaryValue* root) { |
134 // Reads the whole INI file. | 134 // Reads the whole INI file. |
135 std::string content; | 135 std::string content; |
136 file_util::ReadFileToString(file, &content); | 136 file_util::ReadFileToString(file, &content); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 459 } |
460 } | 460 } |
461 } | 461 } |
462 } | 462 } |
463 | 463 |
464 StringToLowerASCII(&branding_name); | 464 StringToLowerASCII(&branding_name); |
465 if (branding_name.find("iceweasel") != std::string::npos) | 465 if (branding_name.find("iceweasel") != std::string::npos) |
466 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_ICEWEASEL); | 466 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_ICEWEASEL); |
467 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX); | 467 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX); |
468 } | 468 } |
OLD | NEW |