| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/safe_browsing/permission_reporter.h" | 5 #include "chrome/browser/safe_browsing/permission_reporter.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/test/simple_test_clock.h" | 11 #include "base/test/simple_test_clock.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/permissions/permission_request_manager.h" | 13 #include "chrome/browser/permissions/permission_request_manager.h" |
| 14 #include "chrome/browser/permissions/permission_uma_util.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/safe_browsing/mock_permission_report_sender.h" | 16 #include "chrome/browser/safe_browsing/mock_permission_report_sender.h" |
| 16 #include "chrome/browser/safe_browsing/ping_manager.h" | 17 #include "chrome/browser/safe_browsing/ping_manager.h" |
| 17 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 18 #include "chrome/browser/sync/test/integration/sync_test.h" | 19 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.h" | 21 #include "chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/common/safe_browsing/permission_report.pb.h" | 23 #include "chrome/common/safe_browsing/permission_report.pb.h" |
| 23 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 26 | 27 |
| 27 #if !defined(OS_CHROMEOS) | 28 #if !defined(OS_CHROMEOS) |
| 28 #include "chrome/browser/signin/signin_manager_factory.h" | 29 #include "chrome/browser/signin/signin_manager_factory.h" |
| 29 #include "components/signin/core/browser/signin_manager.h" | 30 #include "components/signin/core/browser/signin_manager.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 namespace safe_browsing { | 33 namespace safe_browsing { |
| 33 | 34 |
| 34 class PermissionReporterBrowserTest : public SyncTest { | 35 class PermissionReporterBrowserTest : public SyncTest { |
| 35 public: | 36 public: |
| 36 PermissionReporterBrowserTest() : SyncTest(SINGLE_CLIENT) {} | 37 PermissionReporterBrowserTest() : SyncTest(SINGLE_CLIENT) {} |
| 37 ~PermissionReporterBrowserTest() override {} | 38 ~PermissionReporterBrowserTest() override {} |
| 38 | 39 |
| 39 protected: | 40 protected: |
| 40 void SetUpOnMainThread() override { | 41 void SetUpOnMainThread() override { |
| 41 SyncTest::SetUpOnMainThread(); | 42 SyncTest::SetUpOnMainThread(); |
| 42 | 43 |
| 44 PermissionUmaUtil::FakeOfficialBuildForTest(); |
| 43 base::RunLoop run_loop; | 45 base::RunLoop run_loop; |
| 44 content::BrowserThread::PostTaskAndReply( | 46 content::BrowserThread::PostTaskAndReply( |
| 45 content::BrowserThread::IO, FROM_HERE, | 47 content::BrowserThread::IO, FROM_HERE, |
| 46 base::BindOnce( | 48 base::BindOnce( |
| 47 &PermissionReporterBrowserTest::AttachMockReportSenderOnIOThread, | 49 &PermissionReporterBrowserTest::AttachMockReportSenderOnIOThread, |
| 48 base::Unretained(this), | 50 base::Unretained(this), |
| 49 make_scoped_refptr(g_browser_process->safe_browsing_service())), | 51 make_scoped_refptr(g_browser_process->safe_browsing_service())), |
| 50 run_loop.QuitClosure()); | 52 run_loop.QuitClosure()); |
| 51 run_loop.Run(); | 53 run_loop.Run(); |
| 52 } | 54 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 permission_report.platform_type()); | 193 permission_report.platform_type()); |
| 192 EXPECT_EQ(PermissionReport::NO_GESTURE, permission_report.gesture()); | 194 EXPECT_EQ(PermissionReport::NO_GESTURE, permission_report.gesture()); |
| 193 EXPECT_EQ(PermissionReport::PERSIST_DECISION_UNSPECIFIED, | 195 EXPECT_EQ(PermissionReport::PERSIST_DECISION_UNSPECIFIED, |
| 194 permission_report.persisted()); | 196 permission_report.persisted()); |
| 195 EXPECT_EQ(0, permission_report.num_prior_dismissals()); | 197 EXPECT_EQ(0, permission_report.num_prior_dismissals()); |
| 196 // Ensure that we correctly record one prior ignore. | 198 // Ensure that we correctly record one prior ignore. |
| 197 EXPECT_EQ(1, permission_report.num_prior_ignores()); | 199 EXPECT_EQ(1, permission_report.num_prior_ignores()); |
| 198 } | 200 } |
| 199 | 201 |
| 200 } // namespace safe_browsing | 202 } // namespace safe_browsing |
| OLD | NEW |