forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connecting Ad Sampler trigger to TriggerManager.
The trigger remains disabled because it is hard-coded to have 0 quota (to be controlled via Finch in an upcoming CL), so this CL should be a no-op for now. When the trigger notices an ad in some frame on the page it will call TriggerManager to start capturing a trimmed threat report. It will also enqueue a call to finish and send the report 5s later to allow enough time for the asynchronous collection to run. There are some TODOs scattered throughout the code to fill in missing pieces, upcoming CLs will cover these. Bug: 744869 Change-Id: I67c53a57e338c82c299b4d0533700e9aee79b6bd Reviewed-on: https://chromium-review.googlesource.com/612125 Reviewed-by: Alexei Svitkine (very slow) <asvitkine@chromium.org> Reviewed-by: Emily Stark <estark@chromium.org> Reviewed-by: Michael Wasserman <msw@chromium.org> Reviewed-by: Varun Khaneja <vakh@chromium.org> Reviewed-by: Jialiu Lin <jialiul@chromium.org> Commit-Queue: Luke Z <lpz@chromium.org> Cr-Commit-Position: refs/heads/master@{#496289}
- Loading branch information
1 parent
eda1230
commit 40af601
Showing
21 changed files
with
690 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/safe_browsing/trigger_creator.h" | ||
|
||
#include "chrome/browser/browser_process.h" | ||
#include "chrome/browser/history/history_service_factory.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/safe_browsing/safe_browsing_service.h" | ||
#include "components/prefs/pref_service.h" | ||
#include "components/safe_browsing/triggers/ad_sampler_trigger.h" | ||
#include "components/safe_browsing/triggers/trigger_manager.h" | ||
#include "components/safe_browsing/triggers/trigger_throttler.h" | ||
#include "components/security_interstitials/core/base_safe_browsing_error_ui.h" | ||
#include "content/public/browser/browser_context.h" | ||
#include "content/public/browser/browser_thread.h" | ||
#include "net/url_request/url_request_context_getter.h" | ||
|
||
namespace safe_browsing { | ||
|
||
using SBErrorOptions = | ||
security_interstitials::BaseSafeBrowsingErrorUI::SBErrorDisplayOptions; | ||
|
||
void TriggerCreator::MaybeCreateTriggersForWebContents( | ||
Profile* profile, | ||
content::WebContents* web_contents) { | ||
if (!g_browser_process->safe_browsing_service() || | ||
!g_browser_process->safe_browsing_service()->trigger_manager()) { | ||
return; | ||
} | ||
|
||
// We only start triggers for this tab if they are eligible to collect data | ||
// (eg: because of opt-ins, available quota, etc). If we skip a trigger but | ||
// later opt-in changes or quota becomes available, the trigger won't be | ||
// running on old tabs, but that's acceptable. The trigger will be started for | ||
// new tabs. | ||
TriggerManager* trigger_manager = | ||
g_browser_process->safe_browsing_service()->trigger_manager(); | ||
SBErrorOptions options = TriggerManager::GetSBErrorDisplayOptions( | ||
*profile->GetPrefs(), *web_contents); | ||
if (trigger_manager->CanStartDataCollection(options, | ||
TriggerType::AD_SAMPLE)) { | ||
safe_browsing::AdSamplerTrigger::CreateForWebContents( | ||
web_contents, trigger_manager, profile->GetPrefs(), | ||
profile->GetRequestContext(), | ||
HistoryServiceFactory::GetForProfile( | ||
profile, ServiceAccessType::EXPLICIT_ACCESS)); | ||
} | ||
} | ||
|
||
} // namespace safe_browsing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_SAFE_BROWSING_TRIGGER_CREATOR_H_ | ||
#define CHROME_BROWSER_SAFE_BROWSING_TRIGGER_CREATOR_H_ | ||
|
||
class Profile; | ||
|
||
namespace content { | ||
class WebContents; | ||
} | ||
|
||
namespace safe_browsing { | ||
|
||
// Takes care of creation of individual triggers. This functionality lives in a | ||
// separate class from TriggerManager to avoid circular dependencies. | ||
// TriggerManager need not know about individual trigger classes, while the | ||
// trigger classes needs to know about the TriggerManager in order to fire | ||
// triggers. | ||
class TriggerCreator { | ||
public: | ||
static void MaybeCreateTriggersForWebContents( | ||
Profile* profile, | ||
content::WebContents* web_contents); | ||
}; | ||
|
||
} // namespace safe_browsing | ||
#endif // CHROME_BROWSER_SAFE_BROWSING_TRIGGER_CREATOR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.