Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: chrome/test/chromedriver/capabilities.cc

Issue 14371003: [chromedriver] Enable acceptSslCerts and ignore NULL for proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/chromedriver/capabilities_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/test/chromedriver/capabilities.h" 5 #include "chrome/test/chromedriver/capabilities.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } else if (proxy_type == "pac") { 103 } else if (proxy_type == "pac") {
104 CommandLine::StringType proxy_pac_url; 104 CommandLine::StringType proxy_pac_url;
105 if (!proxy_dict->GetString("proxyAutoconfigUrl", &proxy_pac_url)) 105 if (!proxy_dict->GetString("proxyAutoconfigUrl", &proxy_pac_url))
106 return Status(kUnknownError, "'proxyAutoconfigUrl' must be a string"); 106 return Status(kUnknownError, "'proxyAutoconfigUrl' must be a string");
107 capabilities->command.AppendSwitchNative("proxy-pac-url", proxy_pac_url); 107 capabilities->command.AppendSwitchNative("proxy-pac-url", proxy_pac_url);
108 } else if (proxy_type == "autodetect") { 108 } else if (proxy_type == "autodetect") {
109 capabilities->command.AppendSwitch("proxy-auto-detect"); 109 capabilities->command.AppendSwitch("proxy-auto-detect");
110 } else if (proxy_type == "manual") { 110 } else if (proxy_type == "manual") {
111 const char* proxy_servers_options[][2] = { 111 const char* proxy_servers_options[][2] = {
112 {"ftpProxy", "ftp"}, {"httpProxy", "http"}, {"sslProxy", "https"}}; 112 {"ftpProxy", "ftp"}, {"httpProxy", "http"}, {"sslProxy", "https"}};
113 const base::Value* option_value = NULL;
113 std::string proxy_servers; 114 std::string proxy_servers;
114 for (size_t i = 0; i < arraysize(proxy_servers_options); ++i) { 115 for (size_t i = 0; i < arraysize(proxy_servers_options); ++i) {
115 if (!proxy_dict->HasKey(proxy_servers_options[i][0])) 116 if (!proxy_dict->Get(proxy_servers_options[i][0], &option_value) ||
117 option_value->IsType(base::Value::TYPE_NULL)) {
116 continue; 118 continue;
119 }
117 std::string value; 120 std::string value;
118 if (!proxy_dict->GetString(proxy_servers_options[i][0], &value)) { 121 if (!option_value->GetAsString(&value)) {
119 return Status( 122 return Status(
120 kUnknownError, 123 kUnknownError,
121 base::StringPrintf("'%s' must be a string", 124 base::StringPrintf("'%s' must be a string",
122 proxy_servers_options[i][0])); 125 proxy_servers_options[i][0]));
123 } 126 }
124 // Converts into Chrome proxy scheme. 127 // Converts into Chrome proxy scheme.
125 // Example: "http=localhost:9000;ftp=localhost:8000". 128 // Example: "http=localhost:9000;ftp=localhost:8000".
126 if (!proxy_servers.empty()) 129 if (!proxy_servers.empty())
127 proxy_servers += ";"; 130 proxy_servers += ";";
128 proxy_servers += base::StringPrintf( 131 proxy_servers += base::StringPrintf(
129 "%s=%s", proxy_servers_options[i][1], value.c_str()); 132 "%s=%s", proxy_servers_options[i][1], value.c_str());
130 } 133 }
131 134
132 std::string proxy_bypass_list; 135 std::string proxy_bypass_list;
133 if (proxy_dict->HasKey("noProxy")) { 136 if (proxy_dict->Get("noProxy", &option_value) &&
134 if (!proxy_dict->GetString("noProxy", &proxy_bypass_list)) 137 !option_value->IsType(base::Value::TYPE_NULL)) {
138 if (!option_value->GetAsString(&proxy_bypass_list))
135 return Status(kUnknownError, "'noProxy' must be a string"); 139 return Status(kUnknownError, "'noProxy' must be a string");
136 } 140 }
137 141
138 if (proxy_servers.empty() && proxy_bypass_list.empty()) { 142 if (proxy_servers.empty() && proxy_bypass_list.empty()) {
139 return Status(kUnknownError, 143 return Status(kUnknownError,
140 "proxyType is 'manual' but no manual " 144 "proxyType is 'manual' but no manual "
141 "proxy capabilities were found"); 145 "proxy capabilities were found");
142 } 146 }
143 if (!proxy_servers.empty()) 147 if (!proxy_servers.empty())
144 capabilities->command.AppendSwitchASCII("proxy-server", proxy_servers); 148 capabilities->command.AppendSwitchASCII("proxy-server", proxy_servers);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 it != parser_map.end(); ++it) { 247 it != parser_map.end(); ++it) {
244 const base::Value* capability = NULL; 248 const base::Value* capability = NULL;
245 if (desired_caps.Get(it->first, &capability)) { 249 if (desired_caps.Get(it->first, &capability)) {
246 status = it->second.Run(*capability, this); 250 status = it->second.Run(*capability, this);
247 if (status.IsError()) 251 if (status.IsError())
248 return status; 252 return status;
249 } 253 }
250 } 254 }
251 return Status(kOk); 255 return Status(kOk);
252 } 256 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/chromedriver/capabilities_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698