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

Side by Side Diff: chrome/browser/automation/automation_util.cc

Issue 10785017: Move CanonicalCookie into separate files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing include 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 | Annotate | Revision Log
OLDNEW
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 15 matching lines...) Expand all
26 #include "chrome/browser/ui/browser_list.h" 26 #include "chrome/browser/ui/browser_list.h"
27 #include "chrome/browser/ui/browser_tabstrip.h" 27 #include "chrome/browser/ui/browser_tabstrip.h"
28 #include "chrome/browser/ui/tab_contents/tab_contents.h" 28 #include "chrome/browser/ui/tab_contents/tab_contents.h"
29 #include "chrome/browser/view_type_utils.h" 29 #include "chrome/browser/view_type_utils.h"
30 #include "chrome/common/automation_id.h" 30 #include "chrome/common/automation_id.h"
31 #include "chrome/common/extensions/extension.h" 31 #include "chrome/common/extensions/extension.h"
32 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
33 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
34 #include "content/public/browser/render_view_host.h" 34 #include "content/public/browser/render_view_host.h"
35 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
36 #include "net/cookies/canonical_cookie.h"
36 #include "net/cookies/cookie_monster.h" 37 #include "net/cookies/cookie_monster.h"
37 #include "net/cookies/cookie_store.h" 38 #include "net/cookies/cookie_store.h"
38 #include "net/url_request/url_request_context.h" 39 #include "net/url_request/url_request_context.h"
39 #include "net/url_request/url_request_context_getter.h" 40 #include "net/url_request/url_request_context_getter.h"
40 41
41 using content::BrowserThread; 42 using content::BrowserThread;
42 using content::RenderViewHost; 43 using content::RenderViewHost;
43 using content::WebContents; 44 using content::WebContents;
44 45
45 namespace { 46 namespace {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 base::WaitableEvent* event, 95 base::WaitableEvent* event,
95 bool* success) { 96 bool* success) {
96 context_getter->GetURLRequestContext()->cookie_store()-> 97 context_getter->GetURLRequestContext()->cookie_store()->
97 SetCookieWithOptionsAsync( 98 SetCookieWithOptionsAsync(
98 url, value, net::CookieOptions(), 99 url, value, net::CookieOptions(),
99 base::Bind(&SetCookieCallback, event, success)); 100 base::Bind(&SetCookieCallback, event, success));
100 } 101 }
101 102
102 void SetCookieWithDetailsOnIOThread( 103 void SetCookieWithDetailsOnIOThread(
103 const GURL& url, 104 const GURL& url,
104 const net::CookieMonster::CanonicalCookie& cookie, 105 const net::CanonicalCookie& cookie,
105 const std::string& original_domain, 106 const std::string& original_domain,
106 const scoped_refptr<net::URLRequestContextGetter>& context_getter, 107 const scoped_refptr<net::URLRequestContextGetter>& context_getter,
107 base::WaitableEvent* event, 108 base::WaitableEvent* event,
108 bool* success) { 109 bool* success) {
109 net::CookieMonster* cookie_monster = 110 net::CookieMonster* cookie_monster =
110 context_getter->GetURLRequestContext()->cookie_store()-> 111 context_getter->GetURLRequestContext()->cookie_store()->
111 GetCookieMonster(); 112 GetCookieMonster();
112 cookie_monster->SetCookieWithDetailsAsync( 113 cookie_monster->SetCookieWithDetailsAsync(
113 url, cookie.Name(), cookie.Value(), original_domain, 114 url, cookie.Name(), cookie.Value(), original_domain,
114 cookie.Path(), cookie.ExpiryDate(), cookie.IsSecure(), 115 cookie.Path(), cookie.ExpiryDate(), cookie.IsSecure(),
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 base::Closure task = base::Bind(&GetCanonicalCookiesOnIOThread, GURL(url), 249 base::Closure task = base::Bind(&GetCanonicalCookiesOnIOThread, GURL(url),
249 context_getter, &event, &cookie_list); 250 context_getter, &event, &cookie_list);
250 if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, task)) { 251 if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, task)) {
251 reply.SendError("Couldn't post task to get the cookies"); 252 reply.SendError("Couldn't post task to get the cookies");
252 return; 253 return;
253 } 254 }
254 event.Wait(); 255 event.Wait();
255 256
256 ListValue* list = new ListValue(); 257 ListValue* list = new ListValue();
257 for (size_t i = 0; i < cookie_list.size(); ++i) { 258 for (size_t i = 0; i < cookie_list.size(); ++i) {
258 const net::CookieMonster::CanonicalCookie& cookie = cookie_list[i]; 259 const net::CanonicalCookie& cookie = cookie_list[i];
259 DictionaryValue* cookie_dict = new DictionaryValue(); 260 DictionaryValue* cookie_dict = new DictionaryValue();
260 cookie_dict->SetString("name", cookie.Name()); 261 cookie_dict->SetString("name", cookie.Name());
261 cookie_dict->SetString("value", cookie.Value()); 262 cookie_dict->SetString("value", cookie.Value());
262 cookie_dict->SetString("path", cookie.Path()); 263 cookie_dict->SetString("path", cookie.Path());
263 cookie_dict->SetString("domain", cookie.Domain()); 264 cookie_dict->SetString("domain", cookie.Domain());
264 cookie_dict->SetBoolean("secure", cookie.IsSecure()); 265 cookie_dict->SetBoolean("secure", cookie.IsSecure());
265 cookie_dict->SetBoolean("http_only", cookie.IsHttpOnly()); 266 cookie_dict->SetBoolean("http_only", cookie.IsHttpOnly());
266 if (cookie.IsPersistent()) 267 if (cookie.IsPersistent())
267 cookie_dict->SetDouble("expiry", cookie.ExpiryDate().ToDoubleT()); 268 cookie_dict->SetDouble("expiry", cookie.ExpiryDate().ToDoubleT());
268 list->Append(cookie_dict); 269 list->Append(cookie_dict);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 reply.SendError("optional 'expiry' invalid"); 358 reply.SendError("optional 'expiry' invalid");
358 return; 359 return;
359 } 360 }
360 } 361 }
361 if (cookie_dict->HasKey("http_only") && 362 if (cookie_dict->HasKey("http_only") &&
362 !cookie_dict->GetBoolean("http_only", &http_only)) { 363 !cookie_dict->GetBoolean("http_only", &http_only)) {
363 reply.SendError("optional 'http_only' invalid"); 364 reply.SendError("optional 'http_only' invalid");
364 return; 365 return;
365 } 366 }
366 367
367 scoped_ptr<net::CookieMonster::CanonicalCookie> cookie( 368 scoped_ptr<net::CanonicalCookie> cookie(
368 net::CookieMonster::CanonicalCookie::Create( 369 net::CanonicalCookie::Create(
369 GURL(url), name, value, domain, path, 370 GURL(url), name, value, domain, path,
370 mac_key, mac_algorithm, base::Time(), 371 mac_key, mac_algorithm, base::Time(),
371 base::Time::FromDoubleT(expiry), secure, http_only)); 372 base::Time::FromDoubleT(expiry), secure, http_only));
372 if (!cookie.get()) { 373 if (!cookie.get()) {
373 reply.SendError("given 'cookie' parameters are invalid"); 374 reply.SendError("given 'cookie' parameters are invalid");
374 return; 375 return;
375 } 376 }
376 377
377 // Since we may be on the UI thread don't call GetURLRequestContext(). 378 // Since we may be on the UI thread don't call GetURLRequestContext().
378 scoped_refptr<net::URLRequestContextGetter> context_getter = 379 scoped_refptr<net::URLRequestContextGetter> context_getter =
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 const extensions::Extension* extension; 556 const extensions::Extension* extension;
556 return GetExtensionForId(id, profile, &extension); 557 return GetExtensionForId(id, profile, &extension);
557 } 558 }
558 default: 559 default:
559 break; 560 break;
560 } 561 }
561 return false; 562 return false;
562 } 563 }
563 564
564 } // namespace automation_util 565 } // namespace automation_util
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data_cookie_helper.h » ('j') | net/cookies/canonical_cookie.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698