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

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: One more, Windows-only Created 8 years, 5 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"
11 #include "base/string_split.h" 11 #include "base/string_split.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/test/webdriver/commands/response.h" 14 #include "chrome/test/webdriver/commands/response.h"
15 #include "chrome/test/webdriver/webdriver_session.h" 15 #include "chrome/test/webdriver/webdriver_session.h"
16 16
17 namespace webdriver { 17 namespace webdriver {
18 18
19 CookieCommand::CookieCommand(const std::vector<std::string>& path_segments, 19 CookieCommand::CookieCommand(const std::vector<std::string>& path_segments,
20 const DictionaryValue* const parameters) 20 DictionaryValue* const parameters)
21 : WebDriverCommand(path_segments, parameters) {} 21 : WebDriverCommand(path_segments, parameters) {}
22 22
23 CookieCommand::~CookieCommand() {} 23 CookieCommand::~CookieCommand() {}
24 24
25 bool CookieCommand::DoesDelete() { 25 bool CookieCommand::DoesDelete() {
26 return true; 26 return true;
27 } 27 }
28 28
29 bool CookieCommand::DoesGet() { 29 bool CookieCommand::DoesGet() {
30 return true; 30 return true;
(...skipping 11 matching lines...) Expand all
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 DictionaryValue* cookie_dict;
52 if (!GetDictionaryParameter("cookie", &cookie_dict)) { 52 if (!GetDictionaryParameter("cookie", &cookie_dict)) {
vabr (Chromium) 2012/07/26 20:48:03 Here we get a sub-dictionary cookie_dict from para
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 57
58 std::string domain; 58 std::string domain;
59 if (cookie_dict->GetString("domain", &domain)) { 59 if (cookie_dict->GetString("domain", &domain)) {
60 std::vector<std::string> split_domain; 60 std::vector<std::string> split_domain;
61 base::SplitString(domain, ':', &split_domain); 61 base::SplitString(domain, ':', &split_domain);
62 if (split_domain.size() > 2) { 62 if (split_domain.size() > 2) {
63 response->SetError(new Error( 63 response->SetError(new Error(
64 kInvalidCookieDomain, "Cookie domain has too many colons")); 64 kInvalidCookieDomain, "Cookie domain has too many colons"));
65 return; 65 return;
66 } else if (split_domain.size() == 2) { 66 } else if (split_domain.size() == 2) {
67 // Remove the port number. 67 // Remove the port number.
68 cookie_dict->SetString("domain", split_domain[0]); 68 cookie_dict->SetString("domain", split_domain[0]);
vabr (Chromium) 2012/07/26 20:48:03 Here we modify the sub-dictionary cookie_dict of t
69 } 69 }
70 } 70 }
71 71
72 std::string url; 72 std::string url;
73 Error* error = session_->GetURL(&url); 73 Error* error = session_->GetURL(&url);
74 if (!error) 74 if (!error)
75 error = session_->SetCookie(url, cookie_dict); 75 error = session_->SetCookie(url, cookie_dict);
vabr (Chromium) 2012/07/26 20:48:03 Here we pass cookie_dict to SetCookie, which will
76 if (error) { 76 if (error) {
77 response->SetError(error); 77 response->SetError(error);
78 return; 78 return;
79 } 79 }
80 } 80 }
81 81
82 void CookieCommand::ExecuteDelete(Response* const response) { 82 void CookieCommand::ExecuteDelete(Response* const response) {
83 std::string url; 83 std::string url;
84 Error* error = session_->GetURL(&url); 84 Error* error = session_->GetURL(&url);
85 ListValue* unscoped_cookies = NULL; 85 ListValue* unscoped_cookies = NULL;
(...skipping 22 matching lines...) Expand all
108 error = session_->DeleteCookie(url, name); 108 error = session_->DeleteCookie(url, name);
109 if (error) { 109 if (error) {
110 response->SetError(error); 110 response->SetError(error);
111 return; 111 return;
112 } 112 }
113 } 113 }
114 } 114 }
115 115
116 NamedCookieCommand::NamedCookieCommand( 116 NamedCookieCommand::NamedCookieCommand(
117 const std::vector<std::string>& path_segments, 117 const std::vector<std::string>& path_segments,
118 const DictionaryValue* const parameters) 118 DictionaryValue* const parameters)
119 : WebDriverCommand(path_segments, parameters) {} 119 : WebDriverCommand(path_segments, parameters) {}
120 120
121 NamedCookieCommand::~NamedCookieCommand() {} 121 NamedCookieCommand::~NamedCookieCommand() {}
122 122
123 bool NamedCookieCommand::Init(Response* const response) { 123 bool NamedCookieCommand::Init(Response* const response) {
124 if (!WebDriverCommand::Init(response)) 124 if (!WebDriverCommand::Init(response))
125 return false; 125 return false;
126 126
127 // There should be at least 5 segments to match 127 // There should be at least 5 segments to match
128 // /session/:sessionId/cookie/:name 128 // /session/:sessionId/cookie/:name
(...skipping 15 matching lines...) Expand all
144 Error* error = session_->GetURL(&url); 144 Error* error = session_->GetURL(&url);
145 if (!error) 145 if (!error)
146 error = session_->DeleteCookie(url, cookie_name_); 146 error = session_->DeleteCookie(url, cookie_name_);
147 if (error) { 147 if (error) {
148 response->SetError(error); 148 response->SetError(error);
149 return; 149 return;
150 } 150 }
151 } 151 }
152 152
153 } // namespace webdriver 153 } // namespace webdriver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698