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

Unified Diff: chrome/browser/safe_browsing/ui_manager.cc

Issue 2047253002: Add hooks to permission layer for permission action reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-reporter-implementation
Patch Set: Small comment change Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/ui_manager.cc
diff --git a/chrome/browser/safe_browsing/ui_manager.cc b/chrome/browser/safe_browsing/ui_manager.cc
index 80a38d0338e21359b4a371dad026f875f94799dc..2f1bf1dc64a9c031b68206ded118f1b4e382b69b 100644
--- a/chrome/browser/safe_browsing/ui_manager.cc
+++ b/chrome/browser/safe_browsing/ui_manager.cc
@@ -281,6 +281,54 @@ void SafeBrowsingUIManager::ReportInvalidCertificateChain(
callback);
}
+void SafeBrowsingUIManager::ReportPermissionAction(
+ const GURL& origin,
+ content::PermissionType permission,
+ PermissionAction action) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ // Do not report permission action when the permission action reporting
+ // flag is not enabled.
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnablePermissionActionReporting)) {
+ return;
+ }
+
+ Profile* profile = ProfileManager::GetLastUsedProfile();
raymes 2016/06/16 01:10:23 We should use the actual profile (as discussed).
stefanocs 2016/06/16 01:52:20 Done.
+
+ // Do not report when SafeBrowsing is not enabled.
+ if (!profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) {
raymes 2016/06/16 01:10:22 Let's check with nparker for this check.
raymes 2016/06/16 01:10:23 nit: no {} for single-line if statements (and belo
stefanocs 2016/06/16 01:52:20 Acknowledged.
stefanocs 2016/06/16 01:52:20 Done.
+ return;
+ }
+ // Do not report if profile doesn't have profile sync service.
+ if (!ProfileSyncServiceFactory::HasProfileSyncService(profile)) {
+ return;
+ }
+
+ ProfileSyncService* profile_sync_service =
+ ProfileSyncServiceFactory::GetForProfile(profile);
+ syncer::ModelTypeSet preferred_data_types =
+ profile_sync_service->GetPreferredDataTypes();
+
+ // Do not report if profile can't start sync immediately.
+ if (!profile_sync_service->CanSyncStart()) {
raymes 2016/06/16 01:10:23 Let's check with pavely about how to find out: -Wh
stefanocs 2016/06/16 01:52:20 Acknowledged.
+ return;
+ }
+ // Do not report if Chrome Tab Sync is not enabled.
+ if (!preferred_data_types.Has(syncer::PROXY_TABS)) {
+ return;
+ }
+ // Do not report if Chrome Pref Sync is not enabled.
+ if (!preferred_data_types.Has(syncer::PREFERENCES)) {
+ return;
+ }
+
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&SafeBrowsingUIManager::ReportPermissionActionOnIOThread, this,
+ origin, permission, action));
+}
+
void SafeBrowsingUIManager::AddObserver(Observer* observer) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
observer_list_.AddObserver(observer);
@@ -303,6 +351,21 @@ void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread(
sb_service_->ping_manager()->ReportInvalidCertificateChain(serialized_report);
}
+void SafeBrowsingUIManager::ReportPermissionActionOnIOThread(
+ const GURL& origin,
+ content::PermissionType permission,
+ PermissionAction action) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ // The service may delete the ping manager (i.e. when user disabling service,
+ // etc). This happens on the IO thread.
+ if (!sb_service_ || !sb_service_->ping_manager())
+ return;
+
+ sb_service_->ping_manager()->ReportPermissionAction(origin, permission,
+ action);
+}
+
// If the user had opted-in to send ThreatDetails, this gets called
// when the report is ready.
void SafeBrowsingUIManager::SendSerializedThreatDetails(
« chrome/browser/safe_browsing/ui_manager.h ('K') | « chrome/browser/safe_browsing/ui_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698