OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/net/firefox_proxy_settings.h" | 5 #include "chrome/browser/net/firefox_proxy_settings.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Parses the prefs found in the file |pref_file| and puts the key/value pairs | 62 // Parses the prefs found in the file |pref_file| and puts the key/value pairs |
63 // in |prefs|. Keys are strings, and values can be strings, booleans or | 63 // in |prefs|. Keys are strings, and values can be strings, booleans or |
64 // integers. Returns true if it succeeded, false otherwise (in which case | 64 // integers. Returns true if it succeeded, false otherwise (in which case |
65 // |prefs| is not filled). | 65 // |prefs| is not filled). |
66 // Note: for strings, only valid UTF-8 string values are supported. If a | 66 // Note: for strings, only valid UTF-8 string values are supported. If a |
67 // key/pair is not valid UTF-8, it is ignored and will not appear in |prefs|. | 67 // key/pair is not valid UTF-8, it is ignored and will not appear in |prefs|. |
68 bool ParsePrefFile(const base::FilePath& pref_file, DictionaryValue* prefs) { | 68 bool ParsePrefFile(const base::FilePath& pref_file, DictionaryValue* prefs) { |
69 // The string that is before a pref key. | 69 // The string that is before a pref key. |
70 const std::string kUserPrefString = "user_pref(\""; | 70 const std::string kUserPrefString = "user_pref(\""; |
71 std::string contents; | 71 std::string contents; |
72 if (!file_util::ReadFileToString(pref_file, &contents)) | 72 if (!base::ReadFileToString(pref_file, &contents)) |
73 return false; | 73 return false; |
74 | 74 |
75 std::vector<std::string> lines; | 75 std::vector<std::string> lines; |
76 Tokenize(contents, "\n", &lines); | 76 Tokenize(contents, "\n", &lines); |
77 | 77 |
78 for (std::vector<std::string>::const_iterator iter = lines.begin(); | 78 for (std::vector<std::string>::const_iterator iter = lines.begin(); |
79 iter != lines.end(); ++iter) { | 79 iter != lines.end(); ++iter) { |
80 const std::string& line = *iter; | 80 const std::string& line = *iter; |
81 size_t start_key = line.find(kUserPrefString); | 81 size_t start_key = line.find(kUserPrefString); |
82 if (start_key == std::string::npos) | 82 if (start_key == std::string::npos) |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 while (string_tok.GetNext()) { | 298 while (string_tok.GetNext()) { |
299 std::string token = string_tok.token(); | 299 std::string token = string_tok.token(); |
300 TrimWhitespaceASCII(token, TRIM_ALL, &token); | 300 TrimWhitespaceASCII(token, TRIM_ALL, &token); |
301 if (!token.empty()) | 301 if (!token.empty()) |
302 settings->proxy_bypass_list_.push_back(token); | 302 settings->proxy_bypass_list_.push_back(token); |
303 } | 303 } |
304 } | 304 } |
305 } | 305 } |
306 return true; | 306 return true; |
307 } | 307 } |
OLD | NEW |