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

Side by Side Diff: chrome/browser/extensions/api/cookies/cookies_api.cc

Issue 11747025: Run the JSON Schema Compiler's bundle compilation on JSON files. Previously it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ms release build Created 7 years, 11 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 // Implements the Chrome Extensions Cookies API. 5 // Implements the Chrome Extensions Cookies API.
6 6
7 #include "chrome/browser/extensions/api/cookies/cookies_api.h" 7 #include "chrome/browser/extensions/api/cookies/cookies_api.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 *store_id = cookies_helpers::GetStoreIdFromProfile(store_profile); 182 *store_id = cookies_helpers::GetStoreIdFromProfile(store_profile);
183 } 183 }
184 184
185 if (context) 185 if (context)
186 *context = store_profile->GetRequestContext(); 186 *context = store_profile->GetRequestContext();
187 DCHECK(context); 187 DCHECK(context);
188 188
189 return true; 189 return true;
190 } 190 }
191 191
192 GetCookieFunction::GetCookieFunction() { 192 CookiesGetFunction::CookiesGetFunction() {
193 } 193 }
194 194
195 GetCookieFunction::~GetCookieFunction() { 195 CookiesGetFunction::~CookiesGetFunction() {
196 } 196 }
197 197
198 bool GetCookieFunction::RunImpl() { 198 bool CookiesGetFunction::RunImpl() {
199 parsed_args_ = Get::Params::Create(*args_); 199 parsed_args_ = Get::Params::Create(*args_);
200 EXTENSION_FUNCTION_VALIDATE(parsed_args_.get()); 200 EXTENSION_FUNCTION_VALIDATE(parsed_args_.get());
201 201
202 // Read/validate input parameters. 202 // Read/validate input parameters.
203 if (!ParseUrl(parsed_args_->details.url, &url_, true)) 203 if (!ParseUrl(parsed_args_->details.url, &url_, true))
204 return false; 204 return false;
205 205
206 std::string store_id = parsed_args_->details.store_id.get() ? 206 std::string store_id = parsed_args_->details.store_id.get() ?
207 *parsed_args_->details.store_id : ""; 207 *parsed_args_->details.store_id : "";
208 net::URLRequestContextGetter* store_context = NULL; 208 net::URLRequestContextGetter* store_context = NULL;
209 if (!ParseStoreContext(&store_id, &store_context)) 209 if (!ParseStoreContext(&store_id, &store_context))
210 return false; 210 return false;
211 store_context_ = store_context; 211 store_context_ = store_context;
212 if (!parsed_args_->details.store_id.get()) 212 if (!parsed_args_->details.store_id.get())
213 parsed_args_->details.store_id.reset(new std::string(store_id)); 213 parsed_args_->details.store_id.reset(new std::string(store_id));
214 214
215 store_context_ = store_context; 215 store_context_ = store_context;
216 216
217 bool rv = BrowserThread::PostTask( 217 bool rv = BrowserThread::PostTask(
218 BrowserThread::IO, FROM_HERE, 218 BrowserThread::IO, FROM_HERE,
219 base::Bind(&GetCookieFunction::GetCookieOnIOThread, this)); 219 base::Bind(&CookiesGetFunction::GetCookieOnIOThread, this));
220 DCHECK(rv); 220 DCHECK(rv);
221 221
222 // Will finish asynchronously. 222 // Will finish asynchronously.
223 return true; 223 return true;
224 } 224 }
225 225
226 void GetCookieFunction::GetCookieOnIOThread() { 226 void CookiesGetFunction::GetCookieOnIOThread() {
227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
228 net::CookieStore* cookie_store = 228 net::CookieStore* cookie_store =
229 store_context_->GetURLRequestContext()->cookie_store(); 229 store_context_->GetURLRequestContext()->cookie_store();
230 cookies_helpers::GetCookieListFromStore( 230 cookies_helpers::GetCookieListFromStore(
231 cookie_store, url_, 231 cookie_store, url_,
232 base::Bind(&GetCookieFunction::GetCookieCallback, this)); 232 base::Bind(&CookiesGetFunction::GetCookieCallback, this));
233 } 233 }
234 234
235 void GetCookieFunction::GetCookieCallback(const net::CookieList& cookie_list) { 235 void CookiesGetFunction::GetCookieCallback(const net::CookieList& cookie_list) {
236 net::CookieList::const_iterator it; 236 net::CookieList::const_iterator it;
237 for (it = cookie_list.begin(); it != cookie_list.end(); ++it) { 237 for (it = cookie_list.begin(); it != cookie_list.end(); ++it) {
238 // Return the first matching cookie. Relies on the fact that the 238 // Return the first matching cookie. Relies on the fact that the
239 // CookieMonster returns them in canonical order (longest path, then 239 // CookieMonster returns them in canonical order (longest path, then
240 // earliest creation time). 240 // earliest creation time).
241 if (it->Name() == parsed_args_->details.name) { 241 if (it->Name() == parsed_args_->details.name) {
242 scoped_ptr<Cookie> cookie( 242 scoped_ptr<Cookie> cookie(
243 cookies_helpers::CreateCookie(*it, *parsed_args_->details.store_id)); 243 cookies_helpers::CreateCookie(*it, *parsed_args_->details.store_id));
244 results_ = Get::Results::Create(*cookie); 244 results_ = Get::Results::Create(*cookie);
245 break; 245 break;
246 } 246 }
247 } 247 }
248 248
249 // The cookie doesn't exist; return null. 249 // The cookie doesn't exist; return null.
250 if (it == cookie_list.end()) 250 if (it == cookie_list.end())
251 SetResult(Value::CreateNullValue()); 251 SetResult(Value::CreateNullValue());
252 252
253 bool rv = BrowserThread::PostTask( 253 bool rv = BrowserThread::PostTask(
254 BrowserThread::UI, FROM_HERE, 254 BrowserThread::UI, FROM_HERE,
255 base::Bind(&GetCookieFunction::RespondOnUIThread, this)); 255 base::Bind(&CookiesGetFunction::RespondOnUIThread, this));
256 DCHECK(rv); 256 DCHECK(rv);
257 } 257 }
258 258
259 void GetCookieFunction::RespondOnUIThread() { 259 void CookiesGetFunction::RespondOnUIThread() {
260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
261 SendResponse(true); 261 SendResponse(true);
262 } 262 }
263 263
264 GetAllCookiesFunction::GetAllCookiesFunction() { 264 CookiesGetAllFunction::CookiesGetAllFunction() {
265 } 265 }
266 266
267 GetAllCookiesFunction::~GetAllCookiesFunction() { 267 CookiesGetAllFunction::~CookiesGetAllFunction() {
268 } 268 }
269 269
270 bool GetAllCookiesFunction::RunImpl() { 270 bool CookiesGetAllFunction::RunImpl() {
271 parsed_args_ = GetAll::Params::Create(*args_); 271 parsed_args_ = GetAll::Params::Create(*args_);
272 EXTENSION_FUNCTION_VALIDATE(parsed_args_.get()); 272 EXTENSION_FUNCTION_VALIDATE(parsed_args_.get());
273 273
274 if (parsed_args_->details.url.get() && 274 if (parsed_args_->details.url.get() &&
275 !ParseUrl(*parsed_args_->details.url, &url_, false)) { 275 !ParseUrl(*parsed_args_->details.url, &url_, false)) {
276 return false; 276 return false;
277 } 277 }
278 278
279 std::string store_id = parsed_args_->details.store_id.get() ? 279 std::string store_id = parsed_args_->details.store_id.get() ?
280 *parsed_args_->details.store_id : ""; 280 *parsed_args_->details.store_id : "";
281 net::URLRequestContextGetter* store_context = NULL; 281 net::URLRequestContextGetter* store_context = NULL;
282 if (!ParseStoreContext(&store_id, &store_context)) 282 if (!ParseStoreContext(&store_id, &store_context))
283 return false; 283 return false;
284 store_context_ = store_context; 284 store_context_ = store_context;
285 if (!parsed_args_->details.store_id.get()) 285 if (!parsed_args_->details.store_id.get())
286 parsed_args_->details.store_id.reset(new std::string(store_id)); 286 parsed_args_->details.store_id.reset(new std::string(store_id));
287 287
288 bool rv = BrowserThread::PostTask( 288 bool rv = BrowserThread::PostTask(
289 BrowserThread::IO, FROM_HERE, 289 BrowserThread::IO, FROM_HERE,
290 base::Bind(&GetAllCookiesFunction::GetAllCookiesOnIOThread, this)); 290 base::Bind(&CookiesGetAllFunction::GetAllCookiesOnIOThread, this));
291 DCHECK(rv); 291 DCHECK(rv);
292 292
293 // Will finish asynchronously. 293 // Will finish asynchronously.
294 return true; 294 return true;
295 } 295 }
296 296
297 void GetAllCookiesFunction::GetAllCookiesOnIOThread() { 297 void CookiesGetAllFunction::GetAllCookiesOnIOThread() {
298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
299 net::CookieStore* cookie_store = 299 net::CookieStore* cookie_store =
300 store_context_->GetURLRequestContext()->cookie_store(); 300 store_context_->GetURLRequestContext()->cookie_store();
301 cookies_helpers::GetCookieListFromStore( 301 cookies_helpers::GetCookieListFromStore(
302 cookie_store, url_, 302 cookie_store, url_,
303 base::Bind(&GetAllCookiesFunction::GetAllCookiesCallback, this)); 303 base::Bind(&CookiesGetAllFunction::GetAllCookiesCallback, this));
304 } 304 }
305 305
306 void GetAllCookiesFunction::GetAllCookiesCallback( 306 void CookiesGetAllFunction::GetAllCookiesCallback(
307 const net::CookieList& cookie_list) { 307 const net::CookieList& cookie_list) {
308 const extensions::Extension* extension = GetExtension(); 308 const extensions::Extension* extension = GetExtension();
309 if (extension) { 309 if (extension) {
310 std::vector<linked_ptr<Cookie> > match_vector; 310 std::vector<linked_ptr<Cookie> > match_vector;
311 cookies_helpers::AppendMatchingCookiesToVector( 311 cookies_helpers::AppendMatchingCookiesToVector(
312 cookie_list, url_, &parsed_args_->details, 312 cookie_list, url_, &parsed_args_->details,
313 GetExtension(), &match_vector); 313 GetExtension(), &match_vector);
314 314
315 results_ = GetAll::Results::Create(match_vector); 315 results_ = GetAll::Results::Create(match_vector);
316 } 316 }
317 bool rv = BrowserThread::PostTask( 317 bool rv = BrowserThread::PostTask(
318 BrowserThread::UI, FROM_HERE, 318 BrowserThread::UI, FROM_HERE,
319 base::Bind(&GetAllCookiesFunction::RespondOnUIThread, this)); 319 base::Bind(&CookiesGetAllFunction::RespondOnUIThread, this));
320 DCHECK(rv); 320 DCHECK(rv);
321 } 321 }
322 322
323 void GetAllCookiesFunction::RespondOnUIThread() { 323 void CookiesGetAllFunction::RespondOnUIThread() {
324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
325 SendResponse(true); 325 SendResponse(true);
326 } 326 }
327 327
328 SetCookieFunction::SetCookieFunction() : success_(false) { 328 CookiesSetFunction::CookiesSetFunction() : success_(false) {
329 } 329 }
330 330
331 SetCookieFunction::~SetCookieFunction() { 331 CookiesSetFunction::~CookiesSetFunction() {
332 } 332 }
333 333
334 bool SetCookieFunction::RunImpl() { 334 bool CookiesSetFunction::RunImpl() {
335 parsed_args_ = Set::Params::Create(*args_); 335 parsed_args_ = Set::Params::Create(*args_);
336 EXTENSION_FUNCTION_VALIDATE(parsed_args_.get()); 336 EXTENSION_FUNCTION_VALIDATE(parsed_args_.get());
337 337
338 // Read/validate input parameters. 338 // Read/validate input parameters.
339 if (!ParseUrl(parsed_args_->details.url, &url_, true)) 339 if (!ParseUrl(parsed_args_->details.url, &url_, true))
340 return false; 340 return false;
341 341
342 std::string store_id = parsed_args_->details.store_id.get() ? 342 std::string store_id = parsed_args_->details.store_id.get() ?
343 *parsed_args_->details.store_id : ""; 343 *parsed_args_->details.store_id : "";
344 net::URLRequestContextGetter* store_context = NULL; 344 net::URLRequestContextGetter* store_context = NULL;
345 if (!ParseStoreContext(&store_id, &store_context)) 345 if (!ParseStoreContext(&store_id, &store_context))
346 return false; 346 return false;
347 store_context_ = store_context; 347 store_context_ = store_context;
348 if (!parsed_args_->details.store_id.get()) 348 if (!parsed_args_->details.store_id.get())
349 parsed_args_->details.store_id.reset(new std::string(store_id)); 349 parsed_args_->details.store_id.reset(new std::string(store_id));
350 350
351 bool rv = BrowserThread::PostTask( 351 bool rv = BrowserThread::PostTask(
352 BrowserThread::IO, FROM_HERE, 352 BrowserThread::IO, FROM_HERE,
353 base::Bind(&SetCookieFunction::SetCookieOnIOThread, this)); 353 base::Bind(&CookiesSetFunction::SetCookieOnIOThread, this));
354 DCHECK(rv); 354 DCHECK(rv);
355 355
356 // Will finish asynchronously. 356 // Will finish asynchronously.
357 return true; 357 return true;
358 } 358 }
359 359
360 void SetCookieFunction::SetCookieOnIOThread() { 360 void CookiesSetFunction::SetCookieOnIOThread() {
361 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 361 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
362 net::CookieMonster* cookie_monster = 362 net::CookieMonster* cookie_monster =
363 store_context_->GetURLRequestContext()->cookie_store()-> 363 store_context_->GetURLRequestContext()->cookie_store()->
364 GetCookieMonster(); 364 GetCookieMonster();
365 365
366 base::Time expiration_time; 366 base::Time expiration_time;
367 if (parsed_args_->details.expiration_date.get()) { 367 if (parsed_args_->details.expiration_date.get()) {
368 // Time::FromDoubleT converts double time 0 to empty Time object. So we need 368 // Time::FromDoubleT converts double time 0 to empty Time object. So we need
369 // to do special handling here. 369 // to do special handling here.
370 expiration_time = (*parsed_args_->details.expiration_date == 0) ? 370 expiration_time = (*parsed_args_->details.expiration_date == 0) ?
371 base::Time::UnixEpoch() : 371 base::Time::UnixEpoch() :
372 base::Time::FromDoubleT(*parsed_args_->details.expiration_date); 372 base::Time::FromDoubleT(*parsed_args_->details.expiration_date);
373 } 373 }
374 374
375 cookie_monster->SetCookieWithDetailsAsync( 375 cookie_monster->SetCookieWithDetailsAsync(
376 url_, 376 url_,
377 parsed_args_->details.name.get() ? *parsed_args_->details.name : "", 377 parsed_args_->details.name.get() ? *parsed_args_->details.name : "",
378 parsed_args_->details.value.get() ? *parsed_args_->details.value : "", 378 parsed_args_->details.value.get() ? *parsed_args_->details.value : "",
379 parsed_args_->details.domain.get() ? *parsed_args_->details.domain : "", 379 parsed_args_->details.domain.get() ? *parsed_args_->details.domain : "",
380 parsed_args_->details.path.get() ? *parsed_args_->details.path : "", 380 parsed_args_->details.path.get() ? *parsed_args_->details.path : "",
381 expiration_time, 381 expiration_time,
382 parsed_args_->details.secure.get() ? 382 parsed_args_->details.secure.get() ?
383 *parsed_args_->details.secure.get() : 383 *parsed_args_->details.secure.get() :
384 false, 384 false,
385 parsed_args_->details.http_only.get() ? 385 parsed_args_->details.http_only.get() ?
386 *parsed_args_->details.http_only : 386 *parsed_args_->details.http_only :
387 false, 387 false,
388 base::Bind(&SetCookieFunction::PullCookie, this)); 388 base::Bind(&CookiesSetFunction::PullCookie, this));
389 } 389 }
390 390
391 void SetCookieFunction::PullCookie(bool set_cookie_result) { 391 void CookiesSetFunction::PullCookie(bool set_cookie_result) {
392 // Pull the newly set cookie. 392 // Pull the newly set cookie.
393 net::CookieMonster* cookie_monster = 393 net::CookieMonster* cookie_monster =
394 store_context_->GetURLRequestContext()->cookie_store()-> 394 store_context_->GetURLRequestContext()->cookie_store()->
395 GetCookieMonster(); 395 GetCookieMonster();
396 success_ = set_cookie_result; 396 success_ = set_cookie_result;
397 cookies_helpers::GetCookieListFromStore( 397 cookies_helpers::GetCookieListFromStore(
398 cookie_monster, url_, 398 cookie_monster, url_,
399 base::Bind(&SetCookieFunction::PullCookieCallback, this)); 399 base::Bind(&CookiesSetFunction::PullCookieCallback, this));
400 } 400 }
401 401
402 void SetCookieFunction::PullCookieCallback(const net::CookieList& cookie_list) { 402 void CookiesSetFunction::PullCookieCallback(
403 const net::CookieList& cookie_list) {
403 net::CookieList::const_iterator it; 404 net::CookieList::const_iterator it;
404 for (it = cookie_list.begin(); it != cookie_list.end(); ++it) { 405 for (it = cookie_list.begin(); it != cookie_list.end(); ++it) {
405 // Return the first matching cookie. Relies on the fact that the 406 // Return the first matching cookie. Relies on the fact that the
406 // CookieMonster returns them in canonical order (longest path, then 407 // CookieMonster returns them in canonical order (longest path, then
407 // earliest creation time). 408 // earliest creation time).
408 std::string name = parsed_args_->details.name.get() ? 409 std::string name = parsed_args_->details.name.get() ?
409 *parsed_args_->details.name : ""; 410 *parsed_args_->details.name : "";
410 if (it->Name() == name) { 411 if (it->Name() == name) {
411 scoped_ptr<Cookie> cookie( 412 scoped_ptr<Cookie> cookie(
412 cookies_helpers::CreateCookie(*it, *parsed_args_->details.store_id)); 413 cookies_helpers::CreateCookie(*it, *parsed_args_->details.store_id));
413 results_ = Set::Results::Create(*cookie); 414 results_ = Set::Results::Create(*cookie);
414 break; 415 break;
415 } 416 }
416 } 417 }
417 418
418 bool rv = BrowserThread::PostTask( 419 bool rv = BrowserThread::PostTask(
419 BrowserThread::UI, FROM_HERE, 420 BrowserThread::UI, FROM_HERE,
420 base::Bind(&SetCookieFunction::RespondOnUIThread, this)); 421 base::Bind(&CookiesSetFunction::RespondOnUIThread, this));
421 DCHECK(rv); 422 DCHECK(rv);
422 } 423 }
423 424
424 void SetCookieFunction::RespondOnUIThread() { 425 void CookiesSetFunction::RespondOnUIThread() {
425 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
426 if (!success_) { 427 if (!success_) {
427 std::string name = parsed_args_->details.name.get() ? 428 std::string name = parsed_args_->details.name.get() ?
428 *parsed_args_->details.name : ""; 429 *parsed_args_->details.name : "";
429 error_ = ErrorUtils::FormatErrorMessage( 430 error_ = ErrorUtils::FormatErrorMessage(
430 keys::kCookieSetFailedError, name); 431 keys::kCookieSetFailedError, name);
431 } 432 }
432 SendResponse(success_); 433 SendResponse(success_);
433 } 434 }
434 435
435 RemoveCookieFunction::RemoveCookieFunction() { 436 CookiesRemoveFunction::CookiesRemoveFunction() {
436 } 437 }
437 438
438 RemoveCookieFunction::~RemoveCookieFunction() { 439 CookiesRemoveFunction::~CookiesRemoveFunction() {
439 } 440 }
440 441
441 bool RemoveCookieFunction::RunImpl() { 442 bool CookiesRemoveFunction::RunImpl() {
442 parsed_args_ = Remove::Params::Create(*args_); 443 parsed_args_ = Remove::Params::Create(*args_);
443 EXTENSION_FUNCTION_VALIDATE(parsed_args_.get()); 444 EXTENSION_FUNCTION_VALIDATE(parsed_args_.get());
444 445
445 // Read/validate input parameters. 446 // Read/validate input parameters.
446 if (!ParseUrl(parsed_args_->details.url, &url_, true)) 447 if (!ParseUrl(parsed_args_->details.url, &url_, true))
447 return false; 448 return false;
448 449
449 std::string store_id = parsed_args_->details.store_id.get() ? 450 std::string store_id = parsed_args_->details.store_id.get() ?
450 *parsed_args_->details.store_id : ""; 451 *parsed_args_->details.store_id : "";
451 net::URLRequestContextGetter* store_context = NULL; 452 net::URLRequestContextGetter* store_context = NULL;
452 if (!ParseStoreContext(&store_id, &store_context)) 453 if (!ParseStoreContext(&store_id, &store_context))
453 return false; 454 return false;
454 store_context_ = store_context; 455 store_context_ = store_context;
455 if (!parsed_args_->details.store_id.get()) 456 if (!parsed_args_->details.store_id.get())
456 parsed_args_->details.store_id.reset(new std::string(store_id)); 457 parsed_args_->details.store_id.reset(new std::string(store_id));
457 458
458 // Pass the work off to the IO thread. 459 // Pass the work off to the IO thread.
459 bool rv = BrowserThread::PostTask( 460 bool rv = BrowserThread::PostTask(
460 BrowserThread::IO, FROM_HERE, 461 BrowserThread::IO, FROM_HERE,
461 base::Bind(&RemoveCookieFunction::RemoveCookieOnIOThread, this)); 462 base::Bind(&CookiesRemoveFunction::RemoveCookieOnIOThread, this));
462 DCHECK(rv); 463 DCHECK(rv);
463 464
464 // Will return asynchronously. 465 // Will return asynchronously.
465 return true; 466 return true;
466 } 467 }
467 468
468 void RemoveCookieFunction::RemoveCookieOnIOThread() { 469 void CookiesRemoveFunction::RemoveCookieOnIOThread() {
469 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
470 471
471 // Remove the cookie 472 // Remove the cookie
472 net::CookieStore* cookie_store = 473 net::CookieStore* cookie_store =
473 store_context_->GetURLRequestContext()->cookie_store(); 474 store_context_->GetURLRequestContext()->cookie_store();
474 cookie_store->DeleteCookieAsync( 475 cookie_store->DeleteCookieAsync(
475 url_, parsed_args_->details.name, 476 url_, parsed_args_->details.name,
476 base::Bind(&RemoveCookieFunction::RemoveCookieCallback, this)); 477 base::Bind(&CookiesRemoveFunction::RemoveCookieCallback, this));
477 } 478 }
478 479
479 void RemoveCookieFunction::RemoveCookieCallback() { 480 void CookiesRemoveFunction::RemoveCookieCallback() {
480 // Build the callback result 481 // Build the callback result
481 Remove::Results::Details details; 482 Remove::Results::Details details;
482 details.name = parsed_args_->details.name; 483 details.name = parsed_args_->details.name;
483 details.url = url_.spec(); 484 details.url = url_.spec();
484 details.store_id = *parsed_args_->details.store_id; 485 details.store_id = *parsed_args_->details.store_id;
485 results_ = Remove::Results::Create(details); 486 results_ = Remove::Results::Create(details);
486 487
487 // Return to UI thread 488 // Return to UI thread
488 bool rv = BrowserThread::PostTask( 489 bool rv = BrowserThread::PostTask(
489 BrowserThread::UI, FROM_HERE, 490 BrowserThread::UI, FROM_HERE,
490 base::Bind(&RemoveCookieFunction::RespondOnUIThread, this)); 491 base::Bind(&CookiesRemoveFunction::RespondOnUIThread, this));
491 DCHECK(rv); 492 DCHECK(rv);
492 } 493 }
493 494
494 void RemoveCookieFunction::RespondOnUIThread() { 495 void CookiesRemoveFunction::RespondOnUIThread() {
495 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 496 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
496 SendResponse(true); 497 SendResponse(true);
497 } 498 }
498 499
499 bool GetAllCookieStoresFunction::RunImpl() { 500 bool CookiesGetAllCookieStoresFunction::RunImpl() {
500 Profile* original_profile = profile(); 501 Profile* original_profile = profile();
501 DCHECK(original_profile); 502 DCHECK(original_profile);
502 scoped_ptr<ListValue> original_tab_ids(new ListValue()); 503 scoped_ptr<ListValue> original_tab_ids(new ListValue());
503 Profile* incognito_profile = NULL; 504 Profile* incognito_profile = NULL;
504 scoped_ptr<ListValue> incognito_tab_ids; 505 scoped_ptr<ListValue> incognito_tab_ids;
505 if (include_incognito() && profile()->HasOffTheRecordProfile()) { 506 if (include_incognito() && profile()->HasOffTheRecordProfile()) {
506 incognito_profile = profile()->GetOffTheRecordProfile(); 507 incognito_profile = profile()->GetOffTheRecordProfile();
507 if (incognito_profile) 508 if (incognito_profile)
508 incognito_tab_ids.reset(new ListValue()); 509 incognito_tab_ids.reset(new ListValue());
509 } 510 }
(...skipping 22 matching lines...) Expand all
532 if (incognito_tab_ids.get() && incognito_tab_ids->GetSize() > 0 && 533 if (incognito_tab_ids.get() && incognito_tab_ids->GetSize() > 0 &&
533 incognito_profile) { 534 incognito_profile) {
534 cookie_stores.push_back(make_linked_ptr( 535 cookie_stores.push_back(make_linked_ptr(
535 cookies_helpers::CreateCookieStore( 536 cookies_helpers::CreateCookieStore(
536 incognito_profile, incognito_tab_ids.release()).release())); 537 incognito_profile, incognito_tab_ids.release()).release()));
537 } 538 }
538 results_ = GetAllCookieStores::Results::Create(cookie_stores); 539 results_ = GetAllCookieStores::Results::Create(cookie_stores);
539 return true; 540 return true;
540 } 541 }
541 542
542 void GetAllCookieStoresFunction::Run() { 543 void CookiesGetAllCookieStoresFunction::Run() {
543 SendResponse(RunImpl()); 544 SendResponse(RunImpl());
544 } 545 }
545 546
546 CookiesAPI::CookiesAPI(Profile* profile) 547 CookiesAPI::CookiesAPI(Profile* profile)
547 : profile_(profile) { 548 : profile_(profile) {
548 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( 549 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
549 this, keys::kOnChanged); 550 this, keys::kOnChanged);
550 } 551 }
551 552
552 CookiesAPI::~CookiesAPI() { 553 CookiesAPI::~CookiesAPI() {
(...skipping 11 matching lines...) Expand all
564 return &g_factory.Get(); 565 return &g_factory.Get();
565 } 566 }
566 567
567 void CookiesAPI::OnListenerAdded( 568 void CookiesAPI::OnListenerAdded(
568 const extensions::EventListenerInfo& details) { 569 const extensions::EventListenerInfo& details) {
569 cookies_event_router_.reset(new CookiesEventRouter(profile_)); 570 cookies_event_router_.reset(new CookiesEventRouter(profile_));
570 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); 571 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);
571 } 572 }
572 573
573 } // namespace extensions 574 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/cookies/cookies_api.h ('k') | chrome/browser/extensions/api/debugger/debugger_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698