OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/automation/automation_util.h" | 5 #include "chrome/browser/automation/automation_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 ListValue* list = new ListValue(); | 256 ListValue* list = new ListValue(); |
257 for (size_t i = 0; i < cookie_list.size(); ++i) { | 257 for (size_t i = 0; i < cookie_list.size(); ++i) { |
258 const net::CookieMonster::CanonicalCookie& cookie = cookie_list[i]; | 258 const net::CookieMonster::CanonicalCookie& cookie = cookie_list[i]; |
259 DictionaryValue* cookie_dict = new DictionaryValue(); | 259 DictionaryValue* cookie_dict = new DictionaryValue(); |
260 cookie_dict->SetString("name", cookie.Name()); | 260 cookie_dict->SetString("name", cookie.Name()); |
261 cookie_dict->SetString("value", cookie.Value()); | 261 cookie_dict->SetString("value", cookie.Value()); |
262 cookie_dict->SetString("path", cookie.Path()); | 262 cookie_dict->SetString("path", cookie.Path()); |
263 cookie_dict->SetString("domain", cookie.Domain()); | 263 cookie_dict->SetString("domain", cookie.Domain()); |
264 cookie_dict->SetBoolean("secure", cookie.IsSecure()); | 264 cookie_dict->SetBoolean("secure", cookie.IsSecure()); |
265 cookie_dict->SetBoolean("http_only", cookie.IsHttpOnly()); | 265 cookie_dict->SetBoolean("http_only", cookie.IsHttpOnly()); |
266 if (cookie.DoesExpire()) | 266 if (cookie.IsPersistent()) |
267 cookie_dict->SetDouble("expiry", cookie.ExpiryDate().ToDoubleT()); | 267 cookie_dict->SetDouble("expiry", cookie.ExpiryDate().ToDoubleT()); |
268 list->Append(cookie_dict); | 268 list->Append(cookie_dict); |
269 } | 269 } |
270 DictionaryValue dict; | 270 DictionaryValue dict; |
271 dict.Set("cookies", list); | 271 dict.Set("cookies", list); |
272 reply.SendSuccess(&dict); | 272 reply.SendSuccess(&dict); |
273 } | 273 } |
274 | 274 |
275 void DeleteCookieJSON(AutomationProvider* provider, | 275 void DeleteCookieJSON(AutomationProvider* provider, |
276 DictionaryValue* args, | 276 DictionaryValue* args, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 if (cookie_dict->HasKey("http_only") && | 361 if (cookie_dict->HasKey("http_only") && |
362 !cookie_dict->GetBoolean("http_only", &http_only)) { | 362 !cookie_dict->GetBoolean("http_only", &http_only)) { |
363 reply.SendError("optional 'http_only' invalid"); | 363 reply.SendError("optional 'http_only' invalid"); |
364 return; | 364 return; |
365 } | 365 } |
366 | 366 |
367 scoped_ptr<net::CookieMonster::CanonicalCookie> cookie( | 367 scoped_ptr<net::CookieMonster::CanonicalCookie> cookie( |
368 net::CookieMonster::CanonicalCookie::Create( | 368 net::CookieMonster::CanonicalCookie::Create( |
369 GURL(url), name, value, domain, path, | 369 GURL(url), name, value, domain, path, |
370 mac_key, mac_algorithm, base::Time(), | 370 mac_key, mac_algorithm, base::Time(), |
371 base::Time::FromDoubleT(expiry), secure, http_only, expiry != 0)); | 371 base::Time::FromDoubleT(expiry), secure, http_only)); |
372 if (!cookie.get()) { | 372 if (!cookie.get()) { |
373 reply.SendError("given 'cookie' parameters are invalid"); | 373 reply.SendError("given 'cookie' parameters are invalid"); |
374 return; | 374 return; |
375 } | 375 } |
376 | 376 |
377 // Since we may be on the UI thread don't call GetURLRequestContext(). | 377 // Since we may be on the UI thread don't call GetURLRequestContext(). |
378 scoped_refptr<net::URLRequestContextGetter> context_getter = | 378 scoped_refptr<net::URLRequestContextGetter> context_getter = |
379 provider->profile()->GetRequestContext(); | 379 provider->profile()->GetRequestContext(); |
380 | 380 |
381 base::WaitableEvent event(true /* manual reset */, | 381 base::WaitableEvent event(true /* manual reset */, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 const extensions::Extension* extension; | 555 const extensions::Extension* extension; |
556 return GetExtensionForId(id, profile, &extension); | 556 return GetExtensionForId(id, profile, &extension); |
557 } | 557 } |
558 default: | 558 default: |
559 break; | 559 break; |
560 } | 560 } |
561 return false; | 561 return false; |
562 } | 562 } |
563 | 563 |
564 } // namespace automation_util | 564 } // namespace automation_util |
OLD | NEW |