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

Side by Side Diff: chrome/browser/extensions/api/history/history_api.cc

Issue 23785002: Clean up activity log URLs when history is cleaned. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix line Created 7 years, 3 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/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/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/extensions/activity_log/activity_log.h"
20 #include "chrome/browser/extensions/event_router.h" 21 #include "chrome/browser/extensions/event_router.h"
21 #include "chrome/browser/extensions/extension_system.h" 22 #include "chrome/browser/extensions/extension_system.h"
22 #include "chrome/browser/history/history_service.h" 23 #include "chrome/browser/history/history_service.h"
23 #include "chrome/browser/history/history_service_factory.h" 24 #include "chrome/browser/history/history_service_factory.h"
24 #include "chrome/browser/history/history_types.h" 25 #include "chrome/browser/history/history_types.h"
25 #include "chrome/browser/history/visit_filter.h" 26 #include "chrome/browser/history/visit_filter.h"
26 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/common/cancelable_task_tracker.h" 28 #include "chrome/common/cancelable_task_tracker.h"
28 #include "chrome/common/extensions/api/experimental_history.h" 29 #include "chrome/common/extensions/api/experimental_history.h"
29 #include "chrome/common/extensions/api/history.h" 30 #include "chrome/common/extensions/api/history.h"
30 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
31 #include "content/public/browser/notification_details.h" 32 #include "content/public/browser/notification_details.h"
32 #include "content/public/browser/notification_source.h" 33 #include "content/public/browser/notification_source.h"
33 34
34 namespace extensions { 35 namespace extensions {
35 36
36 using api::experimental_history::MostVisitedItem; 37 using api::experimental_history::MostVisitedItem;
37 using api::history::HistoryItem; 38 using api::history::HistoryItem;
38 using api::history::VisitItem; 39 using api::history::VisitItem;
40 using extensions::ActivityLog;
39 41
40 typedef std::vector<linked_ptr<api::history::HistoryItem> > 42 typedef std::vector<linked_ptr<api::history::HistoryItem> >
41 HistoryItemList; 43 HistoryItemList;
42 typedef std::vector<linked_ptr<api::history::VisitItem> > 44 typedef std::vector<linked_ptr<api::history::VisitItem> >
43 VisitItemList; 45 VisitItemList;
44 46
45 namespace AddUrl = api::history::AddUrl; 47 namespace AddUrl = api::history::AddUrl;
46 namespace DeleteUrl = api::history::DeleteUrl; 48 namespace DeleteUrl = api::history::DeleteUrl;
47 namespace DeleteRange = api::history::DeleteRange; 49 namespace DeleteRange = api::history::DeleteRange;
48 namespace GetMostVisited = api::experimental_history::GetMostVisited; 50 namespace GetMostVisited = api::experimental_history::GetMostVisited;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 439
438 GURL url; 440 GURL url;
439 if (!ValidateUrl(params->details.url, &url)) 441 if (!ValidateUrl(params->details.url, &url))
440 return false; 442 return false;
441 443
442 HistoryService* hs = 444 HistoryService* hs =
443 HistoryServiceFactory::GetForProfile(profile(), 445 HistoryServiceFactory::GetForProfile(profile(),
444 Profile::EXPLICIT_ACCESS); 446 Profile::EXPLICIT_ACCESS);
445 hs->DeleteURL(url); 447 hs->DeleteURL(url);
446 448
449 // Also clean out from the activity log.
felt 2013/09/03 23:03:46 the activity log api needed to declare its depende
450 ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
451 if (activity_log) {
452 activity_log->RemoveURL(url);
453 }
454
447 SendResponse(true); 455 SendResponse(true);
448 return true; 456 return true;
449 } 457 }
450 458
451 bool HistoryDeleteRangeFunction::RunAsyncImpl() { 459 bool HistoryDeleteRangeFunction::RunAsyncImpl() {
452 scoped_ptr<DeleteRange::Params> params(DeleteRange::Params::Create(*args_)); 460 scoped_ptr<DeleteRange::Params> params(DeleteRange::Params::Create(*args_));
453 EXTENSION_FUNCTION_VALIDATE(params.get()); 461 EXTENSION_FUNCTION_VALIDATE(params.get());
454 462
455 if (!VerifyDeleteAllowed()) 463 if (!VerifyDeleteAllowed())
456 return false; 464 return false;
457 465
458 base::Time start_time = GetTime(params->range.start_time); 466 base::Time start_time = GetTime(params->range.start_time);
459 base::Time end_time = GetTime(params->range.end_time); 467 base::Time end_time = GetTime(params->range.end_time);
460 468
461 std::set<GURL> restrict_urls; 469 std::set<GURL> restrict_urls;
462 HistoryService* hs = 470 HistoryService* hs =
463 HistoryServiceFactory::GetForProfile(profile(), 471 HistoryServiceFactory::GetForProfile(profile(),
464 Profile::EXPLICIT_ACCESS); 472 Profile::EXPLICIT_ACCESS);
465 hs->ExpireHistoryBetween( 473 hs->ExpireHistoryBetween(
466 restrict_urls, 474 restrict_urls,
467 start_time, 475 start_time,
468 end_time, 476 end_time,
469 base::Bind(&HistoryDeleteRangeFunction::DeleteComplete, 477 base::Bind(&HistoryDeleteRangeFunction::DeleteComplete,
470 base::Unretained(this)), 478 base::Unretained(this)),
471 &task_tracker_); 479 &task_tracker_);
472 480
481 // Also clean from the activity log.
482 ActivityLog* activity_log = ActivityLog::GetInstance(profile());
483 if (activity_log) {
484 activity_log->RemoveURLs(restrict_urls);
485 }
486
473 return true; 487 return true;
474 } 488 }
475 489
476 void HistoryDeleteRangeFunction::DeleteComplete() { 490 void HistoryDeleteRangeFunction::DeleteComplete() {
477 SendAsyncResponse(); 491 SendAsyncResponse();
478 } 492 }
479 493
480 bool HistoryDeleteAllFunction::RunAsyncImpl() { 494 bool HistoryDeleteAllFunction::RunAsyncImpl() {
481 if (!VerifyDeleteAllowed()) 495 if (!VerifyDeleteAllowed())
482 return false; 496 return false;
483 497
484 std::set<GURL> restrict_urls; 498 std::set<GURL> restrict_urls;
485 HistoryService* hs = 499 HistoryService* hs =
486 HistoryServiceFactory::GetForProfile(profile(), 500 HistoryServiceFactory::GetForProfile(profile(),
487 Profile::EXPLICIT_ACCESS); 501 Profile::EXPLICIT_ACCESS);
488 hs->ExpireHistoryBetween( 502 hs->ExpireHistoryBetween(
489 restrict_urls, 503 restrict_urls,
490 base::Time(), // Unbounded beginning... 504 base::Time(), // Unbounded beginning...
491 base::Time(), // ...and the end. 505 base::Time(), // ...and the end.
492 base::Bind(&HistoryDeleteAllFunction::DeleteComplete, 506 base::Bind(&HistoryDeleteAllFunction::DeleteComplete,
493 base::Unretained(this)), 507 base::Unretained(this)),
494 &task_tracker_); 508 &task_tracker_);
495 509
510 // Also clean up from the activity log.
511 ActivityLog* activity_log = ActivityLog::GetInstance(profile());
512 if (activity_log) {
513 activity_log->RemoveURLs(restrict_urls);
514 }
496 return true; 515 return true;
497 } 516 }
498 517
499 void HistoryDeleteAllFunction::DeleteComplete() { 518 void HistoryDeleteAllFunction::DeleteComplete() {
500 SendAsyncResponse(); 519 SendAsyncResponse();
501 } 520 }
502 521
503 } // namespace extensions 522 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698