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

Side by Side Diff: chrome/browser/safe_browsing/permission_reporter_browsertest.cc

Issue 2269863002: Turn on Permission Action Reporting by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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
« no previous file with comments | « chrome/browser/permissions/permission_uma_util_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/safe_browsing/mock_permission_report_sender.h" 15 #include "chrome/browser/safe_browsing/mock_permission_report_sender.h"
16 #include "chrome/browser/safe_browsing/ping_manager.h" 16 #include "chrome/browser/safe_browsing/ping_manager.h"
17 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 17 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
18 #include "chrome/browser/sync/test/integration/sync_test.h" 18 #include "chrome/browser/sync/test/integration/sync_test.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h" 21 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h"
22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/safe_browsing/permission_report.pb.h" 22 #include "chrome/common/safe_browsing/permission_report.pb.h"
24 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
25 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
26 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
27 26
28 #if !defined(OS_CHROMEOS) 27 #if !defined(OS_CHROMEOS)
29 #include "chrome/browser/signin/signin_manager_factory.h" 28 #include "chrome/browser/signin/signin_manager_factory.h"
30 #include "components/signin/core/browser/signin_manager.h" 29 #include "components/signin/core/browser/signin_manager.h"
31 #endif 30 #endif
32 31
(...skipping 12 matching lines...) Expand all
45 content::BrowserThread::PostTaskAndReply( 44 content::BrowserThread::PostTaskAndReply(
46 content::BrowserThread::IO, FROM_HERE, 45 content::BrowserThread::IO, FROM_HERE,
47 base::Bind( 46 base::Bind(
48 &PermissionReporterBrowserTest::AttachMockReportSenderOnIOThread, 47 &PermissionReporterBrowserTest::AttachMockReportSenderOnIOThread,
49 base::Unretained(this), 48 base::Unretained(this),
50 make_scoped_refptr(g_browser_process->safe_browsing_service())), 49 make_scoped_refptr(g_browser_process->safe_browsing_service())),
51 run_loop.QuitClosure()); 50 run_loop.QuitClosure());
52 run_loop.Run(); 51 run_loop.Run();
53 } 52 }
54 53
55 void SetUpCommandLine(base::CommandLine* command_line) override {
56 SyncTest::SetUpCommandLine(command_line);
57 command_line->AppendSwitch(switches::kEnablePermissionActionReporting);
58 }
59
60 void AttachMockReportSenderOnIOThread( 54 void AttachMockReportSenderOnIOThread(
61 scoped_refptr<SafeBrowsingService> safe_browsing_service) { 55 scoped_refptr<SafeBrowsingService> safe_browsing_service) {
62 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
63 57
64 mock_report_sender_ = new MockPermissionReportSender; 58 mock_report_sender_ = new MockPermissionReportSender;
65 59
66 safe_browsing_service->ping_manager()->permission_reporter_.reset( 60 safe_browsing_service->ping_manager()->permission_reporter_.reset(
67 new PermissionReporter(base::WrapUnique(mock_report_sender_), 61 new PermissionReporter(base::WrapUnique(mock_report_sender_),
68 base::WrapUnique(new base::SimpleTestClock))); 62 base::WrapUnique(new base::SimpleTestClock)));
69 } 63 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 EXPECT_EQ(PermissionReport::DESKTOP_PLATFORM, 119 EXPECT_EQ(PermissionReport::DESKTOP_PLATFORM,
126 permission_report.platform_type()); 120 permission_report.platform_type());
127 EXPECT_EQ(PermissionReport::NO_GESTURE, permission_report.gesture()); 121 EXPECT_EQ(PermissionReport::NO_GESTURE, permission_report.gesture());
128 EXPECT_EQ(PermissionReport::PERSIST_DECISION_UNSPECIFIED, 122 EXPECT_EQ(PermissionReport::PERSIST_DECISION_UNSPECIFIED,
129 permission_report.persisted()); 123 permission_report.persisted());
130 EXPECT_EQ(0, permission_report.num_prior_dismissals()); 124 EXPECT_EQ(0, permission_report.num_prior_dismissals());
131 EXPECT_EQ(0, permission_report.num_prior_ignores()); 125 EXPECT_EQ(0, permission_report.num_prior_ignores());
132 } 126 }
133 127
134 } // namespace safe_browsing 128 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_uma_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698