Browse Source

fix build error

Carmelo Messina 3 years ago
parent
commit
e0eee8f815
1 changed files with 72 additions and 32 deletions
  1. 72 32
      build/patches/Disable-safe-browsing.patch

+ 72 - 32
build/patches/Disable-safe-browsing.patch

@@ -26,12 +26,13 @@ Disable CrowdDeny feature
  ...ontent_browser_client_receiver_bindings.cc |  2 +
  .../file_type_policies_component_installer.cc | 16 +----
  .../browser/component_updater/registration.cc |  7 --
- .../chrome_download_manager_delegate.cc       | 39 ++++------
+ .../chrome_download_manager_delegate.cc       | 40 ++++-------
  .../chrome_download_manager_delegate.h        |  8 ++-
  .../browser/download/download_item_model.cc   | 15 +++-
  chrome/browser/download/download_item_model.h |  4 ++
  chrome/browser/download/download_prefs.cc     | 17 ++---
- .../download/download_target_determiner.cc    | 46 ++++++------
+ chrome/browser/download/download_stats.cc     |  3 -
+ .../download/download_target_determiner.cc    | 52 ++++++--------
  .../download/download_target_determiner.h     |  6 ++
  .../browser/download/download_target_info.cc  |  4 ++
  .../browser/download/download_target_info.h   |  4 ++
@@ -70,6 +71,7 @@ Disable CrowdDeny feature
  .../chrome_content_renderer_client.cc         |  2 +
  .../installer_policies/BUILD.gn               |  2 -
  .../permissions/permission_request_manager.cc |  5 +-
+ components/safe_browsing/buildflags.gni       |  2 +
  .../content/common/file_type_policies.cc      |  3 +-
  .../safe_browsing/core/common/features.cc     |  2 +-
  .../content/captive_portal_blocking_page.cc   |  7 --
@@ -78,7 +80,7 @@ Disable CrowdDeny feature
  .../file_system_access_file_writer_impl.cc    | 41 +----------
  .../file_system_access_file_writer_impl.h     |  9 +--
  .../file_system_access_permission_context.h   |  6 --
- 72 files changed, 169 insertions(+), 660 deletions(-)
+ 74 files changed, 171 insertions(+), 670 deletions(-)
 
 diff --git a/chrome/android/java/res/xml/google_services_preferences.xml b/chrome/android/java/res/xml/google_services_preferences.xml
 --- a/chrome/android/java/res/xml/google_services_preferences.xml
@@ -823,17 +825,18 @@ diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrom
  #include "chrome/browser/ui/chrome_pages.h"
  #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
  #include "chrome/common/buildflags.h"
-@@ -70,7 +72,9 @@
+@@ -69,8 +71,9 @@
+ #include "components/prefs/pref_member.h"
  #include "components/prefs/pref_service.h"
  #include "components/safe_browsing/buildflags.h"
- #include "components/safe_browsing/content/browser/download/download_stats.h"
+-#include "components/safe_browsing/content/browser/download/download_stats.h"
 +#if defined(FULL_SAFE_BROWSING)
  #include "components/safe_browsing/content/common/file_type_policies.h"
 +#endif
  #include "components/services/quarantine/public/mojom/quarantine.mojom.h"
  #include "components/services/quarantine/quarantine_impl.h"
  #include "content/public/browser/browser_task_traits.h"
-@@ -129,8 +133,10 @@ using content::DownloadManager;
+@@ -129,8 +132,10 @@ using content::DownloadManager;
  using download::DownloadItem;
  using download::DownloadPathReservationTracker;
  using download::PathValidationResult;
@@ -844,7 +847,7 @@ diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrom
  using ConnectionType = net::NetworkChangeNotifier::ConnectionType;
  
  namespace {
-@@ -332,12 +338,12 @@ void HandleMixedDownloadInfoBarResult(
+@@ -332,12 +337,12 @@ void HandleMixedDownloadInfoBarResult(
  }
  #endif
  
@@ -858,7 +861,7 @@ diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrom
    if (download_restriction !=
            DownloadPrefs::DownloadRestriction::POTENTIALLY_DANGEROUS_FILES &&
        download_restriction !=
-@@ -372,8 +378,8 @@ void MaybeReportDangerousDownloadBlocked(
+@@ -372,8 +377,8 @@ void MaybeReportDangerousDownloadBlocked(
          danger_type, download->GetMimeType(), /*scan_id*/ "",
          download->GetTotalBytes(), safe_browsing::EventResult::BLOCKED);
    }
@@ -868,7 +871,7 @@ diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrom
  
  }  // namespace
  
-@@ -395,13 +401,6 @@ ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() {
+@@ -395,13 +400,6 @@ ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() {
  
  void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) {
    download_manager_ = dm;
@@ -882,7 +885,7 @@ diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrom
  }
  
  #if defined(OS_ANDROID)
-@@ -748,16 +747,6 @@ void ChromeDownloadManagerDelegate::ChooseSavePath(
+@@ -748,16 +746,6 @@ void ChromeDownloadManagerDelegate::ChooseSavePath(
  
  void ChromeDownloadManagerDelegate::SanitizeSavePackageResourceName(
      base::FilePath* filename) {
@@ -899,7 +902,7 @@ diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrom
  }
  
  void ChromeDownloadManagerDelegate::SanitizeDownloadParameters(
-@@ -827,8 +816,6 @@ void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) {
+@@ -827,8 +815,6 @@ void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) {
      chrome::ShowSettingsSubPage(browser, "certificates");
    else
      browser->OpenURL(params);
@@ -908,7 +911,7 @@ diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrom
  #endif  // OS_ANDROID
  }
  
-@@ -884,18 +871,18 @@ ChromeDownloadManagerDelegate::ApplicationClientIdForFileScanning() {
+@@ -884,18 +870,18 @@ ChromeDownloadManagerDelegate::ApplicationClientIdForFileScanning() {
    return std::string(chrome::kApplicationClientIDStringForAVScanning);
  }
  
@@ -929,7 +932,7 @@ diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrom
  
  void ChromeDownloadManagerDelegate::GetMixedContentStatus(
      download::DownloadItem* download,
-@@ -1400,8 +1387,11 @@ void ChromeDownloadManagerDelegate::OnDownloadTargetDetermined(
+@@ -1400,8 +1386,11 @@ void ChromeDownloadManagerDelegate::OnDownloadTargetDetermined(
        DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true);
  #endif
  
@@ -941,7 +944,7 @@ diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrom
    if (ShouldBlockFile(target_info->danger_type, item)) {
      MaybeReportDangerousDownloadBlocked(
          download_prefs_->download_restriction(), "DANGEROUS_FILE_TYPE",
-@@ -1410,6 +1400,7 @@ void ChromeDownloadManagerDelegate::OnDownloadTargetDetermined(
+@@ -1410,6 +1399,7 @@ void ChromeDownloadManagerDelegate::OnDownloadTargetDetermined(
      // A dangerous type would take precedence over the blocking of the file.
      target_info->danger_type = download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS;
    }
@@ -949,7 +952,7 @@ diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrom
  
    base::FilePath target_path = target_info->target_path;
  
-@@ -1539,10 +1530,10 @@ void ChromeDownloadManagerDelegate::MaybeSendDangerousDownloadOpenedReport(
+@@ -1539,10 +1529,10 @@ void ChromeDownloadManagerDelegate::MaybeSendDangerousDownloadOpenedReport(
      service->MaybeSendDangerousDownloadOpenedReport(download,
                                                      show_download_in_folder);
    }
@@ -1165,12 +1168,34 @@ diff --git a/chrome/browser/download/download_prefs.cc b/chrome/browser/download
  
    DCHECK(extension[0] == base::FilePath::kExtensionSeparator);
    extension.erase(0, 1);
+diff --git a/chrome/browser/download/download_stats.cc b/chrome/browser/download/download_stats.cc
+--- a/chrome/browser/download/download_stats.cc
++++ b/chrome/browser/download/download_stats.cc
+@@ -4,7 +4,6 @@
+ 
+ #include "chrome/browser/download/download_stats.h"
+ #include "components/profile_metrics/browser_profile_type.h"
+-#include "components/safe_browsing/content/browser/download/download_stats.h"
+ 
+ #include "base/metrics/histogram_functions.h"
+ #include "base/metrics/user_metrics.h"
+@@ -26,8 +25,6 @@ void RecordDangerousDownloadWarningShown(
+     bool has_user_gesture) {
+   base::UmaHistogramEnumeration("Download.ShowedDownloadWarning", danger_type,
+                                 download::DOWNLOAD_DANGER_TYPE_MAX);
+-  safe_browsing::RecordDangerousDownloadWarningShown(
+-      danger_type, file_path, is_https, has_user_gesture);
+ }
+ 
+ void RecordOpenedDangerousConfirmDialog(
 diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/browser/download/download_target_determiner.cc
 --- a/chrome/browser/download/download_target_determiner.cc
 +++ b/chrome/browser/download/download_target_determiner.cc
-@@ -31,7 +31,9 @@
+@@ -29,9 +29,10 @@
+ #include "components/download/public/common/download_interrupt_reasons.h"
+ #include "components/history/core/browser/history_service.h"
  #include "components/prefs/pref_service.h"
- #include "components/safe_browsing/content/browser/download/download_stats.h"
+-#include "components/safe_browsing/content/browser/download/download_stats.h"
  #include "components/safe_browsing/content/browser/safe_browsing_metrics_collector.h"
 +#if defined(FULL_SAFE_BROWSING)
  #include "components/safe_browsing/content/common/file_type_policies.h"
@@ -1178,7 +1203,7 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
  #include "content/public/browser/browser_context.h"
  #include "content/public/browser/browser_task_traits.h"
  #include "content/public/browser/browser_thread.h"
-@@ -65,13 +67,16 @@
+@@ -65,13 +66,16 @@
  using content::BrowserThread;
  using download::DownloadItem;
  using download::DownloadPathReservationTracker;
@@ -1195,7 +1220,7 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
  // Condenses the results from HistoryService::GetVisibleVisitCountToHost() to a
  // single bool. A host is considered visited before if prior visible visits were
  // found in history and the first such visit was earlier than the most recent
-@@ -82,6 +87,7 @@ void VisitCountsToVisitedBefore(base::OnceCallback<void(bool)> callback,
+@@ -82,6 +86,7 @@ void VisitCountsToVisitedBefore(base::OnceCallback<void(bool)> callback,
        result.success && result.count > 0 &&
        (result.first_visit.LocalMidnight() < base::Time::Now().LocalMidnight()));
  }
@@ -1203,7 +1228,7 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
  
  #if defined(OS_WIN)
  // Keeps track of whether Adobe Reader is up to date.
-@@ -106,7 +112,9 @@ DownloadTargetDeterminer::DownloadTargetDeterminer(
+@@ -106,7 +111,9 @@ DownloadTargetDeterminer::DownloadTargetDeterminer(
        create_target_directory_(false),
        conflict_action_(conflict_action),
        danger_type_(download->GetDangerType()),
@@ -1213,7 +1238,7 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
        virtual_path_(initial_virtual_path),
        is_filetype_handled_safely_(false),
  #if defined(OS_ANDROID)
-@@ -297,12 +305,14 @@ base::FilePath DownloadTargetDeterminer::GenerateFileName() const {
+@@ -297,12 +304,14 @@ base::FilePath DownloadTargetDeterminer::GenerateFileName() const {
        download_->GetURL(), download_->GetContentDisposition(), referrer_charset,
        suggested_filename, sniffed_mime_type, default_filename);
  
@@ -1229,7 +1254,7 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
  
    // If no mime type or explicitly specified a name, don't replace file
    // extension.
-@@ -834,6 +844,7 @@ DownloadTargetDeterminer::Result
+@@ -834,6 +843,7 @@ DownloadTargetDeterminer::Result
      return CONTINUE;
    }
  
@@ -1237,7 +1262,7 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
    // First determine the danger level assuming that the user doesn't have any
    // prior visits to the referrer recoreded in history. The resulting danger
    // level would be ALLOW_ON_USER_GESTURE if the level depends on the visit
-@@ -870,6 +881,7 @@ DownloadTargetDeterminer::Result
+@@ -870,6 +880,7 @@ DownloadTargetDeterminer::Result
    // invalid, then assume the referrer has not been visited before.
    if (danger_type_ == download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS)
      danger_type_ = download::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE;
@@ -1245,11 +1270,16 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
    return CONTINUE;
  }
  
-@@ -882,11 +894,13 @@ void DownloadTargetDeterminer::CheckVisitedReferrerBeforeDone(
-           virtual_path_.BaseName()),
-       download_->HasUserGesture(), visited_referrer_before,
-       GetLastDownloadBypassTimestamp());
-+#if defined(FULL_SAFE_BROWSING)
+@@ -877,16 +888,13 @@ void DownloadTargetDeterminer::CheckVisitedReferrerBeforeDone(
+     bool visited_referrer_before) {
+   DCHECK_CURRENTLY_ON(BrowserThread::UI);
+   DCHECK_EQ(STATE_DETERMINE_INTERMEDIATE_PATH, next_state_);
+-  safe_browsing::RecordDownloadFileTypeAttributes(
+-      safe_browsing::FileTypePolicies::GetInstance()->GetFileDangerLevel(
+-          virtual_path_.BaseName()),
+-      download_->HasUserGesture(), visited_referrer_before,
+-      GetLastDownloadBypassTimestamp());
++  #if defined(FULL_SAFE_BROWSING)
    danger_level_ = GetDangerLevel(
        visited_referrer_before ? VISITED_REFERRER : NO_VISITS_TO_REFERRER);
    if (danger_level_ != DownloadFileType::NOT_DANGEROUS &&
@@ -1259,7 +1289,7 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
    DoLoop();
  }
  
-@@ -986,7 +1000,9 @@ void DownloadTargetDeterminer::ScheduleCallbackAndDeleteSelf(
+@@ -986,7 +994,9 @@ void DownloadTargetDeterminer::ScheduleCallbackAndDeleteSelf(
              << " Intermediate:" << intermediate_path_.AsUTF8Unsafe()
              << " Confirmation reason:" << static_cast<int>(confirmation_reason_)
              << " Danger type:" << danger_type_
@@ -1269,7 +1299,7 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
              << " Result:" << static_cast<int>(result);
    std::unique_ptr<DownloadTargetInfo> target_info(new DownloadTargetInfo);
  
-@@ -998,7 +1014,9 @@ void DownloadTargetDeterminer::ScheduleCallbackAndDeleteSelf(
+@@ -998,7 +1008,9 @@ void DownloadTargetDeterminer::ScheduleCallbackAndDeleteSelf(
             ? DownloadItem::TARGET_DISPOSITION_PROMPT
             : DownloadItem::TARGET_DISPOSITION_OVERWRITE);
    target_info->danger_type = danger_type_;
@@ -1279,7 +1309,7 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
    target_info->intermediate_path = intermediate_path_;
    target_info->mime_type = mime_type_;
    target_info->is_filetype_handled_safely = is_filetype_handled_safely_;
-@@ -1087,6 +1105,7 @@ bool DownloadTargetDeterminer::HasPromptedForPath() const {
+@@ -1087,6 +1099,7 @@ bool DownloadTargetDeterminer::HasPromptedForPath() const {
                                  DownloadItem::TARGET_DISPOSITION_PROMPT);
  }
  
@@ -1287,7 +1317,7 @@ diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/brow
  DownloadFileType::DangerLevel DownloadTargetDeterminer::GetDangerLevel(
      PriorVisitsToReferrer visits) const {
    DCHECK_CURRENTLY_ON(BrowserThread::UI);
-@@ -1111,30 +1130,9 @@ DownloadFileType::DangerLevel DownloadTargetDeterminer::GetDangerLevel(
+@@ -1111,30 +1124,9 @@ DownloadFileType::DangerLevel DownloadTargetDeterminer::GetDangerLevel(
        download_->HasUserGesture())
      return DownloadFileType::NOT_DANGEROUS;
  
@@ -2482,6 +2512,16 @@ diff --git a/components/permissions/permission_request_manager.cc b/components/p
  
  void PermissionRequestManager::ScheduleShowBubble() {
    base::RecordAction(base::UserMetricsAction("PermissionBubbleRequest"));
+diff --git a/components/safe_browsing/buildflags.gni b/components/safe_browsing/buildflags.gni
+--- a/components/safe_browsing/buildflags.gni
++++ b/components/safe_browsing/buildflags.gni
+@@ -19,4 +19,6 @@ declare_args() {
+   } else {
+     safe_browsing_mode = 1
+   }
++
++  safe_browsing_mode = 0
+ }
 diff --git a/components/safe_browsing/content/common/file_type_policies.cc b/components/safe_browsing/content/common/file_type_policies.cc
 --- a/components/safe_browsing/content/common/file_type_policies.cc
 +++ b/components/safe_browsing/content/common/file_type_policies.cc