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

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

Issue 2644133005: Include all server redirects in referrer chain (Closed)
Patch Set: proto change and adding two histograms Created 3 years, 10 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
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 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 const GURL& initiating_frame_url, 1233 const GURL& initiating_frame_url,
1234 content::WebContents* web_contents, 1234 content::WebContents* web_contents,
1235 const base::FilePath& default_file_path, 1235 const base::FilePath& default_file_path,
1236 const std::vector<base::FilePath::StringType>& alternate_extensions, 1236 const std::vector<base::FilePath::StringType>& alternate_extensions,
1237 Profile* profile, 1237 Profile* profile,
1238 const CheckDownloadCallback& callback, 1238 const CheckDownloadCallback& callback,
1239 DownloadProtectionService* service, 1239 DownloadProtectionService* service,
1240 scoped_refptr<SafeBrowsingDatabaseManager> database_manager) 1240 scoped_refptr<SafeBrowsingDatabaseManager> database_manager)
1241 : requestor_url_(requestor_url), 1241 : requestor_url_(requestor_url),
1242 initiating_frame_url_(initiating_frame_url), 1242 initiating_frame_url_(initiating_frame_url),
1243 initiating_main_frame_url_(
1244 web_contents ? web_contents->GetLastCommittedURL():GURL()),
Nathan Parker 2017/01/27 22:53:37 nit: add spaces around :
Jialiu Lin 2017/01/27 23:25:06 Done.
1243 tab_id_(SessionTabHelper::IdForTab(web_contents)), 1245 tab_id_(SessionTabHelper::IdForTab(web_contents)),
1244 default_file_path_(default_file_path), 1246 default_file_path_(default_file_path),
1245 alternate_extensions_(alternate_extensions), 1247 alternate_extensions_(alternate_extensions),
1246 callback_(callback), 1248 callback_(callback),
1247 service_(service), 1249 service_(service),
1248 database_manager_(database_manager), 1250 database_manager_(database_manager),
1249 start_time_(base::TimeTicks::Now()), 1251 start_time_(base::TimeTicks::Now()),
1250 supported_path_( 1252 supported_path_(
1251 GetSupportedFilePath(default_file_path, alternate_extensions)), 1253 GetSupportedFilePath(default_file_path, alternate_extensions)),
1252 weakptr_factory_(this) { 1254 weakptr_factory_(this) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 *(request.add_alternate_extensions()) = 1369 *(request.add_alternate_extensions()) =
1368 base::FilePath(alternate_extension).AsUTF8Unsafe(); 1370 base::FilePath(alternate_extension).AsUTF8Unsafe();
1369 } 1371 }
1370 if (supported_path_ != default_file_path_) { 1372 if (supported_path_ != default_file_path_) {
1371 *(request.add_alternate_extensions()) = 1373 *(request.add_alternate_extensions()) =
1372 base::FilePath(default_file_path_.FinalExtension()).AsUTF8Unsafe(); 1374 base::FilePath(default_file_path_.FinalExtension()).AsUTF8Unsafe();
1373 } 1375 }
1374 1376
1375 service_->AddReferrerChainToPPAPIClientDownloadRequest( 1377 service_->AddReferrerChainToPPAPIClientDownloadRequest(
1376 initiating_frame_url_, 1378 initiating_frame_url_,
1379 initiating_main_frame_url_,
1377 tab_id_, 1380 tab_id_,
1378 has_user_gesture_, 1381 has_user_gesture_,
1379 &request); 1382 &request);
1380 1383
1381 if (!request.SerializeToString(&client_download_request_data_)) { 1384 if (!request.SerializeToString(&client_download_request_data_)) {
1382 // More of an internal error than anything else. Note that the UNKNOWN 1385 // More of an internal error than anything else. Note that the UNKNOWN
1383 // verdict gets interpreted as "allowed". 1386 // verdict gets interpreted as "allowed".
1384 Finish(RequestOutcome::REQUEST_MALFORMED, UNKNOWN); 1387 Finish(RequestOutcome::REQUEST_MALFORMED, UNKNOWN);
1385 return; 1388 return;
1386 } 1389 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 1496
1494 return base::FilePath(); 1497 return base::FilePath();
1495 } 1498 }
1496 1499
1497 std::unique_ptr<net::URLFetcher> fetcher_; 1500 std::unique_ptr<net::URLFetcher> fetcher_;
1498 std::string client_download_request_data_; 1501 std::string client_download_request_data_;
1499 1502
1500 // URL of document that requested the PPAPI download. 1503 // URL of document that requested the PPAPI download.
1501 const GURL requestor_url_; 1504 const GURL requestor_url_;
1502 1505
1503 // URL of the frame that hosted the PPAPI plugin. 1506 // URL of the frame that hosts the PPAPI plugin.
1504 const GURL initiating_frame_url_; 1507 const GURL initiating_frame_url_;
1505 1508
1509 // URL of the tab that contains the initialting_frame.
1510 const GURL initiating_main_frame_url_;
1511
1506 // Tab id that associated with the PPAPI plugin, computed by 1512 // Tab id that associated with the PPAPI plugin, computed by
1507 // SessionTabHelper::IdForTab(). 1513 // SessionTabHelper::IdForTab().
1508 int tab_id_; 1514 int tab_id_;
1509 1515
1510 // If the user interacted with this PPAPI plugin to trigger the download. 1516 // If the user interacted with this PPAPI plugin to trigger the download.
1511 bool has_user_gesture_; 1517 bool has_user_gesture_;
1512 1518
1513 // Default download path requested by the PPAPI plugin. 1519 // Default download path requested by the PPAPI plugin.
1514 const base::FilePath default_file_path_; 1520 const base::FilePath default_file_path_;
1515 1521
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 download_url, 1846 download_url,
1841 download_tab_id, 1847 download_tab_id,
1842 kDownloadAttributionUserGestureLimit, 1848 kDownloadAttributionUserGestureLimit,
1843 &attribution_chain); 1849 &attribution_chain);
1844 UMA_HISTOGRAM_COUNTS_100( 1850 UMA_HISTOGRAM_COUNTS_100(
1845 "SafeBrowsing.ReferrerURLChainSize.DownloadAttribution", 1851 "SafeBrowsing.ReferrerURLChainSize.DownloadAttribution",
1846 attribution_chain.size()); 1852 attribution_chain.size());
1847 UMA_HISTOGRAM_ENUMERATION( 1853 UMA_HISTOGRAM_ENUMERATION(
1848 "SafeBrowsing.ReferrerAttributionResult.DownloadAttribution", result, 1854 "SafeBrowsing.ReferrerAttributionResult.DownloadAttribution", result,
1849 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); 1855 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
1856 out_request->set_download_attribution_finch_enabled(true);
1850 for (auto& entry : attribution_chain) 1857 for (auto& entry : attribution_chain)
1851 out_request->add_referrer_chain()->Swap(entry.get()); 1858 out_request->add_referrer_chain()->Swap(entry.get());
1852 } 1859 }
1853 1860
1854 void DownloadProtectionService::AddReferrerChainToPPAPIClientDownloadRequest( 1861 void DownloadProtectionService::AddReferrerChainToPPAPIClientDownloadRequest(
1855 const GURL& initiating_frame_url, 1862 const GURL& initiating_frame_url,
1863 const GURL& initiating_main_frame_url,
1856 int tab_id, 1864 int tab_id,
1857 bool has_user_gesture, 1865 bool has_user_gesture,
1858 ClientDownloadRequest* out_request) { 1866 ClientDownloadRequest* out_request) {
1859 if (!base::FeatureList::IsEnabled( 1867 if (!base::FeatureList::IsEnabled(
1860 SafeBrowsingNavigationObserverManager::kDownloadAttribution) || 1868 SafeBrowsingNavigationObserverManager::kDownloadAttribution) ||
1861 !navigation_observer_manager_) { 1869 !navigation_observer_manager_) {
1862 return; 1870 return;
1863 } 1871 }
1864 1872
1865 UMA_HISTOGRAM_BOOLEAN( 1873 UMA_HISTOGRAM_BOOLEAN(
1866 "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution", 1874 "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution",
1867 tab_id == -1); 1875 tab_id == -1);
1868 SafeBrowsingNavigationObserverManager::ReferrerChain attribution_chain; 1876 SafeBrowsingNavigationObserverManager::ReferrerChain attribution_chain;
1869 SafeBrowsingNavigationObserverManager::AttributionResult result = 1877 SafeBrowsingNavigationObserverManager::AttributionResult result =
1870 navigation_observer_manager_->IdentifyReferrerChainForPPAPIDownload( 1878 navigation_observer_manager_->IdentifyReferrerChainForPPAPIDownload(
1871 initiating_frame_url, 1879 initiating_frame_url,
1880 initiating_main_frame_url,
1872 tab_id, 1881 tab_id,
1873 has_user_gesture, 1882 has_user_gesture,
1874 kDownloadAttributionUserGestureLimit, 1883 kDownloadAttributionUserGestureLimit,
1875 &attribution_chain); 1884 &attribution_chain);
1876 UMA_HISTOGRAM_COUNTS_100( 1885 UMA_HISTOGRAM_COUNTS_100(
1877 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution", 1886 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution",
1878 attribution_chain.size()); 1887 attribution_chain.size());
1879 UMA_HISTOGRAM_ENUMERATION( 1888 UMA_HISTOGRAM_ENUMERATION(
1880 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result, 1889 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result,
1881 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); 1890 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
1891 out_request->set_download_attribution_finch_enabled(true);
1882 for (auto& entry : attribution_chain) 1892 for (auto& entry : attribution_chain)
1883 out_request->add_referrer_chain()->Swap(entry.get()); 1893 out_request->add_referrer_chain()->Swap(entry.get());
1884 } 1894 }
1885 1895
1886 } // namespace safe_browsing 1896 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698