| Index: chrome/browser/extensions/activity_log/activity_actions.cc
|
| diff --git a/chrome/browser/extensions/activity_log/activity_actions.cc b/chrome/browser/extensions/activity_log/activity_actions.cc
|
| index efc6ea8b66d06ee557bad382ff8071bbedfdf16e..d30e9d9e96856d9114bb5b373ea1083e0812a9da 100644
|
| --- a/chrome/browser/extensions/activity_log/activity_actions.cc
|
| +++ b/chrome/browser/extensions/activity_log/activity_actions.cc
|
| @@ -161,7 +161,8 @@ Action::InjectionType Action::DidInjectAd(
|
| return NO_AD_INJECTION;
|
|
|
| if (api_name_ == ad_injection_constants::kHtmlIframeSrcApiName ||
|
| - api_name_ == ad_injection_constants::kHtmlEmbedSrcApiName) {
|
| + api_name_ == ad_injection_constants::kHtmlEmbedSrcApiName ||
|
| + api_name_ == ad_injection_constants::kHtmlAnchorHrefApiName) {
|
| return CheckSrcModification();
|
| } else if (EndsWith(api_name_,
|
| ad_injection_constants::kAppendChildApiSuffix,
|
| @@ -418,10 +419,35 @@ void Action::MaybeUploadUrl(rappor::RapporService* rappor_service) const {
|
| }
|
|
|
| Action::InjectionType Action::CheckSrcModification() const {
|
| - bool injected_ad = arg_url_.is_valid() &&
|
| - !arg_url_.is_empty() &&
|
| - AdNetworkDatabase::Get()->IsAdNetwork(arg_url_);
|
| - return injected_ad ? INJECTION_NEW_AD : NO_AD_INJECTION;
|
| + const AdNetworkDatabase* database = AdNetworkDatabase::Get();
|
| +
|
| + bool arg_url_valid = arg_url_.is_valid() && !arg_url_.is_empty();
|
| +
|
| + GURL prev_url;
|
| + std::string prev_url_string;
|
| + if (args_.get() && args_->GetString(1u, &prev_url_string))
|
| + prev_url = GURL(prev_url_string);
|
| +
|
| + bool prev_url_valid = prev_url.is_valid() && !prev_url.is_empty();
|
| +
|
| + bool injected_ad = arg_url_valid && database->IsAdNetwork(arg_url_);
|
| + bool replaced_ad = prev_url_valid && database->IsAdNetwork(prev_url);
|
| +
|
| + if (injected_ad && replaced_ad)
|
| + return INJECTION_REPLACED_AD;
|
| + if (injected_ad)
|
| + return INJECTION_NEW_AD;
|
| + if (replaced_ad)
|
| + return INJECTION_REMOVED_AD;
|
| +
|
| + // If the extension replaced a valid URL with another valid URL for an iframe,
|
| + // embed, href, etc, then chances are it's ad injection (as there are few
|
| + // legitimate use cases for this). Log it as a likely one, which also helps
|
| + // us determine the effectiveness of our IsAdNetwork() recognition.
|
| + if (arg_url_valid && prev_url_valid)
|
| + return INJECTION_LIKELY_REPLACED_AD;
|
| +
|
| + return NO_AD_INJECTION;
|
| }
|
|
|
| Action::InjectionType Action::CheckAppendChild() const {
|
|
|