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/extensions/api/history/history_api.h" | 5 #include "chrome/browser/extensions/api/history/history_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 if (!ValidateUrl(params->details.url, &url)) | 391 if (!ValidateUrl(params->details.url, &url)) |
392 return false; | 392 return false; |
393 | 393 |
394 HistoryService* hs = HistoryServiceFactory::GetForProfile( | 394 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
395 GetProfile(), Profile::EXPLICIT_ACCESS); | 395 GetProfile(), Profile::EXPLICIT_ACCESS); |
396 hs->DeleteURL(url); | 396 hs->DeleteURL(url); |
397 | 397 |
398 // Also clean out from the activity log. If the activity log testing flag is | 398 // Also clean out from the activity log. If the activity log testing flag is |
399 // set then don't clean so testers can see what potentially malicious | 399 // set then don't clean so testers can see what potentially malicious |
400 // extensions have been trying to clean from their logs. | 400 // extensions have been trying to clean from their logs. |
401 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 401 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
402 switches::kEnableExtensionActivityLogTesting)) { | 402 switches::kEnableExtensionActivityLogTesting)) { |
403 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 403 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); |
404 DCHECK(activity_log); | 404 DCHECK(activity_log); |
405 activity_log->RemoveURL(url); | 405 activity_log->RemoveURL(url); |
406 } | 406 } |
407 | 407 |
408 SendResponse(true); | 408 SendResponse(true); |
409 return true; | 409 return true; |
410 } | 410 } |
411 | 411 |
(...skipping 12 matching lines...) Expand all Loading... |
424 GetProfile(), Profile::EXPLICIT_ACCESS); | 424 GetProfile(), Profile::EXPLICIT_ACCESS); |
425 hs->ExpireHistoryBetween( | 425 hs->ExpireHistoryBetween( |
426 restrict_urls, | 426 restrict_urls, |
427 start_time, | 427 start_time, |
428 end_time, | 428 end_time, |
429 base::Bind(&HistoryDeleteRangeFunction::DeleteComplete, | 429 base::Bind(&HistoryDeleteRangeFunction::DeleteComplete, |
430 base::Unretained(this)), | 430 base::Unretained(this)), |
431 &task_tracker_); | 431 &task_tracker_); |
432 | 432 |
433 // Also clean from the activity log unless in testing mode. | 433 // Also clean from the activity log unless in testing mode. |
434 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 434 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
435 switches::kEnableExtensionActivityLogTesting)) { | 435 switches::kEnableExtensionActivityLogTesting)) { |
436 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 436 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); |
437 DCHECK(activity_log); | 437 DCHECK(activity_log); |
438 activity_log->RemoveURLs(restrict_urls); | 438 activity_log->RemoveURLs(restrict_urls); |
439 } | 439 } |
440 | 440 |
441 return true; | 441 return true; |
442 } | 442 } |
443 | 443 |
444 void HistoryDeleteRangeFunction::DeleteComplete() { | 444 void HistoryDeleteRangeFunction::DeleteComplete() { |
445 SendAsyncResponse(); | 445 SendAsyncResponse(); |
446 } | 446 } |
447 | 447 |
448 bool HistoryDeleteAllFunction::RunAsyncImpl() { | 448 bool HistoryDeleteAllFunction::RunAsyncImpl() { |
449 if (!VerifyDeleteAllowed()) | 449 if (!VerifyDeleteAllowed()) |
450 return false; | 450 return false; |
451 | 451 |
452 std::set<GURL> restrict_urls; | 452 std::set<GURL> restrict_urls; |
453 HistoryService* hs = HistoryServiceFactory::GetForProfile( | 453 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
454 GetProfile(), Profile::EXPLICIT_ACCESS); | 454 GetProfile(), Profile::EXPLICIT_ACCESS); |
455 hs->ExpireHistoryBetween( | 455 hs->ExpireHistoryBetween( |
456 restrict_urls, | 456 restrict_urls, |
457 base::Time(), // Unbounded beginning... | 457 base::Time(), // Unbounded beginning... |
458 base::Time(), // ...and the end. | 458 base::Time(), // ...and the end. |
459 base::Bind(&HistoryDeleteAllFunction::DeleteComplete, | 459 base::Bind(&HistoryDeleteAllFunction::DeleteComplete, |
460 base::Unretained(this)), | 460 base::Unretained(this)), |
461 &task_tracker_); | 461 &task_tracker_); |
462 | 462 |
463 // Also clean from the activity log unless in testing mode. | 463 // Also clean from the activity log unless in testing mode. |
464 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 464 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
465 switches::kEnableExtensionActivityLogTesting)) { | 465 switches::kEnableExtensionActivityLogTesting)) { |
466 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); | 466 ActivityLog* activity_log = ActivityLog::GetInstance(GetProfile()); |
467 DCHECK(activity_log); | 467 DCHECK(activity_log); |
468 activity_log->RemoveURLs(restrict_urls); | 468 activity_log->RemoveURLs(restrict_urls); |
469 } | 469 } |
470 | 470 |
471 return true; | 471 return true; |
472 } | 472 } |
473 | 473 |
474 void HistoryDeleteAllFunction::DeleteComplete() { | 474 void HistoryDeleteAllFunction::DeleteComplete() { |
475 SendAsyncResponse(); | 475 SendAsyncResponse(); |
476 } | 476 } |
477 | 477 |
478 } // namespace extensions | 478 } // namespace extensions |
OLD | NEW |