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

Side by Side Diff: chrome/test/webdriver/commands/cookie_commands.cc

Issue 6532008: Fix chromium-style compile error that got in the tree since yesterday. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for Feb 17th Created 9 years, 10 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 | « chrome/test/webdriver/commands/cookie_commands.h ('k') | chrome/test/webdriver/cookie.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/webdriver/commands/cookie_commands.h" 5 #include "chrome/test/webdriver/commands/cookie_commands.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/test/webdriver/cookie.h" 13 #include "chrome/test/webdriver/cookie.h"
14 #include "chrome/test/webdriver/session.h" 14 #include "chrome/test/webdriver/session.h"
15 #include "chrome/test/webdriver/session_manager.h" 15 #include "chrome/test/webdriver/session_manager.h"
16 #include "chrome/test/webdriver/commands/response.h" 16 #include "chrome/test/webdriver/commands/response.h"
17 17
18 namespace webdriver { 18 namespace webdriver {
19 19
20 CookieCommand::CookieCommand(const std::vector<std::string>& path_segments,
21 const DictionaryValue* const parameters)
22 : WebDriverCommand(path_segments, parameters) {}
23
24 CookieCommand::~CookieCommand() {}
25
20 bool CookieCommand::Init(Response* const response) { 26 bool CookieCommand::Init(Response* const response) {
21 if (WebDriverCommand::Init(response)) { 27 if (WebDriverCommand::Init(response)) {
22 if (session_->GetURL(&current_url_)) { 28 if (session_->GetURL(&current_url_)) {
23 return true; 29 return true;
24 } 30 }
25 SET_WEBDRIVER_ERROR(response, "Failed to query current page URL", 31 SET_WEBDRIVER_ERROR(response, "Failed to query current page URL",
26 kInternalServerError); 32 kInternalServerError);
27 return false; 33 return false;
28 } 34 }
29 35
30 return false; 36 return false;
31 } 37 }
32 38
39 bool CookieCommand::DoesDelete() {
40 return true;
41 }
42
43 bool CookieCommand::DoesGet() {
44 return true;
45 }
46
47 bool CookieCommand::DoesPost() {
48 return true;
49 }
50
33 void CookieCommand::ExecuteGet(Response* const response) { 51 void CookieCommand::ExecuteGet(Response* const response) {
34 // TODO(JMikhail): Add GetJSONCookies to automation proxy since 52 // TODO(JMikhail): Add GetJSONCookies to automation proxy since
35 // GetCookies does not return the necessary information 53 // GetCookies does not return the necessary information
36 std::string cookies; 54 std::string cookies;
37 std::vector<std::string> tokens; 55 std::vector<std::string> tokens;
38 56
39 if (!session_->GetCookies(current_url_, &cookies)) { 57 if (!session_->GetCookies(current_url_, &cookies)) {
40 SET_WEBDRIVER_ERROR(response, "Failed to fetch cookies", 58 SET_WEBDRIVER_ERROR(response, "Failed to fetch cookies",
41 kUnknownError); 59 kUnknownError);
42 return; 60 return;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 LOG(ERROR) << "Failed to parse cookie: " << *i; 136 LOG(ERROR) << "Failed to parse cookie: " << *i;
119 SET_WEBDRIVER_ERROR(response, "Could not delete all cookies", 137 SET_WEBDRIVER_ERROR(response, "Could not delete all cookies",
120 kInternalServerError); 138 kInternalServerError);
121 return; 139 return;
122 } 140 }
123 } 141 }
124 142
125 response->set_status(kSuccess); 143 response->set_status(kSuccess);
126 } 144 }
127 145
146 NamedCookieCommand::NamedCookieCommand(
147 const std::vector<std::string>& path_segments,
148 const DictionaryValue* const parameters)
149 : WebDriverCommand(path_segments, parameters) {}
150
151 NamedCookieCommand::~NamedCookieCommand() {}
152
128 bool NamedCookieCommand::Init(Response* const response) { 153 bool NamedCookieCommand::Init(Response* const response) {
129 if (WebDriverCommand::Init(response)) { 154 if (WebDriverCommand::Init(response)) {
130 if (!session_->GetURL(&current_url_)) { 155 if (!session_->GetURL(&current_url_)) {
131 SET_WEBDRIVER_ERROR(response, "Failed to query current page URL", 156 SET_WEBDRIVER_ERROR(response, "Failed to query current page URL",
132 kInternalServerError); 157 kInternalServerError);
133 return false; 158 return false;
134 } 159 }
135 160
136 // There should be at least 5 segments to match 161 // There should be at least 5 segments to match
137 // /session/:sessionId/cookie/:name 162 // /session/:sessionId/cookie/:name
138 cookie_name_ = GetPathVariable(4); 163 cookie_name_ = GetPathVariable(4);
139 if (cookie_name_ == "") { 164 if (cookie_name_ == "") {
140 SET_WEBDRIVER_ERROR(response, "No cookie name specified", 165 SET_WEBDRIVER_ERROR(response, "No cookie name specified",
141 kBadRequest); 166 kBadRequest);
142 return false; 167 return false;
143 } 168 }
144 169
145 return true; 170 return true;
146 } 171 }
147 172
148 return false; 173 return false;
149 } 174 }
150 175
176 bool NamedCookieCommand::DoesDelete() {
177 return true;
178 }
179
180 bool NamedCookieCommand::DoesGet() {
181 return true;
182 }
183
151 void NamedCookieCommand::ExecuteGet(Response* const response) { 184 void NamedCookieCommand::ExecuteGet(Response* const response) {
152 std::string cookie; 185 std::string cookie;
153 186
154 if (!session_->GetCookieByName(current_url_, cookie_name_, &cookie)) { 187 if (!session_->GetCookieByName(current_url_, cookie_name_, &cookie)) {
155 SET_WEBDRIVER_ERROR(response, "Failed to fetch cookie", 188 SET_WEBDRIVER_ERROR(response, "Failed to fetch cookie",
156 kUnknownError); 189 kUnknownError);
157 return; 190 return;
158 } 191 }
159 192
160 response->set_status(kSuccess); 193 response->set_status(kSuccess);
161 response->set_value(new StringValue(cookie)); 194 response->set_value(new StringValue(cookie));
162 } 195 }
163 196
164 void NamedCookieCommand::ExecuteDelete(Response* const response) { 197 void NamedCookieCommand::ExecuteDelete(Response* const response) {
165 if (!session_->DeleteCookie(current_url_, cookie_name_)) { 198 if (!session_->DeleteCookie(current_url_, cookie_name_)) {
166 SET_WEBDRIVER_ERROR(response, "Failed to delete cookie", 199 SET_WEBDRIVER_ERROR(response, "Failed to delete cookie",
167 kUnknownError); 200 kUnknownError);
168 return; 201 return;
169 } 202 }
170 203
171 response->set_status(kSuccess); 204 response->set_status(kSuccess);
172 } 205 }
173 206
174 } // namespace webdriver 207 } // namespace webdriver
175 208
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/cookie_commands.h ('k') | chrome/test/webdriver/cookie.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698