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

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

Issue 10834004: Correct const accessors in base/values.(h|cc) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reverting webdriver:Command::parameters_ to const Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 30 matching lines...) Expand all
41 if (!error) 41 if (!error)
42 error = session_->GetCookies(url, &cookies); 42 error = session_->GetCookies(url, &cookies);
43 if (error) { 43 if (error) {
44 response->SetError(error); 44 response->SetError(error);
45 return; 45 return;
46 } 46 }
47 response->SetValue(cookies); 47 response->SetValue(cookies);
48 } 48 }
49 49
50 void CookieCommand::ExecutePost(Response* const response) { 50 void CookieCommand::ExecutePost(Response* const response) {
51 DictionaryValue* cookie_dict; 51 const DictionaryValue* cookie_dict;
52 if (!GetDictionaryParameter("cookie", &cookie_dict)) { 52 if (!GetDictionaryParameter("cookie", &cookie_dict)) {
53 response->SetError(new Error( 53 response->SetError(new Error(
54 kBadRequest, "Missing or invalid |cookie| parameter")); 54 kBadRequest, "Missing or invalid |cookie| parameter"));
55 return; 55 return;
56 } 56 }
57 scoped_ptr<DictionaryValue> cookie_dict_copy(cookie_dict->DeepCopy());
57 58
58 std::string domain; 59 std::string domain;
59 if (cookie_dict->GetString("domain", &domain)) { 60 if (cookie_dict_copy->GetString("domain", &domain)) {
60 std::vector<std::string> split_domain; 61 std::vector<std::string> split_domain;
61 base::SplitString(domain, ':', &split_domain); 62 base::SplitString(domain, ':', &split_domain);
62 if (split_domain.size() > 2) { 63 if (split_domain.size() > 2) {
63 response->SetError(new Error( 64 response->SetError(new Error(
64 kInvalidCookieDomain, "Cookie domain has too many colons")); 65 kInvalidCookieDomain, "Cookie domain has too many colons"));
65 return; 66 return;
66 } else if (split_domain.size() == 2) { 67 } else if (split_domain.size() == 2) {
67 // Remove the port number. 68 // Remove the port number.
68 cookie_dict->SetString("domain", split_domain[0]); 69 cookie_dict_copy->SetString("domain", split_domain[0]);
69 } 70 }
70 } 71 }
71 72
72 std::string url; 73 std::string url;
73 Error* error = session_->GetURL(&url); 74 Error* error = session_->GetURL(&url);
74 if (!error) 75 if (!error)
75 error = session_->SetCookie(url, cookie_dict); 76 error = session_->SetCookie(url, cookie_dict_copy.get());
76 if (error) { 77 if (error) {
77 response->SetError(error); 78 response->SetError(error);
78 return; 79 return;
79 } 80 }
80 } 81 }
81 82
82 void CookieCommand::ExecuteDelete(Response* const response) { 83 void CookieCommand::ExecuteDelete(Response* const response) {
83 std::string url; 84 std::string url;
84 Error* error = session_->GetURL(&url); 85 Error* error = session_->GetURL(&url);
85 ListValue* unscoped_cookies = NULL; 86 ListValue* unscoped_cookies = NULL;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 Error* error = session_->GetURL(&url); 145 Error* error = session_->GetURL(&url);
145 if (!error) 146 if (!error)
146 error = session_->DeleteCookie(url, cookie_name_); 147 error = session_->DeleteCookie(url, cookie_name_);
147 if (error) { 148 if (error) {
148 response->SetError(error); 149 response->SetError(error);
149 return; 150 return;
150 } 151 }
151 } 152 }
152 153
153 } // namespace webdriver 154 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/command.cc ('k') | chrome/test/webdriver/commands/create_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698