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

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

Issue 2777853005: Generalize the usage of referrer chain (Closed)
Patch Set: address lpz's comments Created 3 years, 8 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 | « no previous file | chrome/browser/safe_browsing/safe_browsing_navigation_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 const GURL& download_url, 1873 const GURL& download_url,
1874 content::WebContents* web_contents) { 1874 content::WebContents* web_contents) {
1875 std::unique_ptr<ReferrerChain> referrer_chain = 1875 std::unique_ptr<ReferrerChain> referrer_chain =
1876 base::MakeUnique<ReferrerChain>(); 1876 base::MakeUnique<ReferrerChain>();
1877 int download_tab_id = SessionTabHelper::IdForTab(web_contents); 1877 int download_tab_id = SessionTabHelper::IdForTab(web_contents);
1878 UMA_HISTOGRAM_BOOLEAN( 1878 UMA_HISTOGRAM_BOOLEAN(
1879 "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution", 1879 "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution",
1880 download_tab_id == -1); 1880 download_tab_id == -1);
1881 // We look for the referrer chain that leads to the download url first. 1881 // We look for the referrer chain that leads to the download url first.
1882 SafeBrowsingNavigationObserverManager::AttributionResult result = 1882 SafeBrowsingNavigationObserverManager::AttributionResult result =
1883 navigation_observer_manager_->IdentifyReferrerChainForDownload( 1883 navigation_observer_manager_->IdentifyReferrerChainByEventURL(
1884 download_url, 1884 download_url, download_tab_id, kDownloadAttributionUserGestureLimit,
1885 download_tab_id,
1886 kDownloadAttributionUserGestureLimit,
1887 referrer_chain.get()); 1885 referrer_chain.get());
1888 1886
1889 // If no navigation event is found, this download is not triggered by regular 1887 // If no navigation event is found, this download is not triggered by regular
1890 // navigation (e.g. html5 file apis, etc). We look for the referrer chain 1888 // navigation (e.g. html5 file apis, etc). We look for the referrer chain
1891 // based on relevant WebContents instead. 1889 // based on relevant WebContents instead.
1892 if (result == 1890 if (result ==
1893 SafeBrowsingNavigationObserverManager::NAVIGATION_EVENT_NOT_FOUND && 1891 SafeBrowsingNavigationObserverManager::NAVIGATION_EVENT_NOT_FOUND &&
1894 web_contents && web_contents->GetLastCommittedURL().is_valid()) { 1892 web_contents && web_contents->GetLastCommittedURL().is_valid()) {
1895 result = 1893 result = navigation_observer_manager_->IdentifyReferrerChainByWebContents(
1896 navigation_observer_manager_->IdentifyReferrerChainByDownloadWebContent( 1894 web_contents, kDownloadAttributionUserGestureLimit,
1897 web_contents, kDownloadAttributionUserGestureLimit, 1895 referrer_chain.get());
1898 referrer_chain.get());
1899 } 1896 }
1900 1897
1901 UMA_HISTOGRAM_COUNTS_100( 1898 UMA_HISTOGRAM_COUNTS_100(
1902 "SafeBrowsing.ReferrerURLChainSize.DownloadAttribution", 1899 "SafeBrowsing.ReferrerURLChainSize.DownloadAttribution",
1903 referrer_chain->size()); 1900 referrer_chain->size());
1904 UMA_HISTOGRAM_ENUMERATION( 1901 UMA_HISTOGRAM_ENUMERATION(
1905 "SafeBrowsing.ReferrerAttributionResult.DownloadAttribution", result, 1902 "SafeBrowsing.ReferrerAttributionResult.DownloadAttribution", result,
1906 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); 1903 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
1907 return referrer_chain; 1904 return referrer_chain;
1908 } 1905 }
1909 1906
1910 void DownloadProtectionService::AddReferrerChainToPPAPIClientDownloadRequest( 1907 void DownloadProtectionService::AddReferrerChainToPPAPIClientDownloadRequest(
1911 const GURL& initiating_frame_url, 1908 const GURL& initiating_frame_url,
1912 const GURL& initiating_main_frame_url, 1909 const GURL& initiating_main_frame_url,
1913 int tab_id, 1910 int tab_id,
1914 bool has_user_gesture, 1911 bool has_user_gesture,
1915 ClientDownloadRequest* out_request) { 1912 ClientDownloadRequest* out_request) {
1916 if (!base::FeatureList::IsEnabled( 1913 if (!base::FeatureList::IsEnabled(
1917 SafeBrowsingNavigationObserverManager::kDownloadAttribution) || 1914 SafeBrowsingNavigationObserverManager::kDownloadAttribution) ||
1918 !navigation_observer_manager_) { 1915 !navigation_observer_manager_) {
1919 return; 1916 return;
1920 } 1917 }
1921 1918
1922 UMA_HISTOGRAM_BOOLEAN( 1919 UMA_HISTOGRAM_BOOLEAN(
1923 "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution", 1920 "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution",
1924 tab_id == -1); 1921 tab_id == -1);
1925 SafeBrowsingNavigationObserverManager::AttributionResult result = 1922 SafeBrowsingNavigationObserverManager::AttributionResult result =
1926 navigation_observer_manager_->IdentifyReferrerChainForDownloadHostingPage( 1923 navigation_observer_manager_->IdentifyReferrerChainByHostingPage(
1927 initiating_frame_url, initiating_main_frame_url, tab_id, 1924 initiating_frame_url, initiating_main_frame_url, tab_id,
1928 has_user_gesture, kDownloadAttributionUserGestureLimit, 1925 has_user_gesture, kDownloadAttributionUserGestureLimit,
1929 out_request->mutable_referrer_chain()); 1926 out_request->mutable_referrer_chain());
1930 UMA_HISTOGRAM_COUNTS_100( 1927 UMA_HISTOGRAM_COUNTS_100(
1931 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution", 1928 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution",
1932 out_request->referrer_chain_size()); 1929 out_request->referrer_chain_size());
1933 UMA_HISTOGRAM_ENUMERATION( 1930 UMA_HISTOGRAM_ENUMERATION(
1934 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result, 1931 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result,
1935 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); 1932 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
1936 out_request->set_download_attribution_finch_enabled(true); 1933 out_request->set_download_attribution_finch_enabled(true);
1937 } 1934 }
1938 1935
1939 } // namespace safe_browsing 1936 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_navigation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698