0001-fix-building-without-safebrowsing.patch 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  1. --- a/chrome/browser/BUILD.gn
  2. +++ b/chrome/browser/BUILD.gn
  3. @@ -2388,7 +2388,6 @@ static_library("browser") {
  4. "//components/reporting/util:task_runner_context",
  5. "//components/resources",
  6. "//components/safe_browsing/content/browser",
  7. - "//components/safe_browsing/content/browser:client_side_detection",
  8. "//components/safe_browsing/content/browser:safe_browsing_service",
  9. "//components/safe_browsing/content/browser/password_protection",
  10. "//components/safe_browsing/content/browser/web_ui",
  11. @@ -3809,8 +3808,6 @@ static_library("browser") {
  12. "download/download_commands.h",
  13. "download/download_crx_util.cc",
  14. "download/download_crx_util.h",
  15. - "download/download_danger_prompt.cc",
  16. - "download/download_danger_prompt.h",
  17. "download/download_dir_policy_handler.cc",
  18. "download/download_dir_policy_handler.h",
  19. "download/download_dir_util.cc",
  20. --- a/chrome/browser/browser_process.h
  21. +++ b/chrome/browser/browser_process.h
  22. @@ -55,10 +55,6 @@ class NetworkQualityTracker;
  23. class SharedURLLoaderFactory;
  24. }
  25. -namespace safe_browsing {
  26. -class SafeBrowsingService;
  27. -}
  28. -
  29. namespace subresource_filter {
  30. class RulesetService;
  31. }
  32. @@ -219,9 +215,6 @@ class BrowserProcess {
  33. // on this platform (or this is a unit test).
  34. virtual StatusTray* status_tray() = 0;
  35. - // Returns the SafeBrowsing service.
  36. - virtual safe_browsing::SafeBrowsingService* safe_browsing_service() = 0;
  37. -
  38. // Returns the service providing versioned storage for rules used by the Safe
  39. // Browsing subresource filter.
  40. virtual subresource_filter::RulesetService*
  41. --- a/chrome/browser/browser_process_impl.cc
  42. +++ b/chrome/browser/browser_process_impl.cc
  43. @@ -71,7 +71,6 @@
  44. #include "chrome/browser/printing/print_job_manager.h"
  45. #include "chrome/browser/profiles/profile_manager.h"
  46. #include "chrome/browser/resource_coordinator/resource_coordinator_parts.h"
  47. -#include "chrome/browser/safe_browsing/safe_browsing_service.h"
  48. #include "chrome/browser/shell_integration.h"
  49. #include "chrome/browser/site_isolation/prefs_observer.h"
  50. #include "chrome/browser/ssl/secure_origin_prefs_observer.h"
  51. @@ -436,8 +435,6 @@ void BrowserProcessImpl::StartTearDown()
  52. #endif
  53. metrics_services_manager_.reset();
  54. intranet_redirect_detector_.reset();
  55. - if (safe_browsing_service_.get())
  56. - safe_browsing_service()->ShutDown();
  57. network_time_tracker_.reset();
  58. #if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
  59. @@ -1084,14 +1081,6 @@ StatusTray* BrowserProcessImpl::status_t
  60. return status_tray_.get();
  61. }
  62. -safe_browsing::SafeBrowsingService*
  63. -BrowserProcessImpl::safe_browsing_service() {
  64. - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  65. - if (!created_safe_browsing_service_)
  66. - CreateSafeBrowsingService();
  67. - return safe_browsing_service_.get();
  68. -}
  69. -
  70. subresource_filter::RulesetService*
  71. BrowserProcessImpl::subresource_filter_ruleset_service() {
  72. DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  73. @@ -1336,26 +1325,6 @@ void BrowserProcessImpl::CreateBackgroun
  74. #endif
  75. }
  76. -void BrowserProcessImpl::CreateSafeBrowsingService() {
  77. - DCHECK(!safe_browsing_service_);
  78. - // Set this flag to true so that we don't retry indefinitely to
  79. - // create the service class if there was an error.
  80. - created_safe_browsing_service_ = true;
  81. -
  82. - // The factory can be overridden in tests.
  83. - if (!safe_browsing::SafeBrowsingServiceInterface::HasFactory()) {
  84. - safe_browsing::SafeBrowsingServiceInterface::RegisterFactory(
  85. - safe_browsing::GetSafeBrowsingServiceFactory());
  86. - }
  87. -
  88. - // TODO(crbug/925153): Port consumers of the |safe_browsing_service_| to use
  89. - // the interface in components/safe_browsing, and remove this cast.
  90. - safe_browsing_service_ = static_cast<safe_browsing::SafeBrowsingService*>(
  91. - safe_browsing::SafeBrowsingServiceInterface::CreateSafeBrowsingService());
  92. - if (safe_browsing_service_)
  93. - safe_browsing_service_->Initialize();
  94. -}
  95. -
  96. void BrowserProcessImpl::CreateSubresourceFilterRulesetService() {
  97. DCHECK(!subresource_filter_ruleset_service_);
  98. created_subresource_filter_ruleset_service_ = true;
  99. --- a/chrome/browser/browser_process_impl.h
  100. +++ b/chrome/browser/browser_process_impl.h
  101. @@ -195,7 +195,6 @@ class BrowserProcessImpl : public Browse
  102. std::unique_ptr<BackgroundModeManager> manager) override;
  103. #endif
  104. StatusTray* status_tray() override;
  105. - safe_browsing::SafeBrowsingService* safe_browsing_service() override;
  106. subresource_filter::RulesetService* subresource_filter_ruleset_service()
  107. override;
  108. @@ -355,9 +354,6 @@ class BrowserProcessImpl : public Browse
  109. std::unique_ptr<BackgroundModeManager> background_mode_manager_;
  110. #endif
  111. - bool created_safe_browsing_service_ = false;
  112. - scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service_;
  113. -
  114. bool created_subresource_filter_ruleset_service_ = false;
  115. std::unique_ptr<subresource_filter::RulesetService>
  116. subresource_filter_ruleset_service_;
  117. --- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc
  118. +++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc
  119. @@ -66,7 +66,6 @@
  120. #include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h"
  121. #include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h"
  122. #include "chrome/browser/profiles/profile.h"
  123. -#include "chrome/browser/safe_browsing/safe_browsing_service.h"
  124. #include "chrome/browser/safe_browsing/verdict_cache_manager_factory.h"
  125. #include "chrome/browser/search_engines/template_url_service_factory.h"
  126. #include "chrome/browser/share/share_history.h"
  127. @@ -627,10 +626,6 @@ void ChromeBrowsingDataRemoverDelegate::
  128. base::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies"));
  129. network::mojom::NetworkContext* safe_browsing_context = nullptr;
  130. - safe_browsing::SafeBrowsingService* sb_service =
  131. - g_browser_process->safe_browsing_service();
  132. - if (sb_service)
  133. - safe_browsing_context = sb_service->GetNetworkContext(profile_);
  134. // Cleared for DATA_TYPE_HISTORY, DATA_TYPE_COOKIES and DATA_TYPE_PASSWORDS.
  135. browsing_data::RemoveFederatedSiteSettingsData(delete_begin_, delete_end_,
  136. --- a/chrome/browser/chrome_content_browser_client.cc
  137. +++ b/chrome/browser/chrome_content_browser_client.cc
  138. @@ -1063,34 +1063,6 @@ void SetApplicationLocaleOnIOThread(cons
  139. GetIOThreadApplicationLocale() = locale;
  140. }
  141. -// An implementation of the SSLCertReporter interface used by
  142. -// SSLErrorHandler. Uses CertificateReportingService to send reports. The
  143. -// service handles queueing and re-sending of failed reports. Each certificate
  144. -// error creates a new instance of this class.
  145. -class CertificateReportingServiceCertReporter : public SSLCertReporter {
  146. - public:
  147. - explicit CertificateReportingServiceCertReporter(
  148. - content::WebContents* web_contents)
  149. - : service_(CertificateReportingServiceFactory::GetForBrowserContext(
  150. - web_contents->GetBrowserContext())) {}
  151. -
  152. - CertificateReportingServiceCertReporter(
  153. - const CertificateReportingServiceCertReporter&) = delete;
  154. - CertificateReportingServiceCertReporter& operator=(
  155. - const CertificateReportingServiceCertReporter&) = delete;
  156. -
  157. - ~CertificateReportingServiceCertReporter() override {}
  158. -
  159. - // SSLCertReporter implementation
  160. - void ReportInvalidCertificateChain(
  161. - const std::string& serialized_report) override {
  162. - service_->Send(serialized_report);
  163. - }
  164. -
  165. - private:
  166. - raw_ptr<CertificateReportingService> service_;
  167. -};
  168. -
  169. #if BUILDFLAG(ENABLE_EXTENSIONS)
  170. AppLoadedInTabSource ClassifyAppLoadedInTabSource(
  171. @@ -5201,14 +5173,9 @@ ChromeContentBrowserClient::CreateThrott
  172. throttles.push_back(std::make_unique<PolicyBlocklistNavigationThrottle>(
  173. handle, handle->GetWebContents()->GetBrowserContext()));
  174. - // Before setting up SSL error detection, configure SSLErrorHandler to invoke
  175. - // the relevant extension API whenever an SSL interstitial is shown.
  176. - SSLErrorHandler::SetClientCallbackOnInterstitialsShown(
  177. - base::BindRepeating(&MaybeTriggerSecurityInterstitialShownEvent));
  178. - content::WebContents* web_contents = handle->GetWebContents();
  179. throttles.push_back(std::make_unique<SSLErrorNavigationThrottle>(
  180. handle,
  181. - std::make_unique<CertificateReportingServiceCertReporter>(web_contents),
  182. + nullptr,
  183. base::BindOnce(&HandleSSLErrorWrapper), base::BindOnce(&IsInHostedApp),
  184. base::BindOnce(
  185. &ShouldIgnoreSslInterstitialBecauseNavigationDefaultedToHttps)));
  186. @@ -5254,16 +5221,6 @@ ChromeContentBrowserClient::CreateThrott
  187. &throttles);
  188. #endif
  189. - // g_browser_process->safe_browsing_service() may be null in unittests.
  190. - safe_browsing::SafeBrowsingUIManager* ui_manager =
  191. - g_browser_process->safe_browsing_service()
  192. - ? g_browser_process->safe_browsing_service()->ui_manager().get()
  193. - : nullptr;
  194. - MaybeAddThrottle(
  195. - safe_browsing::SafeBrowsingNavigationThrottle::MaybeCreateThrottleFor(
  196. - handle, ui_manager),
  197. - &throttles);
  198. -
  199. if (base::FeatureList::IsEnabled(safe_browsing::kDelayedWarnings)) {
  200. throttles.push_back(
  201. std::make_unique<safe_browsing::DelayedWarningNavigationThrottle>(
  202. @@ -5542,8 +5499,6 @@ void ChromeContentBrowserClient::Overrid
  203. void ChromeContentBrowserClient::InitOnUIThread() {
  204. DCHECK_CURRENTLY_ON(BrowserThread::UI);
  205. - safe_browsing_service_ = g_browser_process->safe_browsing_service();
  206. -
  207. // Initialize `network_contexts_parent_directory_`.
  208. base::FilePath user_data_dir;
  209. base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
  210. --- a/chrome/browser/component_updater/file_type_policies_component_installer.cc
  211. +++ b/chrome/browser/component_updater/file_type_policies_component_installer.cc
  212. @@ -38,20 +38,6 @@ const uint8_t kFileTypePoliciesPublicKey
  213. const char kFileTypePoliciesManifestName[] = "File Type Policies";
  214. void LoadFileTypesFromDisk(const base::FilePath& pb_path) {
  215. - if (pb_path.empty())
  216. - return;
  217. -
  218. - VLOG(1) << "Reading Download File Types from file: " << pb_path.value();
  219. - std::string binary_pb;
  220. - if (!base::ReadFileToString(pb_path, &binary_pb)) {
  221. - // The file won't exist on new installations, so this is not always an
  222. - // error.
  223. - VLOG(1) << "Failed reading from " << pb_path.value();
  224. - return;
  225. - }
  226. -
  227. - safe_browsing::FileTypePolicies::GetInstance()->PopulateFromDynamicUpdate(
  228. - binary_pb);
  229. }
  230. } // namespace
  231. --- a/chrome/browser/download/chrome_download_manager_delegate.cc
  232. +++ b/chrome/browser/download/chrome_download_manager_delegate.cc
  233. @@ -473,13 +473,6 @@ void ChromeDownloadManagerDelegate::SetD
  234. download_manager_ = dm;
  235. - safe_browsing::SafeBrowsingService* sb_service =
  236. - g_browser_process->safe_browsing_service();
  237. - if (sb_service && !profile_->IsOffTheRecord()) {
  238. - // Include this download manager in the set monitored by safe browsing.
  239. - sb_service->AddDownloadManager(dm);
  240. - }
  241. -
  242. if (download_manager_) {
  243. download_manager_->AddObserver(this);
  244. }
  245. @@ -875,17 +868,6 @@ void ChromeDownloadManagerDelegate::Choo
  246. void ChromeDownloadManagerDelegate::SanitizeSavePackageResourceName(
  247. base::FilePath* filename,
  248. const GURL& source_url) {
  249. - safe_browsing::FileTypePolicies* file_type_policies =
  250. - safe_browsing::FileTypePolicies::GetInstance();
  251. -
  252. - const PrefService* prefs = profile_->GetPrefs();
  253. - if (file_type_policies->GetFileDangerLevel(*filename, source_url, prefs) ==
  254. - safe_browsing::DownloadFileType::NOT_DANGEROUS)
  255. - return;
  256. -
  257. - base::FilePath default_filename = base::FilePath::FromUTF8Unsafe(
  258. - l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
  259. - *filename = filename->AddExtension(default_filename.BaseName().value());
  260. }
  261. void ChromeDownloadManagerDelegate::SanitizeDownloadParameters(
  262. --- a/chrome/browser/download/download_item_model.cc
  263. +++ b/chrome/browser/download/download_item_model.cc
  264. @@ -109,7 +109,7 @@ class DownloadItemModelData : public bas
  265. // Danger level of the file determined based on the file type and whether
  266. // there was a user action associated with the download.
  267. - DownloadFileType::DangerLevel danger_level_;
  268. + safe_browsing::DownloadFileType::DangerLevel danger_level_;
  269. // Whether the download is currently being revived.
  270. bool is_being_revived_;
  271. @@ -159,7 +159,7 @@ DownloadItemModelData* DownloadItemModel
  272. DownloadItemModelData::DownloadItemModelData()
  273. : should_show_in_shelf_(true),
  274. was_ui_notified_(false),
  275. - danger_level_(DownloadFileType::NOT_DANGEROUS),
  276. + danger_level_(safe_browsing::DownloadFileType::NOT_DANGEROUS),
  277. is_being_revived_(false) {}
  278. #if BUILDFLAG(FULL_SAFE_BROWSING)
  279. @@ -534,13 +534,13 @@ void DownloadItemModel::SetShouldPreferO
  280. data->should_prefer_opening_in_browser_ = preference;
  281. }
  282. -DownloadFileType::DangerLevel DownloadItemModel::GetDangerLevel() const {
  283. +safe_browsing::DownloadFileType::DangerLevel DownloadItemModel::GetDangerLevel() const {
  284. const DownloadItemModelData* data = DownloadItemModelData::Get(download_);
  285. - return data ? data->danger_level_ : DownloadFileType::NOT_DANGEROUS;
  286. + return data ? data->danger_level_ : safe_browsing::DownloadFileType::NOT_DANGEROUS;
  287. }
  288. void DownloadItemModel::SetDangerLevel(
  289. - DownloadFileType::DangerLevel danger_level) {
  290. + safe_browsing::DownloadFileType::DangerLevel danger_level) {
  291. DownloadItemModelData* data = DownloadItemModelData::GetOrCreate(download_);
  292. data->danger_level_ = danger_level;
  293. }
  294. @@ -717,9 +717,6 @@ bool DownloadItemModel::IsCommandEnabled
  295. // filename. Don't base an "Always open" decision based on it. Also
  296. // exclude extensions.
  297. return download_->CanOpenDownload() &&
  298. - safe_browsing::FileTypePolicies::GetInstance()
  299. - ->IsAllowedToOpenAutomatically(
  300. - download_->GetTargetFilePath()) &&
  301. !download_crx_util::IsExtensionDownload(*download_);
  302. case DownloadCommands::PAUSE:
  303. return !download_->IsSavePackageDownload() &&
  304. --- a/chrome/browser/download/download_prefs.cc
  305. +++ b/chrome/browser/download/download_prefs.cc
  306. @@ -263,14 +263,7 @@ DownloadPrefs::DownloadPrefs(Profile* pr
  307. base::FilePath::StringType(1, base::FilePath::kExtensionSeparator) +
  308. extension);
  309. - // Note that the list of file types that are not allowed to open
  310. - // automatically can change in the future. When the list is tightened, it is
  311. - // expected that some entries in the users' auto open list will get dropped
  312. - // permanently as a result.
  313. - if (FileTypePolicies::GetInstance()->IsAllowedToOpenAutomatically(
  314. - filename_with_extension)) {
  315. - auto_open_by_user_.insert(extension);
  316. - }
  317. + auto_open_by_user_.insert(extension);
  318. }
  319. }
  320. @@ -449,10 +442,6 @@ bool DownloadPrefs::IsAutoOpenByPolicy(c
  321. bool DownloadPrefs::EnableAutoOpenByUserBasedOnExtension(
  322. const base::FilePath& file_name) {
  323. base::FilePath::StringType extension = file_name.Extension();
  324. - if (!FileTypePolicies::GetInstance()->IsAllowedToOpenAutomatically(
  325. - file_name)) {
  326. - return false;
  327. - }
  328. DCHECK(extension[0] == base::FilePath::kExtensionSeparator);
  329. extension.erase(0, 1);
  330. --- a/chrome/browser/download/download_target_determiner.cc
  331. +++ b/chrome/browser/download/download_target_determiner.cc
  332. @@ -323,13 +323,6 @@ base::FilePath DownloadTargetDeterminer:
  333. download_->GetURL(), download_->GetContentDisposition(), referrer_charset,
  334. suggested_filename, sniffed_mime_type, default_filename);
  335. - // We don't replace the file extension if sfafe browsing consider the file
  336. - // extension to be unsafe. Just let safe browsing scan the generated file.
  337. - if (safe_browsing::FileTypePolicies::GetInstance()->IsCheckedBinaryFile(
  338. - generated_filename)) {
  339. - return generated_filename;
  340. - }
  341. -
  342. // If no mime type or explicitly specified a name, don't replace file
  343. // extension.
  344. if (sniffed_mime_type.empty() || !suggested_filename.empty())
  345. @@ -1272,30 +1265,7 @@ DownloadFileType::DangerLevel DownloadTa
  346. download_->HasUserGesture())
  347. return DownloadFileType::NOT_DANGEROUS;
  348. - DownloadFileType::DangerLevel danger_level =
  349. - safe_browsing::FileTypePolicies::GetInstance()->GetFileDangerLevel(
  350. - virtual_path_.BaseName(), download_->GetURL(),
  351. - GetProfile()->GetPrefs());
  352. -
  353. - // A danger level of ALLOW_ON_USER_GESTURE is used to label potentially
  354. - // dangerous file types that have a high frequency of legitimate use. We would
  355. - // like to avoid prompting for the legitimate cases as much as possible. To
  356. - // that end, we consider a download to be legitimate if one of the following
  357. - // is true, and avoid prompting:
  358. - //
  359. - // * The user navigated to the download URL via the omnibox (either by typing
  360. - // the URL, pasting it, or using search).
  361. - //
  362. - // * The navigation that initiated the download has a user gesture associated
  363. - // with it AND the user the user is familiar with the referring origin. A
  364. - // user is considered familiar with a referring origin if a visit for a page
  365. - // from the same origin was recorded on the previous day or earlier.
  366. - if (danger_level == DownloadFileType::ALLOW_ON_USER_GESTURE &&
  367. - ((download_->GetTransitionType() &
  368. - ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) != 0 ||
  369. - (download_->HasUserGesture() && visits == VISITED_REFERRER)))
  370. - return DownloadFileType::NOT_DANGEROUS;
  371. - return danger_level;
  372. + return DownloadFileType::NOT_DANGEROUS;
  373. }
  374. absl::optional<base::Time>
  375. --- a/chrome/browser/extensions/api/downloads/downloads_api.cc
  376. +++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
  377. @@ -37,7 +37,6 @@
  378. #include "chrome/browser/download/bubble/download_bubble_ui_controller.h"
  379. #include "chrome/browser/download/download_core_service.h"
  380. #include "chrome/browser/download/download_core_service_factory.h"
  381. -#include "chrome/browser/download/download_danger_prompt.h"
  382. #include "chrome/browser/download/download_file_icon_extractor.h"
  383. #include "chrome/browser/download/download_open_prompt.h"
  384. #include "chrome/browser/download/download_prefs.h"
  385. @@ -1368,9 +1367,6 @@ DownloadsAcceptDangerFunction::Downloads
  386. DownloadsAcceptDangerFunction::~DownloadsAcceptDangerFunction() {}
  387. -DownloadsAcceptDangerFunction::OnPromptCreatedCallback*
  388. - DownloadsAcceptDangerFunction::on_prompt_created_ = nullptr;
  389. -
  390. ExtensionFunction::ResponseAction DownloadsAcceptDangerFunction::Run() {
  391. absl::optional<downloads::AcceptDanger::Params> params =
  392. downloads::AcceptDanger::Params::Create(args());
  393. @@ -1408,42 +1404,7 @@ void DownloadsAcceptDangerFunction::Prom
  394. return;
  395. }
  396. RecordApiFunctions(DOWNLOADS_FUNCTION_ACCEPT_DANGER);
  397. - // DownloadDangerPrompt displays a modal dialog using native widgets that the
  398. - // user must either accept or cancel. It cannot be scripted.
  399. - DownloadDangerPrompt* prompt = DownloadDangerPrompt::Create(
  400. - download_item, web_contents, true,
  401. - base::BindOnce(&DownloadsAcceptDangerFunction::DangerPromptCallback, this,
  402. - download_id));
  403. - // DownloadDangerPrompt deletes itself
  404. - if (on_prompt_created_ && !on_prompt_created_->is_null())
  405. - std::move(*on_prompt_created_).Run(prompt);
  406. - // Function finishes in DangerPromptCallback().
  407. -}
  408. -
  409. -void DownloadsAcceptDangerFunction::DangerPromptCallback(
  410. - int download_id,
  411. - DownloadDangerPrompt::Action action) {
  412. - DCHECK_CURRENTLY_ON(BrowserThread::UI);
  413. - DownloadItem* download_item = GetDownload(
  414. - browser_context(), include_incognito_information(), download_id);
  415. - std::string error;
  416. - if (InvalidId(download_item, &error) ||
  417. - Fault(download_item->GetState() != DownloadItem::IN_PROGRESS,
  418. - download_extension_errors::kNotInProgress, &error)) {
  419. - Respond(Error(std::move(error)));
  420. - return;
  421. - }
  422. - switch (action) {
  423. - case DownloadDangerPrompt::ACCEPT:
  424. - download_item->ValidateDangerousDownload();
  425. - break;
  426. - case DownloadDangerPrompt::CANCEL:
  427. - download_item->Remove();
  428. - break;
  429. - case DownloadDangerPrompt::DISMISS:
  430. - break;
  431. - }
  432. - Respond(NoArguments());
  433. + download_item->ValidateDangerousDownload();
  434. }
  435. DownloadsShowFunction::DownloadsShowFunction() {}
  436. --- a/chrome/browser/extensions/api/downloads/downloads_api.h
  437. +++ b/chrome/browser/extensions/api/downloads/downloads_api.h
  438. @@ -13,7 +13,6 @@
  439. #include "base/memory/raw_ptr.h"
  440. #include "base/scoped_observation.h"
  441. #include "base/time/time.h"
  442. -#include "chrome/browser/download/download_danger_prompt.h"
  443. #include "chrome/common/extensions/api/downloads.h"
  444. #include "components/download/content/public/all_download_item_notifier.h"
  445. #include "components/download/public/common/download_path_reservation_tracker.h"
  446. @@ -201,13 +200,6 @@ class DownloadsRemoveFileFunction : publ
  447. class DownloadsAcceptDangerFunction : public ExtensionFunction {
  448. public:
  449. - using OnPromptCreatedCallback =
  450. - base::OnceCallback<void(DownloadDangerPrompt*)>;
  451. - static void OnPromptCreatedForTesting(
  452. - OnPromptCreatedCallback* callback) {
  453. - on_prompt_created_ = callback;
  454. - }
  455. -
  456. DECLARE_EXTENSION_FUNCTION("downloads.acceptDanger", DOWNLOADS_ACCEPTDANGER)
  457. DownloadsAcceptDangerFunction();
  458. @@ -219,13 +211,10 @@ class DownloadsAcceptDangerFunction : pu
  459. protected:
  460. ~DownloadsAcceptDangerFunction() override;
  461. - void DangerPromptCallback(int download_id,
  462. - DownloadDangerPrompt::Action action);
  463. private:
  464. void PromptOrWait(int download_id, int retries);
  465. - static OnPromptCreatedCallback* on_prompt_created_;
  466. };
  467. class DownloadsShowFunction : public ExtensionFunction {
  468. --- a/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_api.cc
  469. +++ b/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_api.cc
  470. @@ -53,39 +53,7 @@ SafeBrowsingPrivateGetReferrerChainFunct
  471. base::StringPrintf("Could not find tab with id %d.", params->tab_id)));
  472. }
  473. - Profile* profile = Profile::FromBrowserContext(browser_context());
  474. - if (!SafeBrowsingNavigationObserverManager::IsEnabledAndReady(
  475. - profile->GetPrefs(), g_browser_process->safe_browsing_service()))
  476. - return RespondNow(NoArguments());
  477. -
  478. - SafeBrowsingNavigationObserverManager* navigation_observer_manager =
  479. - safe_browsing::SafeBrowsingNavigationObserverManagerFactory::
  480. - GetForBrowserContext(profile);
  481. -
  482. - safe_browsing::ReferrerChain referrer_chain;
  483. - SafeBrowsingNavigationObserverManager::AttributionResult result =
  484. - navigation_observer_manager->IdentifyReferrerChainByRenderFrameHost(
  485. - contents->GetPrimaryMainFrame(), kReferrerUserGestureLimit,
  486. - &referrer_chain);
  487. -
  488. - // If the referrer chain is incomplete we'll append the most recent
  489. - // navigations to referrer chain for diagnostic purposes. This only happens if
  490. - // the user is not in incognito mode and has opted into extended reporting or
  491. - // Scout reporting. Otherwise, |CountOfRecentNavigationsToAppend| returns 0.
  492. - int recent_navigations_to_collect =
  493. - SafeBrowsingNavigationObserverManager::CountOfRecentNavigationsToAppend(
  494. - profile, profile->GetPrefs(), result);
  495. - if (recent_navigations_to_collect > 0) {
  496. - navigation_observer_manager->AppendRecentNavigations(
  497. - recent_navigations_to_collect, &referrer_chain);
  498. - }
  499. -
  500. std::vector<api::safe_browsing_private::ReferrerChainEntry> referrer_entries;
  501. - referrer_entries.reserve(referrer_chain.size());
  502. - for (const auto& entry : referrer_chain) {
  503. - referrer_entries.emplace_back(
  504. - safe_browsing_util::ReferrerToReferrerChainEntry(entry));
  505. - }
  506. return RespondNow(ArgumentList(
  507. api::safe_browsing_private::GetReferrerChain::Results::Create(
  508. referrer_entries)));
  509. --- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
  510. +++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
  511. @@ -717,18 +717,6 @@ void WebstorePrivateBeginInstallWithMani
  512. void WebstorePrivateBeginInstallWithManifest3Function::
  513. ReportFrictionAcceptedEvent() {
  514. - if (!profile_) {
  515. - return;
  516. - }
  517. - auto* metrics_collector =
  518. - safe_browsing::SafeBrowsingMetricsCollectorFactory::GetForProfile(
  519. - profile_);
  520. - // `metrics_collector` can be null in incognito.
  521. - if (metrics_collector) {
  522. - metrics_collector->AddSafeBrowsingEventToPref(
  523. - safe_browsing::SafeBrowsingMetricsCollector::EventType::
  524. - EXTENSION_ALLOWLIST_INSTALL_BYPASS);
  525. - }
  526. }
  527. void WebstorePrivateBeginInstallWithManifest3Function::OnInstallPromptDone(
  528. @@ -1236,56 +1224,9 @@ WebstorePrivateGetReferrerChainFunction:
  529. ExtensionFunction::ResponseAction
  530. WebstorePrivateGetReferrerChainFunction::Run() {
  531. - Profile* profile = Profile::FromBrowserContext(browser_context());
  532. - if (!SafeBrowsingNavigationObserverManager::IsEnabledAndReady(
  533. - profile->GetPrefs(), g_browser_process->safe_browsing_service()))
  534. - return RespondNow(ArgumentList(
  535. - api::webstore_private::GetReferrerChain::Results::Create("")));
  536. -
  537. - content::RenderFrameHost* outermost_render_frame_host =
  538. - render_frame_host() ? render_frame_host()->GetOutermostMainFrame()
  539. - : nullptr;
  540. -
  541. - if (!outermost_render_frame_host) {
  542. - return RespondNow(ErrorWithArguments(
  543. - api::webstore_private::GetReferrerChain::Results::Create(""),
  544. - kWebstoreUserCancelledError));
  545. - }
  546. -
  547. - SafeBrowsingNavigationObserverManager* navigation_observer_manager =
  548. - safe_browsing::SafeBrowsingNavigationObserverManagerFactory::
  549. - GetForBrowserContext(profile);
  550. -
  551. - safe_browsing::ReferrerChain referrer_chain;
  552. - SafeBrowsingNavigationObserverManager::AttributionResult result =
  553. - navigation_observer_manager->IdentifyReferrerChainByRenderFrameHost(
  554. - outermost_render_frame_host, kExtensionReferrerUserGestureLimit,
  555. - &referrer_chain);
  556. -
  557. - // If the referrer chain is incomplete we'll append the most recent
  558. - // navigations to referrer chain for diagnostic purposes. This only happens if
  559. - // the user is not in incognito mode and has opted into extended reporting or
  560. - // Scout reporting. Otherwise, |CountOfRecentNavigationsToAppend| returns 0.
  561. - int recent_navigations_to_collect =
  562. - SafeBrowsingNavigationObserverManager::CountOfRecentNavigationsToAppend(
  563. - profile, profile->GetPrefs(), result);
  564. - if (recent_navigations_to_collect > 0) {
  565. - navigation_observer_manager->AppendRecentNavigations(
  566. - recent_navigations_to_collect, &referrer_chain);
  567. - }
  568. -
  569. - safe_browsing::ExtensionWebStoreInstallRequest request;
  570. - request.mutable_referrer_chain()->Swap(&referrer_chain);
  571. - request.mutable_referrer_chain_options()->set_recent_navigations_to_collect(
  572. - recent_navigations_to_collect);
  573. -
  574. - std::string serialized_referrer_proto = request.SerializeAsString();
  575. - // Base64 encode the proto to avoid issues with base::Value rejecting strings
  576. - // which are not valid UTF8.
  577. - base::Base64Encode(serialized_referrer_proto, &serialized_referrer_proto);
  578. return RespondNow(
  579. ArgumentList(api::webstore_private::GetReferrerChain::Results::Create(
  580. - serialized_referrer_proto)));
  581. + "")));
  582. }
  583. WebstorePrivateGetExtensionStatusFunction::
  584. --- a/chrome/browser/extensions/blocklist_state_fetcher.cc
  585. +++ b/chrome/browser/extensions/blocklist_state_fetcher.cc
  586. @@ -38,23 +38,8 @@ BlocklistStateFetcher::~BlocklistStateFe
  587. void BlocklistStateFetcher::Request(const std::string& id,
  588. RequestCallback callback) {
  589. DCHECK_CURRENTLY_ON(BrowserThread::UI);
  590. - if (!safe_browsing_config_) {
  591. - if (g_browser_process && g_browser_process->safe_browsing_service()) {
  592. - SetSafeBrowsingConfig(
  593. - g_browser_process->safe_browsing_service()->GetV4ProtocolConfig());
  594. - } else {
  595. - base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
  596. - FROM_HERE, base::BindOnce(std::move(callback), BLOCKLISTED_UNKNOWN));
  597. - return;
  598. - }
  599. - }
  600. -
  601. - bool request_already_sent = base::Contains(callbacks_, id);
  602. - callbacks_.insert(std::make_pair(id, std::move(callback)));
  603. - if (request_already_sent)
  604. - return;
  605. -
  606. - SendRequest(id);
  607. + base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
  608. + FROM_HERE, base::BindOnce(std::move(callback), BLOCKLISTED_UNKNOWN));
  609. }
  610. void BlocklistStateFetcher::SendRequest(const std::string& id) {
  611. @@ -65,8 +50,7 @@ void BlocklistStateFetcher::SendRequest(
  612. std::string request_str;
  613. request.SerializeToString(&request_str);
  614. - GURL request_url = GURL(safe_browsing::GetReportUrl(
  615. - *safe_browsing_config_, "clientreport/crx-list-info"));
  616. + GURL request_url = GURL();
  617. net::NetworkTrafficAnnotationTag traffic_annotation =
  618. net::DefineNetworkTrafficAnnotation("extension_blacklist", R"(
  619. semantics {
  620. @@ -126,12 +110,6 @@ void BlocklistStateFetcher::SendRequest(
  621. base::Unretained(this), fetcher));
  622. }
  623. -void BlocklistStateFetcher::SetSafeBrowsingConfig(
  624. - const safe_browsing::V4ProtocolConfig& config) {
  625. - safe_browsing_config_ =
  626. - std::make_unique<safe_browsing::V4ProtocolConfig>(config);
  627. -}
  628. -
  629. void BlocklistStateFetcher::OnURLLoaderComplete(
  630. network::SimpleURLLoader* url_loader,
  631. std::unique_ptr<std::string> response_body) {
  632. --- a/chrome/browser/extensions/blocklist_state_fetcher.h
  633. +++ b/chrome/browser/extensions/blocklist_state_fetcher.h
  634. @@ -36,8 +36,6 @@ class BlocklistStateFetcher {
  635. virtual void Request(const std::string& id, RequestCallback callback);
  636. - void SetSafeBrowsingConfig(const safe_browsing::V4ProtocolConfig& config);
  637. -
  638. protected:
  639. void OnURLLoaderComplete(network::SimpleURLLoader* url_loader,
  640. std::unique_ptr<std::string> response_body);
  641. @@ -56,7 +54,6 @@ class BlocklistStateFetcher {
  642. void SendRequest(const std::string& id);
  643. - std::unique_ptr<safe_browsing::V4ProtocolConfig> safe_browsing_config_;
  644. scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
  645. // SimpleURLLoader -> (owned loader, extension id).
  646. --- a/chrome/browser/profiles/profile_impl.cc
  647. +++ b/chrome/browser/profiles/profile_impl.cc
  648. @@ -92,7 +92,6 @@
  649. #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
  650. #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
  651. #include "chrome/browser/reduce_accept_language/reduce_accept_language_factory.h"
  652. -#include "chrome/browser/safe_browsing/safe_browsing_service.h"
  653. #include "chrome/browser/sessions/exit_type_service.h"
  654. #include "chrome/browser/sharing/sharing_service_factory.h"
  655. #include "chrome/browser/signin/identity_manager_factory.h"
  656. @@ -646,17 +645,6 @@ void ProfileImpl::LoadPrefsForNormalStar
  657. mojo::PendingRemote<prefs::mojom::TrackedPreferenceValidationDelegate>
  658. pref_validation_delegate;
  659. - scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service(
  660. - g_browser_process->safe_browsing_service());
  661. - if (safe_browsing_service.get()) {
  662. - auto pref_validation_delegate_impl =
  663. - safe_browsing_service->CreatePreferenceValidationDelegate(this);
  664. - if (pref_validation_delegate_impl) {
  665. - mojo::MakeSelfOwnedReceiver(
  666. - std::move(pref_validation_delegate_impl),
  667. - pref_validation_delegate.InitWithNewPipeAndPassReceiver());
  668. - }
  669. - }
  670. prefs_ =
  671. CreatePrefService(pref_registry_, CreateExtensionPrefStore(this, false),
  672. --- a/chrome/browser/profiles/profiles_state.cc
  673. +++ b/chrome/browser/profiles/profiles_state.cc
  674. @@ -261,9 +261,6 @@ void RemoveBrowsingDataForProfile(const
  675. // The BrowsingDataRemover relies on many objects that aren't created in unit
  676. // tests. Previously this code would depend on content::ResourceDispatcherHost
  677. // but that's gone, so do a similar hack for now.
  678. - if (!g_browser_process->safe_browsing_service())
  679. - return;
  680. -
  681. Profile* profile =
  682. g_browser_process->profile_manager()->GetProfileByPath(profile_path);
  683. if (!profile)
  684. --- a/chrome/browser/safe_browsing/BUILD.gn
  685. +++ b/chrome/browser/safe_browsing/BUILD.gn
  686. @@ -7,6 +7,7 @@ import("//components/safe_browsing/build
  687. import("//extensions/buildflags/buildflags.gni")
  688. static_library("safe_browsing") {
  689. + if (false) {
  690. sources = [
  691. "chrome_controller_client.cc",
  692. "chrome_controller_client.h",
  693. @@ -68,6 +69,7 @@ static_library("safe_browsing") {
  694. "//mojo/public/cpp/system",
  695. "//services/preferences/public/cpp",
  696. ]
  697. + }
  698. if (safe_browsing_mode != 0) {
  699. # "Safe Browsing Basic" files used for safe browsing in full mode
  700. @@ -495,6 +497,7 @@ static_library("advanced_protection") {
  701. }
  702. source_set("metrics_collector") {
  703. + if (false) {
  704. sources = [
  705. "safe_browsing_metrics_collector_factory.cc",
  706. "safe_browsing_metrics_collector_factory.h",
  707. @@ -514,6 +517,7 @@ source_set("metrics_collector") {
  708. "//components/safe_browsing/core/common:safe_browsing_prefs",
  709. "//content/public/browser",
  710. ]
  711. + }
  712. }
  713. source_set("test_support") {
  714. --- a/chrome/browser/ssl/security_state_tab_helper.cc
  715. +++ b/chrome/browser/ssl/security_state_tab_helper.cc
  716. @@ -174,92 +174,6 @@ bool SecurityStateTabHelper::UsedPolicyI
  717. security_state::MaliciousContentStatus
  718. SecurityStateTabHelper::GetMaliciousContentStatus() const {
  719. - content::NavigationEntry* entry =
  720. - web_contents()->GetController().GetVisibleEntry();
  721. - if (!entry)
  722. - return security_state::MALICIOUS_CONTENT_STATUS_NONE;
  723. - safe_browsing::SafeBrowsingService* sb_service =
  724. - g_browser_process->safe_browsing_service();
  725. - if (!sb_service)
  726. - return security_state::MALICIOUS_CONTENT_STATUS_NONE;
  727. - scoped_refptr<SafeBrowsingUIManager> sb_ui_manager = sb_service->ui_manager();
  728. - safe_browsing::SBThreatType threat_type;
  729. - if (sb_ui_manager->IsUrlAllowlistedOrPendingForWebContents(
  730. - entry->GetURL(), false, entry, web_contents(), false, &threat_type)) {
  731. - switch (threat_type) {
  732. - case safe_browsing::SB_THREAT_TYPE_UNUSED:
  733. - case safe_browsing::SB_THREAT_TYPE_SAFE:
  734. - case safe_browsing::SB_THREAT_TYPE_URL_PHISHING:
  735. - case safe_browsing::SB_THREAT_TYPE_URL_CLIENT_SIDE_PHISHING:
  736. - return security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING;
  737. - case safe_browsing::SB_THREAT_TYPE_URL_MALWARE:
  738. - case safe_browsing::SB_THREAT_TYPE_URL_CLIENT_SIDE_MALWARE:
  739. - return security_state::MALICIOUS_CONTENT_STATUS_MALWARE;
  740. - case safe_browsing::SB_THREAT_TYPE_URL_UNWANTED:
  741. - return security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE;
  742. - case safe_browsing::SB_THREAT_TYPE_SAVED_PASSWORD_REUSE:
  743. -#if BUILDFLAG(FULL_SAFE_BROWSING)
  744. - return security_state::MALICIOUS_CONTENT_STATUS_SAVED_PASSWORD_REUSE;
  745. -#endif
  746. - case safe_browsing::SB_THREAT_TYPE_SIGNED_IN_SYNC_PASSWORD_REUSE:
  747. -#if BUILDFLAG(FULL_SAFE_BROWSING)
  748. - if (safe_browsing::ChromePasswordProtectionService::
  749. - ShouldShowPasswordReusePageInfoBubble(
  750. - web_contents(), PasswordType::PRIMARY_ACCOUNT_PASSWORD)) {
  751. - return security_state::
  752. - MALICIOUS_CONTENT_STATUS_SIGNED_IN_SYNC_PASSWORD_REUSE;
  753. - }
  754. -#endif
  755. - [[fallthrough]];
  756. - case safe_browsing::SB_THREAT_TYPE_SIGNED_IN_NON_SYNC_PASSWORD_REUSE:
  757. -#if BUILDFLAG(FULL_SAFE_BROWSING)
  758. - if (safe_browsing::ChromePasswordProtectionService::
  759. - ShouldShowPasswordReusePageInfoBubble(
  760. - web_contents(), PasswordType::OTHER_GAIA_PASSWORD)) {
  761. - return security_state::
  762. - MALICIOUS_CONTENT_STATUS_SIGNED_IN_NON_SYNC_PASSWORD_REUSE;
  763. - }
  764. -#endif
  765. - [[fallthrough]];
  766. - case safe_browsing::SB_THREAT_TYPE_ENTERPRISE_PASSWORD_REUSE:
  767. -#if BUILDFLAG(FULL_SAFE_BROWSING)
  768. - if (safe_browsing::ChromePasswordProtectionService::
  769. - ShouldShowPasswordReusePageInfoBubble(
  770. - web_contents(), PasswordType::ENTERPRISE_PASSWORD)) {
  771. - return security_state::
  772. - MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE;
  773. - }
  774. -#endif
  775. - // If user has already changed password or FULL_SAFE_BROWSING isn't
  776. - // enabled, returns the regular social engineering content status.
  777. - return security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING;
  778. - case safe_browsing::SB_THREAT_TYPE_BILLING:
  779. - return security_state::MALICIOUS_CONTENT_STATUS_BILLING;
  780. - case safe_browsing::SB_THREAT_TYPE_MANAGED_POLICY_BLOCK:
  781. - return security_state::MALICIOUS_CONTENT_STATUS_MANAGED_POLICY_BLOCK;
  782. - case safe_browsing::SB_THREAT_TYPE_MANAGED_POLICY_WARN:
  783. - return security_state::MALICIOUS_CONTENT_STATUS_MANAGED_POLICY_WARN;
  784. - case safe_browsing::
  785. - DEPRECATED_SB_THREAT_TYPE_URL_PASSWORD_PROTECTION_PHISHING:
  786. - case safe_browsing::SB_THREAT_TYPE_URL_BINARY_MALWARE:
  787. - case safe_browsing::SB_THREAT_TYPE_EXTENSION:
  788. - case safe_browsing::SB_THREAT_TYPE_BLOCKLISTED_RESOURCE:
  789. - case safe_browsing::SB_THREAT_TYPE_API_ABUSE:
  790. - case safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER:
  791. - case safe_browsing::SB_THREAT_TYPE_CSD_ALLOWLIST:
  792. - case safe_browsing::SB_THREAT_TYPE_AD_SAMPLE:
  793. - case safe_browsing::SB_THREAT_TYPE_BLOCKED_AD_POPUP:
  794. - case safe_browsing::SB_THREAT_TYPE_BLOCKED_AD_REDIRECT:
  795. - case safe_browsing::SB_THREAT_TYPE_SUSPICIOUS_SITE:
  796. - case safe_browsing::SB_THREAT_TYPE_APK_DOWNLOAD:
  797. - case safe_browsing::SB_THREAT_TYPE_HIGH_CONFIDENCE_ALLOWLIST:
  798. - // These threat types are not currently associated with
  799. - // interstitials, and thus resources with these threat types are
  800. - // not ever whitelisted or pending whitelisting.
  801. - NOTREACHED();
  802. - break;
  803. - }
  804. - }
  805. return security_state::MALICIOUS_CONTENT_STATUS_NONE;
  806. }
  807. --- a/chrome/browser/ui/BUILD.gn
  808. +++ b/chrome/browser/ui/BUILD.gn
  809. @@ -5032,7 +5032,6 @@ static_library("ui") {
  810. "views/download/bubble/download_dialog_view.h",
  811. "views/download/bubble/download_toolbar_button_view.cc",
  812. "views/download/bubble/download_toolbar_button_view.h",
  813. - "views/download/download_danger_prompt_views.cc",
  814. "views/download/download_in_progress_dialog_view.cc",
  815. "views/download/download_in_progress_dialog_view.h",
  816. "views/download/download_item_view.cc",
  817. --- a/chrome/browser/ui/tab_helpers.cc
  818. +++ b/chrome/browser/ui/tab_helpers.cc
  819. @@ -471,22 +471,6 @@ void TabHelpers::AttachTabHelpers(WebCon
  820. // See https://crbug.com/910288.
  821. resource_coordinator::ResourceCoordinatorTabHelper::CreateForWebContents(
  822. web_contents);
  823. - safe_browsing::SafeBrowsingNavigationObserver::MaybeCreateForWebContents(
  824. - web_contents, HostContentSettingsMapFactory::GetForProfile(profile),
  825. - safe_browsing::SafeBrowsingNavigationObserverManagerFactory::
  826. - GetForBrowserContext(profile),
  827. - profile->GetPrefs(), g_browser_process->safe_browsing_service());
  828. - if (base::FeatureList::IsEnabled(
  829. - safe_browsing::kTailoredSecurityIntegration)) {
  830. - safe_browsing::TailoredSecurityUrlObserver::CreateForWebContents(
  831. - web_contents,
  832. - safe_browsing::TailoredSecurityServiceFactory::GetForProfile(profile));
  833. - }
  834. - safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(
  835. - web_contents,
  836. - std::make_unique<safe_browsing::ChromeSafeBrowsingTabObserverDelegate>());
  837. - safe_browsing::TriggerCreator::MaybeCreateTriggersForWebContents(
  838. - profile, web_contents);
  839. SafetyTipWebContentsObserver::CreateForWebContents(web_contents);
  840. SearchEngineTabHelper::CreateForWebContents(web_contents);
  841. SecurityStateTabHelper::CreateForWebContents(web_contents);
  842. --- a/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc
  843. +++ b/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc
  844. @@ -24,7 +24,6 @@
  845. #include "base/values.h"
  846. #include "chrome/browser/browser_process.h"
  847. #include "chrome/browser/download/bubble/download_bubble_ui_controller.h"
  848. -#include "chrome/browser/download/download_danger_prompt.h"
  849. #include "chrome/browser/download/download_history.h"
  850. #include "chrome/browser/download/download_item_model.h"
  851. #include "chrome/browser/download/download_item_warning_data.h"
  852. @@ -198,13 +197,6 @@ void DownloadsDOMHandler::SaveDangerousR
  853. }
  854. CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS);
  855. - download::DownloadItem* file = GetDownloadByStringId(id);
  856. - if (file) {
  857. - DownloadItemWarningData::AddWarningActionEvent(
  858. - file, DownloadItemWarningData::WarningSurface::DOWNLOADS_PAGE,
  859. - DownloadItemWarningData::WarningAction::KEEP);
  860. - ShowDangerPrompt(file);
  861. - }
  862. }
  863. void DownloadsDOMHandler::DiscardDangerous(const std::string& id) {
  864. @@ -400,12 +392,6 @@ void DownloadsDOMHandler::RemoveDownload
  865. IdSet ids;
  866. for (auto* download : to_remove) {
  867. - if (download->IsDangerous() || download->IsInsecure()) {
  868. - // Don't allow users to revive dangerous downloads; just nuke 'em.
  869. - download->Remove();
  870. - continue;
  871. - }
  872. -
  873. DownloadItemModel item_model(download);
  874. if (!item_model.ShouldShowInShelf() ||
  875. download->GetState() == download::DownloadItem::IN_PROGRESS) {
  876. @@ -533,44 +519,6 @@ void DownloadsDOMHandler::FinalizeRemova
  877. }
  878. }
  879. -void DownloadsDOMHandler::ShowDangerPrompt(
  880. - download::DownloadItem* dangerous_item) {
  881. - DownloadDangerPrompt* danger_prompt = DownloadDangerPrompt::Create(
  882. - dangerous_item, GetWebUIWebContents(), false,
  883. - base::BindOnce(&DownloadsDOMHandler::DangerPromptDone,
  884. - weak_ptr_factory_.GetWeakPtr(), dangerous_item->GetId()));
  885. - // danger_prompt will delete itself.
  886. - DCHECK(danger_prompt);
  887. -}
  888. -
  889. -void DownloadsDOMHandler::DangerPromptDone(
  890. - int download_id,
  891. - DownloadDangerPrompt::Action action) {
  892. - if (action != DownloadDangerPrompt::ACCEPT)
  893. - return;
  894. - download::DownloadItem* item = nullptr;
  895. - if (GetMainNotifierManager())
  896. - item = GetMainNotifierManager()->GetDownload(download_id);
  897. - if (!item && GetOriginalNotifierManager())
  898. - item = GetOriginalNotifierManager()->GetDownload(download_id);
  899. - if (!item || item->IsDone())
  900. - return;
  901. - CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS);
  902. -
  903. - // If a download is insecure, validate that first. Is most cases, insecure
  904. - // download warnings will occur first, but in the worst case scenario, we show
  905. - // a dangerous warning twice. That's better than showing an insecure download
  906. - // warning, then dismissing the dangerous download warning. Since insecure
  907. - // downloads triggering the UI are temporary and rare to begin with, this
  908. - // should very rarely occur.
  909. - if (item->IsInsecure()) {
  910. - item->ValidateInsecureDownload();
  911. - return;
  912. - }
  913. -
  914. - item->ValidateDangerousDownload();
  915. -}
  916. -
  917. bool DownloadsDOMHandler::IsDeletingHistoryAllowed() {
  918. content::DownloadManager* manager = GetMainNotifierManager();
  919. return manager &&
  920. --- a/chrome/browser/ui/webui/downloads/downloads_dom_handler.h
  921. +++ b/chrome/browser/ui/webui/downloads/downloads_dom_handler.h
  922. @@ -12,7 +12,6 @@
  923. #include "base/memory/raw_ptr.h"
  924. #include "base/memory/weak_ptr.h"
  925. -#include "chrome/browser/download/download_danger_prompt.h"
  926. #include "chrome/browser/ui/webui/downloads/downloads.mojom-forward.h"
  927. #include "chrome/browser/ui/webui/downloads/downloads_list_tracker.h"
  928. #include "content/public/browser/web_contents_observer.h"
  929. @@ -97,18 +96,6 @@ class DownloadsDOMHandler : public conte
  930. // null-checking |original_notifier_|.
  931. content::DownloadManager* GetOriginalNotifierManager() const;
  932. - // Displays a native prompt asking the user for confirmation after accepting
  933. - // the dangerous download specified by |dangerous|. The function returns
  934. - // immediately, and will invoke DangerPromptAccepted() asynchronously if the
  935. - // user accepts the dangerous download. The native prompt will observe
  936. - // |dangerous| until either the dialog is dismissed or |dangerous| is no
  937. - // longer an in-progress dangerous download.
  938. - virtual void ShowDangerPrompt(download::DownloadItem* dangerous);
  939. -
  940. - // Conveys danger acceptance from the DownloadDangerPrompt to the
  941. - // DownloadItem.
  942. - void DangerPromptDone(int download_id, DownloadDangerPrompt::Action action);
  943. -
  944. // Returns true if the records of any downloaded items are allowed (and able)
  945. // to be deleted.
  946. bool IsDeletingHistoryAllowed();
  947. --- a/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
  948. +++ b/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
  949. @@ -281,67 +281,6 @@ CreateHttpsOnlyModePage(content::WebCont
  950. security_interstitials::https_only_mode::HttpInterstitialState{});
  951. }
  952. -std::unique_ptr<safe_browsing::SafeBrowsingBlockingPage>
  953. -CreateSafeBrowsingBlockingPage(content::WebContents* web_contents) {
  954. - safe_browsing::SBThreatType threat_type =
  955. - safe_browsing::SB_THREAT_TYPE_URL_MALWARE;
  956. - GURL request_url("http://example.com");
  957. - std::string url_param;
  958. - if (net::GetValueForKeyInQuery(web_contents->GetVisibleURL(), "url",
  959. - &url_param)) {
  960. - if (GURL(url_param).is_valid()) {
  961. - request_url = GURL(url_param);
  962. - }
  963. - }
  964. - GURL main_frame_url(request_url);
  965. - // TODO(mattm): add flag to change main_frame_url or add dedicated flag to
  966. - // test subresource interstitials.
  967. - std::string type_param;
  968. - if (net::GetValueForKeyInQuery(web_contents->GetVisibleURL(), "type",
  969. - &type_param)) {
  970. - if (type_param == "malware") {
  971. - threat_type = safe_browsing::SB_THREAT_TYPE_URL_MALWARE;
  972. - } else if (type_param == "phishing") {
  973. - threat_type = safe_browsing::SB_THREAT_TYPE_URL_PHISHING;
  974. - } else if (type_param == "unwanted") {
  975. - threat_type = safe_browsing::SB_THREAT_TYPE_URL_UNWANTED;
  976. - } else if (type_param == "clientside_malware") {
  977. - threat_type = safe_browsing::SB_THREAT_TYPE_URL_CLIENT_SIDE_MALWARE;
  978. - } else if (type_param == "clientside_phishing") {
  979. - threat_type = safe_browsing::SB_THREAT_TYPE_URL_CLIENT_SIDE_PHISHING;
  980. - } else if (type_param == "billing") {
  981. - threat_type = safe_browsing::SB_THREAT_TYPE_BILLING;
  982. - }
  983. - }
  984. - const content::GlobalRenderFrameHostId primary_main_frame_id =
  985. - web_contents->GetPrimaryMainFrame()->GetGlobalId();
  986. - safe_browsing::SafeBrowsingBlockingPage::UnsafeResource resource;
  987. - resource.url = request_url;
  988. - resource.is_subresource = request_url != main_frame_url;
  989. - resource.is_subframe = false;
  990. - resource.threat_type = threat_type;
  991. - resource.render_process_id = primary_main_frame_id.child_id;
  992. - resource.render_frame_id = primary_main_frame_id.frame_routing_id;
  993. - resource.threat_source =
  994. - g_browser_process->safe_browsing_service()
  995. - ->database_manager()
  996. - ->GetBrowseUrlThreatSource(
  997. - safe_browsing::CheckBrowseUrlType::kHashDatabase);
  998. -
  999. - // Normally safebrowsing interstitial types which block the main page load
  1000. - // (SB_THREAT_TYPE_URL_MALWARE, SB_THREAT_TYPE_URL_PHISHING, and
  1001. - // SB_THREAT_TYPE_URL_UNWANTED on main-frame loads) would expect there to be a
  1002. - // pending navigation when the SafeBrowsingBlockingPage is created. This demo
  1003. - // creates a SafeBrowsingBlockingPage but does not actually show a real
  1004. - // interstitial. Instead it extracts the html and displays it manually, so the
  1005. - // parts which depend on the NavigationEntry are not hit.
  1006. - auto* ui_manager =
  1007. - g_browser_process->safe_browsing_service()->ui_manager().get();
  1008. - return base::WrapUnique<safe_browsing::SafeBrowsingBlockingPage>(
  1009. - ui_manager->blocking_page_factory()->CreateSafeBrowsingPage(
  1010. - ui_manager, web_contents, main_frame_url, {resource}, true));
  1011. -}
  1012. -
  1013. std::unique_ptr<EnterpriseBlockPage> CreateEnterpriseBlockPage(
  1014. content::WebContents* web_contents) {
  1015. const GURL kRequestUrl("https://enterprise-block.example.net");
  1016. @@ -351,92 +290,6 @@ std::unique_ptr<EnterpriseBlockPage> Cre
  1017. kRequestUrl));
  1018. }
  1019. -std::unique_ptr<EnterpriseWarnPage> CreateEnterpriseWarnPage(
  1020. - content::WebContents* web_contents) {
  1021. - const GURL kRequestUrl("https://enterprise-warn.example.net");
  1022. -
  1023. - auto* ui_manager =
  1024. - g_browser_process->safe_browsing_service()->ui_manager().get();
  1025. -
  1026. - const content::GlobalRenderFrameHostId primary_main_frame_id =
  1027. - web_contents->GetPrimaryMainFrame()->GetGlobalId();
  1028. - safe_browsing::SafeBrowsingBlockingPage::UnsafeResource resource;
  1029. - resource.url = kRequestUrl;
  1030. - resource.is_subresource = false;
  1031. - resource.is_subframe = false;
  1032. - resource.threat_type = safe_browsing::SB_THREAT_TYPE_MANAGED_POLICY_WARN;
  1033. - resource.render_process_id = primary_main_frame_id.child_id;
  1034. - resource.render_frame_id = primary_main_frame_id.frame_routing_id;
  1035. - resource.threat_source =
  1036. - g_browser_process->safe_browsing_service()
  1037. - ->database_manager()
  1038. - ->GetBrowseUrlThreatSource(
  1039. - safe_browsing::CheckBrowseUrlType::kHashDatabase);
  1040. -
  1041. - return std::make_unique<EnterpriseWarnPage>(
  1042. - ui_manager, web_contents, kRequestUrl,
  1043. - safe_browsing::SafeBrowsingBlockingPage::UnsafeResourceList({resource}),
  1044. - std::make_unique<EnterpriseWarnControllerClient>(web_contents,
  1045. - kRequestUrl));
  1046. -}
  1047. -
  1048. -std::unique_ptr<TestSafeBrowsingBlockingPageQuiet>
  1049. -CreateSafeBrowsingQuietBlockingPage(content::WebContents* web_contents) {
  1050. - safe_browsing::SBThreatType threat_type =
  1051. - safe_browsing::SB_THREAT_TYPE_URL_MALWARE;
  1052. - GURL request_url("http://example.com");
  1053. - std::string url_param;
  1054. - if (net::GetValueForKeyInQuery(web_contents->GetVisibleURL(), "url",
  1055. - &url_param)) {
  1056. - if (GURL(url_param).is_valid())
  1057. - request_url = GURL(url_param);
  1058. - }
  1059. - GURL main_frame_url(request_url);
  1060. - std::string type_param;
  1061. - bool is_giant_webview = false;
  1062. - if (net::GetValueForKeyInQuery(web_contents->GetVisibleURL(), "type",
  1063. - &type_param)) {
  1064. - if (type_param == "malware") {
  1065. - threat_type = safe_browsing::SB_THREAT_TYPE_URL_MALWARE;
  1066. - } else if (type_param == "phishing") {
  1067. - threat_type = safe_browsing::SB_THREAT_TYPE_URL_PHISHING;
  1068. - } else if (type_param == "unwanted") {
  1069. - threat_type = safe_browsing::SB_THREAT_TYPE_URL_UNWANTED;
  1070. - } else if (type_param == "billing") {
  1071. - threat_type = safe_browsing::SB_THREAT_TYPE_BILLING;
  1072. - } else if (type_param == "giant") {
  1073. - threat_type = safe_browsing::SB_THREAT_TYPE_URL_MALWARE;
  1074. - is_giant_webview = true;
  1075. - }
  1076. - }
  1077. - const content::GlobalRenderFrameHostId primary_main_frame_id =
  1078. - web_contents->GetPrimaryMainFrame()->GetGlobalId();
  1079. - safe_browsing::SafeBrowsingBlockingPage::UnsafeResource resource;
  1080. - resource.url = request_url;
  1081. - resource.is_subresource = request_url != main_frame_url;
  1082. - resource.is_subframe = false;
  1083. - resource.threat_type = threat_type;
  1084. - resource.render_process_id = primary_main_frame_id.child_id;
  1085. - resource.render_frame_id = primary_main_frame_id.frame_routing_id;
  1086. - resource.threat_source =
  1087. - g_browser_process->safe_browsing_service()
  1088. - ->database_manager()
  1089. - ->GetBrowseUrlThreatSource(
  1090. - safe_browsing::CheckBrowseUrlType::kHashDatabase);
  1091. -
  1092. - // Normally safebrowsing interstitial types which block the main page load
  1093. - // (SB_THREAT_TYPE_URL_MALWARE, SB_THREAT_TYPE_URL_PHISHING, and
  1094. - // SB_THREAT_TYPE_URL_UNWANTED on main-frame loads) would expect there to be a
  1095. - // pending navigation when the SafeBrowsingBlockingPage is created. This demo
  1096. - // creates a SafeBrowsingBlockingPage but does not actually show a real
  1097. - // interstitial. Instead it extracts the html and displays it manually, so the
  1098. - // parts which depend on the NavigationEntry are not hit.
  1099. - return base::WrapUnique<TestSafeBrowsingBlockingPageQuiet>(
  1100. - TestSafeBrowsingBlockingPageQuiet::CreateBlockingPage(
  1101. - g_browser_process->safe_browsing_service()->ui_manager().get(),
  1102. - web_contents, main_frame_url, resource, is_giant_webview));
  1103. -}
  1104. -
  1105. #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
  1106. std::unique_ptr<CaptivePortalBlockingPage> CreateCaptivePortalBlockingPage(
  1107. content::WebContents* web_contents) {
  1108. @@ -543,12 +396,8 @@ void InterstitialHTMLSource::StartDataRe
  1109. interstitial_delegate = CreateMITMSoftwareBlockingPage(web_contents);
  1110. } else if (path_without_query == "/blocked-interception") {
  1111. interstitial_delegate = CreateBlockedInterceptionBlockingPage(web_contents);
  1112. - } else if (path_without_query == "/safebrowsing") {
  1113. - interstitial_delegate = CreateSafeBrowsingBlockingPage(web_contents);
  1114. } else if (path_without_query == "/enterprise-block") {
  1115. interstitial_delegate = CreateEnterpriseBlockPage(web_contents);
  1116. - } else if (path_without_query == "/enterprise-warn") {
  1117. - interstitial_delegate = CreateEnterpriseWarnPage(web_contents);
  1118. } else if (path_without_query == "/clock") {
  1119. interstitial_delegate = CreateBadClockBlockingPage(web_contents);
  1120. } else if (path_without_query == "/lookalike") {
  1121. @@ -563,16 +412,12 @@ void InterstitialHTMLSource::StartDataRe
  1122. interstitial_delegate = CreateHttpsOnlyModePage(web_contents);
  1123. }
  1124. - if (path_without_query == "/quietsafebrowsing") {
  1125. - std::unique_ptr<TestSafeBrowsingBlockingPageQuiet> blocking_page =
  1126. - CreateSafeBrowsingQuietBlockingPage(web_contents);
  1127. - html = blocking_page->GetHTML();
  1128. - interstitial_delegate = std::move(blocking_page);
  1129. #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
  1130. - } else if (path_without_query == "/supervised_user") {
  1131. + if (path_without_query == "/supervised_user") {
  1132. html = GetSupervisedUserInterstitialHTML(path);
  1133. + } else
  1134. #endif
  1135. - } else if (interstitial_delegate.get()) {
  1136. + if (interstitial_delegate.get()) {
  1137. html = interstitial_delegate.get()->GetHTMLContents();
  1138. } else {
  1139. html = ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
  1140. --- a/chrome/renderer/chrome_content_renderer_client.cc
  1141. +++ b/chrome/renderer/chrome_content_renderer_client.cc
  1142. @@ -100,7 +100,6 @@
  1143. #include "components/password_manager/core/common/password_manager_features.h"
  1144. #include "components/permissions/features.h"
  1145. #include "components/safe_browsing/buildflags.h"
  1146. -#include "components/safe_browsing/content/renderer/threat_dom_details.h"
  1147. #include "components/spellcheck/spellcheck_buildflags.h"
  1148. #include "components/subresource_filter/content/renderer/subresource_filter_agent.h"
  1149. #include "components/subresource_filter/content/renderer/unverified_ruleset_dealer.h"
  1150. @@ -440,12 +439,8 @@ void ChromeContentRendererClient::Render
  1151. subresource_filter_ruleset_dealer_ =
  1152. std::make_unique<subresource_filter::UnverifiedRulesetDealer>();
  1153. - phishing_model_setter_ =
  1154. - std::make_unique<safe_browsing::PhishingModelSetterImpl>();
  1155. -
  1156. thread->AddObserver(chrome_observer_.get());
  1157. thread->AddObserver(subresource_filter_ruleset_dealer_.get());
  1158. - thread->AddObserver(phishing_model_setter_.get());
  1159. blink::WebScriptController::RegisterExtension(
  1160. extensions_v8::LoadTimesExtension::Get());
  1161. --- a/components/security_interstitials/content/cert_report_helper.cc
  1162. +++ b/components/security_interstitials/content/cert_report_helper.cc
  1163. @@ -177,7 +177,6 @@ void CertReportHelper::FinishCertCollect
  1164. return;
  1165. }
  1166. - ssl_cert_reporter_->ReportInvalidCertificateChain(serialized_report);
  1167. }
  1168. bool CertReportHelper::ShouldShowCertificateReporterCheckbox() {