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

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