OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 "update_engine/chrome_proxy_resolver.h" | 5 #include "update_engine/chrome_proxy_resolver.h" |
6 | 6 |
7 #include <base/json/json_reader.h> | 7 #include <base/json/json_reader.h> |
8 #include <base/scoped_ptr.h> | 8 #include <base/scoped_ptr.h> |
9 #include <base/values.h> | 9 #include <base/values.h> |
10 | 10 |
11 #include "update_engine/utils.h" | 11 #include "update_engine/utils.h" |
12 | 12 |
13 using std::string; | 13 using std::string; |
14 using std::vector; | 14 using std::vector; |
15 | 15 |
16 namespace chromeos_update_engine { | 16 namespace chromeos_update_engine { |
17 | 17 |
18 const char kSessionManagerService[] = "org.chromium.SessionManager"; | 18 const char kSessionManagerService[] = "org.chromium.SessionManager"; |
19 const char kSessionManagerPath[] = "/org/chromium/SessionManager"; | 19 const char kSessionManagerPath[] = "/org/chromium/SessionManager"; |
20 const char kSessionManagerInterface[] = "org.chromium.SessionManagerInterface"; | 20 const char kSessionManagerInterface[] = "org.chromium.SessionManagerInterface"; |
21 const char kSessionManagerRetrievePropertyMethod[] = | 21 const char kSessionManagerRetrievePropertyMethod[] = |
22 "RetrieveProperty"; | 22 "RetrieveProperty"; |
23 const char kSessionManagerProxySettingsKey[] = "cros.proxy.everywhere"; | 23 const char kSessionManagerProxySettingsKey[] = "cros.proxy.everywhere"; |
24 | 24 |
25 bool ChromeProxyResolver::GetProxiesForUrl( | 25 bool ChromeProxyResolver::GetProxiesForUrl( |
26 const std::string& url, | 26 const std::string& url, |
27 std::vector<std::string>* out_proxies) { | 27 std::deque<std::string>* out_proxies) { |
28 // First, query dbus for the currently stored settings | 28 // First, query dbus for the currently stored settings |
29 DBusGProxy* proxy = DbusProxy(); | 29 DBusGProxy* proxy = DbusProxy(); |
30 TEST_AND_RETURN_FALSE(proxy); | 30 TEST_AND_RETURN_FALSE(proxy); |
31 string json_settings; | 31 string json_settings; |
32 TEST_AND_RETURN_FALSE(GetJsonProxySettings(proxy, &json_settings)); | 32 TEST_AND_RETURN_FALSE(GetJsonProxySettings(proxy, &json_settings)); |
33 LOG(INFO) << "got settings:" << json_settings; | 33 LOG(INFO) << "got settings:" << json_settings; |
34 TEST_AND_RETURN_FALSE( | 34 TEST_AND_RETURN_FALSE( |
35 GetProxiesForUrlWithSettings(url, json_settings, out_proxies)); | 35 GetProxiesForUrlWithSettings(url, json_settings, out_proxies)); |
36 return true; | 36 return true; |
37 } | 37 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 kProxyModeAutoDetect, | 78 kProxyModeAutoDetect, |
79 kProxyModePACScript, | 79 kProxyModePACScript, |
80 kProxyModeSingle, | 80 kProxyModeSingle, |
81 kProxyModeProxyPerScheme | 81 kProxyModeProxyPerScheme |
82 }; | 82 }; |
83 } // namespace {} | 83 } // namespace {} |
84 | 84 |
85 bool ChromeProxyResolver::GetProxiesForUrlWithSettings( | 85 bool ChromeProxyResolver::GetProxiesForUrlWithSettings( |
86 const string& url, | 86 const string& url, |
87 const string& json_settings, | 87 const string& json_settings, |
88 std::vector<std::string>* out_proxies) { | 88 std::deque<std::string>* out_proxies) { |
89 base::JSONReader parser; | 89 base::JSONReader parser; |
90 | 90 |
91 scoped_ptr<Value> root( | 91 scoped_ptr<Value> root( |
92 parser.JsonToValue(json_settings, | 92 parser.JsonToValue(json_settings, |
93 true, // check root is obj/arr | 93 true, // check root is obj/arr |
94 false)); // false = disallow trailing comma | 94 false)); // false = disallow trailing comma |
95 if (!root.get()) { | 95 if (!root.get()) { |
96 LOG(ERROR) << "Unable to parse \"" << json_settings << "\": " | 96 LOG(ERROR) << "Unable to parse \"" << json_settings << "\": " |
97 << parser.GetErrorMessage(); | 97 << parser.GetErrorMessage(); |
98 return false; | 98 return false; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 176 } |
177 if (utils::StringHasPrefix(proxy, kNoProxy)) { | 177 if (utils::StringHasPrefix(proxy, kNoProxy)) { |
178 // known failure case. don't log. | 178 // known failure case. don't log. |
179 return false; | 179 return false; |
180 } | 180 } |
181 LOG(INFO) << "Unknown proxy type: " << proxy; | 181 LOG(INFO) << "Unknown proxy type: " << proxy; |
182 return false; | 182 return false; |
183 } | 183 } |
184 | 184 |
185 } // namespace chromeos_update_engine | 185 } // namespace chromeos_update_engine |
OLD | NEW |