OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/browsing_data/chrome_browsing_data_remover_delegate.h" | 5 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/time/time.h" |
11 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 12 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
13 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" | 14 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
14 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 17 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
17 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h" | 18 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h" |
18 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 19 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
19 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 20 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
20 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 21 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 | 545 |
545 private: | 546 private: |
546 password_manager::MockPasswordStore* store_; | 547 password_manager::MockPasswordStore* store_; |
547 | 548 |
548 DISALLOW_COPY_AND_ASSIGN(RemovePasswordsTester); | 549 DISALLOW_COPY_AND_ASSIGN(RemovePasswordsTester); |
549 }; | 550 }; |
550 | 551 |
551 class RemovePermissionPromptCountsTest { | 552 class RemovePermissionPromptCountsTest { |
552 public: | 553 public: |
553 explicit RemovePermissionPromptCountsTest(TestingProfile* profile) | 554 explicit RemovePermissionPromptCountsTest(TestingProfile* profile) |
554 : profile_(profile) {} | 555 : autoblocker_(PermissionDecisionAutoBlocker::GetForProfile(profile)) {} |
555 | 556 |
556 int GetDismissCount(const GURL& url, content::PermissionType permission) { | 557 int GetDismissCount(const GURL& url, content::PermissionType permission) { |
557 return PermissionDecisionAutoBlocker::GetDismissCount( | 558 return autoblocker_->GetDismissCount(url, permission); |
558 url, permission, profile_); | |
559 } | 559 } |
560 | 560 |
561 int GetIgnoreCount(const GURL& url, content::PermissionType permission) { | 561 int GetIgnoreCount(const GURL& url, content::PermissionType permission) { |
562 return PermissionDecisionAutoBlocker::GetIgnoreCount( | 562 return autoblocker_->GetIgnoreCount(url, permission); |
563 url, permission, profile_); | |
564 } | 563 } |
565 | 564 |
566 int RecordIgnore(const GURL& url, content::PermissionType permission) { | 565 int RecordIgnore(const GURL& url, content::PermissionType permission) { |
567 return PermissionDecisionAutoBlocker::RecordIgnore(url, permission, | 566 return autoblocker_->RecordIgnore(url, permission); |
568 profile_); | |
569 } | 567 } |
570 | 568 |
571 bool ShouldChangeDismissalToBlock(const GURL& url, | 569 bool ShouldChangeDismissalToBlock(const GURL& url, |
572 content::PermissionType permission) { | 570 content::PermissionType permission) { |
573 return PermissionDecisionAutoBlocker::ShouldChangeDismissalToBlock( | 571 return autoblocker_->RecordDismissAndEmbargo(url, permission); |
574 url, permission, profile_); | |
575 } | 572 } |
576 | 573 |
577 private: | 574 private: |
578 TestingProfile* profile_; | 575 PermissionDecisionAutoBlocker* autoblocker_; |
579 | 576 |
580 DISALLOW_COPY_AND_ASSIGN(RemovePermissionPromptCountsTest); | 577 DISALLOW_COPY_AND_ASSIGN(RemovePermissionPromptCountsTest); |
581 }; | 578 }; |
582 | 579 |
583 #if BUILDFLAG(ENABLE_PLUGINS) | 580 #if BUILDFLAG(ENABLE_PLUGINS) |
584 // A small modification to MockBrowsingDataFlashLSOHelper so that it responds | 581 // A small modification to MockBrowsingDataFlashLSOHelper so that it responds |
585 // immediately and does not wait for the Notify() call. Otherwise it would | 582 // immediately and does not wait for the Notify() call. Otherwise it would |
586 // deadlock BrowsingDataRemoverImpl::RemoveImpl. | 583 // deadlock BrowsingDataRemoverImpl::RemoveImpl. |
587 class TestBrowsingDataFlashLSOHelper : public MockBrowsingDataFlashLSOHelper { | 584 class TestBrowsingDataFlashLSOHelper : public MockBrowsingDataFlashLSOHelper { |
588 public: | 585 public: |
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 completion_observer.BlockUntilCompletion(); | 1732 completion_observer.BlockUntilCompletion(); |
1736 | 1733 |
1737 // There should be only 1 recently visited bookmarks. | 1734 // There should be only 1 recently visited bookmarks. |
1738 std::vector<const bookmarks::BookmarkNode*> remaining_nodes = | 1735 std::vector<const bookmarks::BookmarkNode*> remaining_nodes = |
1739 ntp_snippets::GetRecentlyVisitedBookmarks( | 1736 ntp_snippets::GetRecentlyVisitedBookmarks( |
1740 bookmark_model, 3, base::Time::UnixEpoch(), | 1737 bookmark_model, 3, base::Time::UnixEpoch(), |
1741 /*consider_visits_from_desktop=*/true); | 1738 /*consider_visits_from_desktop=*/true); |
1742 EXPECT_THAT(remaining_nodes, SizeIs(1)); | 1739 EXPECT_THAT(remaining_nodes, SizeIs(1)); |
1743 EXPECT_THAT(remaining_nodes[0]->url().spec(), Eq("http://foo-2.org/")); | 1740 EXPECT_THAT(remaining_nodes[0]->url().spec(), Eq("http://foo-2.org/")); |
1744 } | 1741 } |
OLD | NEW |