123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769 |
- From: csagan5 <32685696+csagan5@users.noreply.github.com>
- Date: Tue, 18 Sep 2018 08:06:14 +0200
- Subject: Allow building without safebrowsing for Android
- Fix build from scratch (issue found by nikolowry)
- ---
- .../android/java/res/xml/privacy_preferences.xml | 8 -----
- .../preferences/privacy/PrivacyPreferences.java | 40 ----------------------
- .../chrome_browsing_data_remover_delegate.cc | 10 ------
- chrome/browser/chrome_content_browser_client.cc | 20 +----------
- .../file_type_policies_component_installer.cc | 2 ++
- .../download/chrome_download_manager_delegate.cc | 14 ++++++--
- .../download/chrome_download_manager_delegate.h | 6 ++++
- chrome/browser/download/download_item_model.cc | 10 ++++++
- chrome/browser/download/download_item_model.h | 4 +++
- chrome/browser/download/download_prefs.cc | 4 +++
- .../browser/download/download_target_determiner.cc | 22 ++++++++++++
- .../browser/download/download_target_determiner.h | 6 ++++
- chrome/browser/download/download_target_info.cc | 4 +++
- chrome/browser/download/download_target_info.h | 4 +++
- chrome/browser/download/download_ui_model.cc | 4 +++
- chrome/browser/download/download_ui_model.h | 4 +++
- .../chrome_resource_dispatcher_host_delegate.cc | 2 ++
- chrome/browser/net/chrome_network_delegate.cc | 35 ++-----------------
- 18 files changed, 87 insertions(+), 112 deletions(-)
- diff --git a/chrome/android/java/res/xml/privacy_preferences.xml b/chrome/android/java/res/xml/privacy_preferences.xml
- --- a/chrome/android/java/res/xml/privacy_preferences.xml
- +++ b/chrome/android/java/res/xml/privacy_preferences.xml
- @@ -18,14 +18,6 @@
- android:summary="@string/search_suggestions_summary"
- android:defaultValue="true" />
- <org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
- - android:key="safe_browsing_scout_reporting"
- - android:title="@string/safe_browsing_scout_reporting_title"
- - android:summary="@string/safe_browsing_scout_reporting_summary" />
- - <org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
- - android:key="safe_browsing"
- - android:title="@string/safe_browsing_title"
- - android:summary="@string/safe_browsing_summary" />
- - <org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
- android:key="network_predictions"
- android:title="@string/network_predictions_title"
- android:summary="@string/network_predictions_summary"
- diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferences.java
- --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferences.java
- +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferences.java
- @@ -39,9 +39,6 @@ public class PrivacyPreferences extends PreferenceFragment
- implements OnPreferenceChangeListener {
- private static final String PREF_NAVIGATION_ERROR = "navigation_error";
- private static final String PREF_SEARCH_SUGGESTIONS = "search_suggestions";
- - private static final String PREF_SAFE_BROWSING_SCOUT_REPORTING =
- - "safe_browsing_scout_reporting";
- - private static final String PREF_SAFE_BROWSING = "safe_browsing";
- private static final String PREF_CAN_MAKE_PAYMENT = "can_make_payment";
- private static final String PREF_CONTEXTUAL_SEARCH = "contextual_search";
- private static final String PREF_NETWORK_PREDICTIONS = "network_predictions";
- @@ -79,8 +76,6 @@ public class PrivacyPreferences extends PreferenceFragment
- // Remove preferences that were migrated to SyncAndServicesPreferences.
- preferenceScreen.removePreference(findPreference(PREF_NAVIGATION_ERROR));
- preferenceScreen.removePreference(findPreference(PREF_SEARCH_SUGGESTIONS));
- - preferenceScreen.removePreference(findPreference(PREF_SAFE_BROWSING_SCOUT_REPORTING));
- - preferenceScreen.removePreference(findPreference(PREF_SAFE_BROWSING));
- preferenceScreen.removePreference(findPreference(PREF_CONTEXTUAL_SEARCH));
- preferenceScreen.removePreference(findPreference(PREF_USAGE_AND_CRASH_REPORTING));
-
- @@ -114,17 +109,6 @@ public class PrivacyPreferences extends PreferenceFragment
- preferenceScreen.removePreference(findPreference(PREF_CONTEXTUAL_SEARCH));
- }
-
- - // Listen to changes to the Extended Reporting pref.
- - ChromeBaseCheckBoxPreference scoutReportingPref =
- - (ChromeBaseCheckBoxPreference) findPreference(PREF_SAFE_BROWSING_SCOUT_REPORTING);
- - scoutReportingPref.setOnPreferenceChangeListener(this);
- - scoutReportingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
- -
- - ChromeBaseCheckBoxPreference safeBrowsingPref =
- - (ChromeBaseCheckBoxPreference) findPreference(PREF_SAFE_BROWSING);
- - safeBrowsingPref.setOnPreferenceChangeListener(this);
- - safeBrowsingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
- -
- updateSummaries();
- }
-
- @@ -133,11 +117,6 @@ public class PrivacyPreferences extends PreferenceFragment
- String key = preference.getKey();
- if (PREF_SEARCH_SUGGESTIONS.equals(key)) {
- PrefServiceBridge.getInstance().setSearchSuggestEnabled((boolean) newValue);
- - } else if (PREF_SAFE_BROWSING.equals(key)) {
- - PrefServiceBridge.getInstance().setSafeBrowsingEnabled((boolean) newValue);
- - } else if (PREF_SAFE_BROWSING_SCOUT_REPORTING.equals(key)) {
- - PrefServiceBridge.getInstance().setSafeBrowsingExtendedReportingEnabled(
- - (boolean) newValue);
- } else if (PREF_NETWORK_PREDICTIONS.equals(key)) {
- PrefServiceBridge.getInstance().setNetworkPredictionEnabled((boolean) newValue);
- recordNetworkPredictionEnablingUMA((boolean) newValue);
- @@ -189,19 +168,6 @@ public class PrivacyPreferences extends PreferenceFragment
- searchSuggestionsPref.setChecked(prefServiceBridge.isSearchSuggestEnabled());
- }
-
- - CheckBoxPreference extendedReportingPref =
- - (CheckBoxPreference) findPreference(PREF_SAFE_BROWSING_SCOUT_REPORTING);
- - if (extendedReportingPref != null) {
- - extendedReportingPref.setChecked(
- - prefServiceBridge.isSafeBrowsingExtendedReportingEnabled());
- - }
- -
- - CheckBoxPreference safeBrowsingPref =
- - (CheckBoxPreference) findPreference(PREF_SAFE_BROWSING);
- - if (safeBrowsingPref != null) {
- - safeBrowsingPref.setChecked(prefServiceBridge.isSafeBrowsingEnabled());
- - }
- -
- CheckBoxPreference canMakePaymentPref =
- (CheckBoxPreference) findPreference(PREF_CAN_MAKE_PAYMENT);
- if (canMakePaymentPref != null) {
- @@ -250,12 +216,6 @@ public class PrivacyPreferences extends PreferenceFragment
- if (PREF_SEARCH_SUGGESTIONS.equals(key)) {
- return prefs.isSearchSuggestManaged();
- }
- - if (PREF_SAFE_BROWSING_SCOUT_REPORTING.equals(key)) {
- - return prefs.isSafeBrowsingExtendedReportingManaged();
- - }
- - if (PREF_SAFE_BROWSING.equals(key)) {
- - return prefs.isSafeBrowsingManaged();
- - }
- if (PREF_NETWORK_PREDICTIONS.equals(key)) {
- return prefs.isNetworkPredictionManaged();
- }
- diff --git a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc
- --- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc
- +++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc
- @@ -252,16 +252,6 @@ bool DoesOriginMatchEmbedderMask(int origin_type_mask,
- return false;
- }
-
- -// Callback for when cookies have been deleted. Invokes NotifyIfDone.
- -// Receiving |cookie_manager| as a parameter so that the receive pipe is
- -// not deleted before the response is received.
- -void OnClearedCookies(base::OnceClosure done,
- - network::mojom::CookieManagerPtr cookie_manager,
- - uint32_t num_deleted) {
- - DCHECK_CURRENTLY_ON(BrowserThread::UI);
- - std::move(done).Run();
- -}
- -
- } // namespace
-
- ChromeBrowsingDataRemoverDelegate::ChromeBrowsingDataRemoverDelegate(
- diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
- --- a/chrome/browser/chrome_content_browser_client.cc
- +++ b/chrome/browser/chrome_content_browser_client.cc
- @@ -118,7 +118,6 @@
- #include "chrome/browser/safe_browsing/certificate_reporting_service.h"
- #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h"
- #include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
- -#include "chrome/browser/safe_browsing/safe_browsing_navigation_throttle.h"
- #include "chrome/browser/safe_browsing/safe_browsing_service.h"
- #include "chrome/browser/safe_browsing/ui_manager.h"
- #include "chrome/browser/safe_browsing/url_checker_delegate_impl.h"
- @@ -4346,11 +4345,6 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation(
- PreviewsLitePageDecider::MaybeCreateThrottleFor(handle);
- if (previews_lite_page_throttle)
- throttles.push_back(std::move(previews_lite_page_throttle));
- - if (base::FeatureList::IsEnabled(safe_browsing::kCommittedSBInterstitials)) {
- - throttles.push_back(
- - std::make_unique<safe_browsing::SafeBrowsingNavigationThrottle>(
- - handle));
- - }
-
- #if defined(OS_WIN) || defined(OS_MACOSX) || \
- (defined(OS_LINUX) && !defined(OS_CHROMEOS))
- @@ -5303,19 +5297,7 @@ ChromeContentBrowserClient::GetSafeBrowsingUrlCheckerDelegate(
- content::ResourceContext* resource_context) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
- - ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
- - if (!io_data->safe_browsing_enabled()->GetValue())
- - return nullptr;
- -
- - // |safe_browsing_service_| may be unavailable in tests.
- - if (safe_browsing_service_ && !safe_browsing_url_checker_delegate_) {
- - safe_browsing_url_checker_delegate_ =
- - base::MakeRefCounted<safe_browsing::UrlCheckerDelegateImpl>(
- - safe_browsing_service_->database_manager(),
- - safe_browsing_service_->ui_manager());
- - }
- -
- - return safe_browsing_url_checker_delegate_.get();
- + return nullptr;
- }
-
- base::Optional<std::string>
- diff --git a/chrome/browser/component_updater/file_type_policies_component_installer.cc b/chrome/browser/component_updater/file_type_policies_component_installer.cc
- --- a/chrome/browser/component_updater/file_type_policies_component_installer.cc
- +++ b/chrome/browser/component_updater/file_type_policies_component_installer.cc
- @@ -18,7 +18,9 @@
- #include "base/stl_util.h"
- #include "base/task/post_task.h"
- #include "base/version.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/common/safe_browsing/file_type_policies.h"
- +#endif
- #include "components/component_updater/component_updater_paths.h"
-
- using component_updater::ComponentUpdateService;
- diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc
- --- a/chrome/browser/download/chrome_download_manager_delegate.cc
- +++ b/chrome/browser/download/chrome_download_manager_delegate.cc
- @@ -39,8 +39,10 @@
- #include "chrome/browser/download/save_package_file_picker.h"
- #include "chrome/browser/platform_util.h"
- #include "chrome/browser/profiles/profile.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/browser/safe_browsing/download_protection/download_protection_util.h"
- #include "chrome/browser/safe_browsing/safe_browsing_service.h"
- +#endif
- #include "chrome/browser/ui/browser.h"
- #include "chrome/browser/ui/browser_finder.h"
- #include "chrome/browser/ui/chrome_pages.h"
- @@ -51,7 +53,9 @@
- #include "chrome/common/chrome_paths.h"
- #include "chrome/common/pdf_util.h"
- #include "chrome/common/pref_names.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/common/safe_browsing/file_type_policies.h"
- +#endif
- #include "chrome/grit/generated_resources.h"
- #include "components/download/public/common/download_interrupt_reasons.h"
- #include "components/download/public/common/download_item.h"
- @@ -106,8 +110,10 @@ using content::DownloadManager;
- using download::DownloadItem;
- using download::DownloadPathReservationTracker;
- using download::PathValidationResult;
- +#if defined(FULL_SAFE_BROWSING)
- using safe_browsing::DownloadFileType;
- using safe_browsing::DownloadProtectionService;
- +#endif
-
- namespace {
-
- @@ -760,19 +766,19 @@ ChromeDownloadManagerDelegate::ApplicationClientIdForFileScanning() const {
- return std::string(chrome::kApplicationClientIDStringForAVScanning);
- }
-
- +#if defined(FULL_SAFE_BROWSING)
- DownloadProtectionService*
- ChromeDownloadManagerDelegate::GetDownloadProtectionService() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- -#if defined(FULL_SAFE_BROWSING)
- safe_browsing::SafeBrowsingService* sb_service =
- g_browser_process->safe_browsing_service();
- if (sb_service && sb_service->download_protection_service() &&
- profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) {
- return sb_service->download_protection_service();
- }
- -#endif
- return nullptr;
- }
- +#endif
-
- void ChromeDownloadManagerDelegate::NotifyExtensions(
- DownloadItem* download,
- @@ -1214,13 +1220,17 @@ void ChromeDownloadManagerDelegate::OnDownloadTargetDetermined(
- DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true);
- #endif
-
- +#if defined(FULL_SAFE_BROWSING)
- DownloadItemModel(item).SetDangerLevel(target_info->danger_level);
- +#endif
- }
- +#if defined(FULL_SAFE_BROWSING)
- if (ShouldBlockFile(target_info->danger_type, item)) {
- target_info->result = download::DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED;
- // A dangerous type would take precendence over the blocking of the file.
- target_info->danger_type = download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS;
- }
- +#endif
-
- callback.Run(target_info->target_path, target_info->target_disposition,
- target_info->danger_type, target_info->intermediate_path,
- diff --git a/chrome/browser/download/chrome_download_manager_delegate.h b/chrome/browser/download/chrome_download_manager_delegate.h
- --- a/chrome/browser/download/chrome_download_manager_delegate.h
- +++ b/chrome/browser/download/chrome_download_manager_delegate.h
- @@ -21,8 +21,10 @@
- #include "build/build_config.h"
- #include "chrome/browser/download/download_target_determiner_delegate.h"
- #include "chrome/browser/download/download_target_info.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/browser/safe_browsing/download_protection/download_protection_service.h"
- #include "chrome/browser/safe_browsing/download_protection/download_protection_util.h"
- +#endif
- #include "components/download/public/common/download_danger_type.h"
- #include "components/download/public/common/download_item.h"
- #include "components/download/public/common/download_path_reservation_tracker.h"
- @@ -134,8 +136,10 @@ class ChromeDownloadManagerDelegate
- DownloadPrefs* download_prefs() { return download_prefs_.get(); }
-
- protected:
- +#if defined(FULL_SAFE_BROWSING)
- virtual safe_browsing::DownloadProtectionService*
- GetDownloadProtectionService();
- +#endif
-
- // Show file picker for |download|.
- virtual void ShowFilePickerForDownload(
- @@ -201,9 +205,11 @@ class ChromeDownloadManagerDelegate
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
-
- +#if defined(FULL_SAFE_BROWSING)
- // Callback function after the DownloadProtectionService completes.
- void CheckClientDownloadDone(uint32_t download_id,
- safe_browsing::DownloadCheckResult result);
- +#endif
-
- // Internal gateways for ShouldCompleteDownload().
- bool IsDownloadReadyForCompletion(
- diff --git a/chrome/browser/download/download_item_model.cc b/chrome/browser/download/download_item_model.cc
- --- a/chrome/browser/download/download_item_model.cc
- +++ b/chrome/browser/download/download_item_model.cc
- @@ -22,9 +22,11 @@
- #include "chrome/browser/download/download_stats.h"
- #include "chrome/browser/download/offline_item_utils.h"
- #include "chrome/browser/profiles/profile.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/browser/safe_browsing/download_protection/download_feedback_service.h"
- #include "chrome/common/safe_browsing/download_file_types.pb.h"
- #include "chrome/common/safe_browsing/file_type_policies.h"
- +#endif
- #include "chrome/grit/chromium_strings.h"
- #include "chrome/grit/generated_resources.h"
- #include "components/download/public/common/download_danger_type.h"
- @@ -37,7 +39,9 @@
-
- using base::TimeDelta;
- using download::DownloadItem;
- +#if defined(FULL_SAFE_BROWSING)
- using safe_browsing::DownloadFileType;
- +#endif
-
- namespace {
-
- @@ -67,9 +71,11 @@ class DownloadItemModelData : public base::SupportsUserData::Data {
- // for the file type.
- bool should_prefer_opening_in_browser_;
-
- +#if defined(FULL_SAFE_BROWSING)
- // Danger level of the file determined based on the file type and whether
- // there was a user action associated with the download.
- DownloadFileType::DangerLevel danger_level_;
- +#endif
-
- // Whether the download is currently being revived.
- bool is_being_revived_;
- @@ -106,7 +112,9 @@ DownloadItemModelData::DownloadItemModelData()
- : should_show_in_shelf_(true),
- was_ui_notified_(false),
- should_prefer_opening_in_browser_(false),
- +#if defined(FULL_SAFE_BROWSING)
- danger_level_(DownloadFileType::NOT_DANGEROUS),
- +#endif
- is_being_revived_(false) {}
-
- } // namespace
- @@ -368,6 +376,7 @@ void DownloadItemModel::SetShouldPreferOpeningInBrowser(bool preference) {
- data->should_prefer_opening_in_browser_ = preference;
- }
-
- +#if defined(FULL_SAFE_BROWSING)
- DownloadFileType::DangerLevel DownloadItemModel::GetDangerLevel() const {
- const DownloadItemModelData* data = DownloadItemModelData::Get(download_);
- return data ? data->danger_level_ : DownloadFileType::NOT_DANGEROUS;
- @@ -378,6 +387,7 @@ void DownloadItemModel::SetDangerLevel(
- DownloadItemModelData* data = DownloadItemModelData::GetOrCreate(download_);
- data->danger_level_ = danger_level;
- }
- +#endif
-
- bool DownloadItemModel::IsBeingRevived() const {
- const DownloadItemModelData* data = DownloadItemModelData::Get(download_);
- diff --git a/chrome/browser/download/download_item_model.h b/chrome/browser/download/download_item_model.h
- --- a/chrome/browser/download/download_item_model.h
- +++ b/chrome/browser/download/download_item_model.h
- @@ -11,7 +11,9 @@
- #include "base/macros.h"
- #include "base/strings/string16.h"
- #include "chrome/browser/download/download_ui_model.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/common/safe_browsing/download_file_types.pb.h"
- +#endif
- #include "components/download/public/common/download_item.h"
-
- // Implementation of DownloadUIModel that wrappers around a |DownloadItem*|. As
- @@ -48,9 +50,11 @@ class DownloadItemModel : public DownloadUIModel,
- void SetWasUINotified(bool should_notify) override;
- bool ShouldPreferOpeningInBrowser() const override;
- void SetShouldPreferOpeningInBrowser(bool preference) override;
- +#if defined(FULL_SAFE_BROWSING)
- safe_browsing::DownloadFileType::DangerLevel GetDangerLevel() const override;
- void SetDangerLevel(
- safe_browsing::DownloadFileType::DangerLevel danger_level) override;
- +#endif
- void OpenUsingPlatformHandler() override;
- bool IsBeingRevived() const override;
- void SetIsBeingRevived(bool is_being_revived) override;
- diff --git a/chrome/browser/download/download_prefs.cc b/chrome/browser/download/download_prefs.cc
- --- a/chrome/browser/download/download_prefs.cc
- +++ b/chrome/browser/download/download_prefs.cc
- @@ -33,7 +33,9 @@
- #include "chrome/common/chrome_features.h"
- #include "chrome/common/chrome_paths.h"
- #include "chrome/common/pref_names.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/common/safe_browsing/file_type_policies.h"
- +#endif
- #include "components/download/public/common/download_item.h"
- #include "components/pref_registry/pref_registry_syncable.h"
- #include "components/prefs/pref_service.h"
- @@ -55,7 +57,9 @@
- using content::BrowserContext;
- using content::BrowserThread;
- using content::DownloadManager;
- +#if defined(FULL_SAFE_BROWSING)
- using safe_browsing::FileTypePolicies;
- +#endif
-
- namespace {
-
- 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
- @@ -23,7 +23,9 @@
- #include "chrome/browser/history/history_service_factory.h"
- #include "chrome/browser/profiles/profile.h"
- #include "chrome/common/pref_names.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/common/safe_browsing/file_type_policies.h"
- +#endif
- #include "chrome/grit/generated_resources.h"
- #include "components/download/public/common/download_interrupt_reasons.h"
- #include "components/history/core/browser/history_service.h"
- @@ -59,13 +61,16 @@
- using content::BrowserThread;
- using download::DownloadItem;
- using download::DownloadPathReservationTracker;
- +#if defined(FULL_SAFE_BROWSING)
- using safe_browsing::DownloadFileType;
- +#endif
-
- namespace {
-
- const base::FilePath::CharType kCrdownloadSuffix[] =
- FILE_PATH_LITERAL(".crdownload");
-
- +#if defined(FULL_SAFE_BROWSING)
- // 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
- @@ -79,6 +84,7 @@ void VisitCountsToVisitedBefore(
- found_visits && count > 0 &&
- (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight()));
- }
- +#endif
-
- #if defined(OS_WIN)
- // Keeps track of whether Adobe Reader is up to date.
- @@ -103,7 +109,9 @@ DownloadTargetDeterminer::DownloadTargetDeterminer(
- create_target_directory_(false),
- conflict_action_(conflict_action),
- danger_type_(download->GetDangerType()),
- +#if defined(FULL_SAFE_BROWSING)
- danger_level_(DownloadFileType::NOT_DANGEROUS),
- +#endif
- virtual_path_(initial_virtual_path),
- is_filetype_handled_safely_(false),
- #if defined(OS_ANDROID)
- @@ -259,8 +267,12 @@ DownloadTargetDeterminer::Result
- // |suggested_filename| and Content-Disposition header have higher priority
- // than the URL.
- bool safe_file_ext =
- +#if defined(FULL_SAFE_BROWSING)
- !safe_browsing::FileTypePolicies::GetInstance()->IsCheckedBinaryFile(
- generated_filename);
- +#else
- + true;
- +#endif
- net::HttpContentDisposition content_disposition_header(
- download_->GetContentDisposition(), referrer_charset);
- bool should_replace_extension =
- @@ -749,6 +761,7 @@ DownloadTargetDeterminer::Result
- return CONTINUE;
- }
-
- +#if defined(FULL_SAFE_BROWSING)
- // 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
- @@ -785,6 +798,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;
- +#endif
- return CONTINUE;
- }
-
- @@ -792,11 +806,13 @@ void DownloadTargetDeterminer::CheckVisitedReferrerBeforeDone(
- bool visited_referrer_before) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK_EQ(STATE_DETERMINE_INTERMEDIATE_PATH, next_state_);
- +#if defined(FULL_SAFE_BROWSING)
- danger_level_ = GetDangerLevel(
- visited_referrer_before ? VISITED_REFERRER : NO_VISITS_TO_REFERRER);
- if (danger_level_ != DownloadFileType::NOT_DANGEROUS &&
- danger_type_ == download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS)
- danger_type_ = download::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE;
- +#endif
- DoLoop();
- }
-
- @@ -901,7 +917,9 @@ void DownloadTargetDeterminer::ScheduleCallbackAndDeleteSelf(
- << " Intermediate:" << intermediate_path_.AsUTF8Unsafe()
- << " Confirmation reason:" << static_cast<int>(confirmation_reason_)
- << " Danger type:" << danger_type_
- +#if defined(FULL_SAFE_BROWSING)
- << " Danger level:" << danger_level_
- +#endif
- << " Result:" << static_cast<int>(result);
- std::unique_ptr<DownloadTargetInfo> target_info(new DownloadTargetInfo);
-
- @@ -913,7 +931,9 @@ void DownloadTargetDeterminer::ScheduleCallbackAndDeleteSelf(
- ? DownloadItem::TARGET_DISPOSITION_PROMPT
- : DownloadItem::TARGET_DISPOSITION_OVERWRITE);
- target_info->danger_type = danger_type_;
- +#if defined(FULL_SAFE_BROWSING)
- target_info->danger_level = danger_level_;
- +#endif
- target_info->intermediate_path = intermediate_path_;
- target_info->mime_type = mime_type_;
- target_info->is_filetype_handled_safely = is_filetype_handled_safely_;
- @@ -999,6 +1019,7 @@ bool DownloadTargetDeterminer::HasPromptedForPath() const {
- DownloadItem::TARGET_DISPOSITION_PROMPT);
- }
-
- +#if defined(FULL_SAFE_BROWSING)
- DownloadFileType::DangerLevel DownloadTargetDeterminer::GetDangerLevel(
- PriorVisitsToReferrer visits) const {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- @@ -1030,6 +1051,7 @@ DownloadFileType::DangerLevel DownloadTargetDeterminer::GetDangerLevel(
-
- return DownloadFileType::NOT_DANGEROUS;
- }
- +#endif
-
- void DownloadTargetDeterminer::OnDownloadDestroyed(
- DownloadItem* download) {
- diff --git a/chrome/browser/download/download_target_determiner.h b/chrome/browser/download/download_target_determiner.h
- --- a/chrome/browser/download/download_target_determiner.h
- +++ b/chrome/browser/download/download_target_determiner.h
- @@ -16,7 +16,9 @@
- #include "build/build_config.h"
- #include "chrome/browser/download/download_target_determiner_delegate.h"
- #include "chrome/browser/download/download_target_info.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/common/safe_browsing/download_file_types.pb.h"
- +#endif
- #include "components/download/public/common/download_danger_type.h"
- #include "components/download/public/common/download_item.h"
- #include "components/download/public/common/download_path_reservation_tracker.h"
- @@ -300,6 +302,7 @@ class DownloadTargetDeterminer : public download::DownloadItem::Observer {
- // operation.
- bool HasPromptedForPath() const;
-
- +#if defined(FULL_SAFE_BROWSING)
- // Returns true if this download should show the "dangerous file" warning.
- // Various factors are considered, such as the type of the file, whether a
- // user action initiated the download, and whether the user has explicitly
- @@ -309,6 +312,7 @@ class DownloadTargetDeterminer : public download::DownloadItem::Observer {
- // to true if the download requires explicit user consent.
- safe_browsing::DownloadFileType::DangerLevel GetDangerLevel(
- PriorVisitsToReferrer visits) const;
- +#endif
-
- // download::DownloadItem::Observer
- void OnDownloadDestroyed(download::DownloadItem* download) override;
- @@ -321,7 +325,9 @@ class DownloadTargetDeterminer : public download::DownloadItem::Observer {
- download::DownloadPathReservationTracker::FilenameConflictAction
- conflict_action_;
- download::DownloadDangerType danger_type_;
- +#if defined(FULL_SAFE_BROWSING)
- safe_browsing::DownloadFileType::DangerLevel danger_level_;
- +#endif
- base::FilePath virtual_path_;
- base::FilePath local_path_;
- base::FilePath intermediate_path_;
- diff --git a/chrome/browser/download/download_target_info.cc b/chrome/browser/download/download_target_info.cc
- --- a/chrome/browser/download/download_target_info.cc
- +++ b/chrome/browser/download/download_target_info.cc
- @@ -4,12 +4,16 @@
-
- #include "chrome/browser/download/download_target_info.h"
-
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/common/safe_browsing/file_type_policies.h"
- +#endif
-
- DownloadTargetInfo::DownloadTargetInfo()
- : target_disposition(download::DownloadItem::TARGET_DISPOSITION_OVERWRITE),
- danger_type(download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
- +#if defined(FULL_SAFE_BROWSING)
- danger_level(safe_browsing::DownloadFileType::NOT_DANGEROUS),
- +#endif
- is_filetype_handled_safely(false),
- result(download::DOWNLOAD_INTERRUPT_REASON_NONE) {}
-
- diff --git a/chrome/browser/download/download_target_info.h b/chrome/browser/download/download_target_info.h
- --- a/chrome/browser/download/download_target_info.h
- +++ b/chrome/browser/download/download_target_info.h
- @@ -8,7 +8,9 @@
- #include <string>
-
- #include "base/files/file_path.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/common/safe_browsing/download_file_types.pb.h"
- +#endif
- #include "components/download/public/common/download_danger_type.h"
- #include "components/download/public/common/download_interrupt_reasons.h"
- #include "components/download/public/common/download_item.h"
- @@ -32,6 +34,7 @@ struct DownloadTargetInfo {
- // Danger type of the download.
- download::DownloadDangerType danger_type;
-
- +#if defined(FULL_SAFE_BROWSING)
- // The danger type of the download could be set to MAYBE_DANGEROUS_CONTENT if
- // the file type is handled by SafeBrowsing. However, if the SafeBrowsing
- // service is unable to verify whether the file is safe or not, we are on our
- @@ -57,6 +60,7 @@ struct DownloadTargetInfo {
- // SafeBrowsing may flag the file as being malicious, in which case the
- // malicious classification should take precedence.
- safe_browsing::DownloadFileType::DangerLevel danger_level;
- +#endif
-
- // Suggested intermediate path. The downloaded bytes should be written to this
- // path until all the bytes are available and the user has accepted a
- diff --git a/chrome/browser/download/download_ui_model.cc b/chrome/browser/download/download_ui_model.cc
- --- a/chrome/browser/download/download_ui_model.cc
- +++ b/chrome/browser/download/download_ui_model.cc
- @@ -25,7 +25,9 @@
-
- using base::TimeDelta;
- using download::DownloadItem;
- +#if defined(FULL_SAFE_BROWSING)
- using safe_browsing::DownloadFileType;
- +#endif
- using offline_items_collection::FailState;
-
- namespace {
- @@ -389,12 +391,14 @@ bool DownloadUIModel::ShouldPreferOpeningInBrowser() const {
-
- void DownloadUIModel::SetShouldPreferOpeningInBrowser(bool preference) {}
-
- +#if defined(FULL_SAFE_BROWSING)
- DownloadFileType::DangerLevel DownloadUIModel::GetDangerLevel() const {
- return DownloadFileType::NOT_DANGEROUS;
- }
-
- void DownloadUIModel::SetDangerLevel(
- DownloadFileType::DangerLevel danger_level) {}
- +#endif
-
- void DownloadUIModel::OpenUsingPlatformHandler() {}
-
- diff --git a/chrome/browser/download/download_ui_model.h b/chrome/browser/download/download_ui_model.h
- --- a/chrome/browser/download/download_ui_model.h
- +++ b/chrome/browser/download/download_ui_model.h
- @@ -14,7 +14,9 @@
- #include "base/strings/string16.h"
- #include "build/build_config.h"
- #include "chrome/browser/profiles/profile_manager.h"
- +#if defined(FULL_SAFE_BROWSING)
- #include "chrome/common/safe_browsing/download_file_types.pb.h"
- +#endif
- #include "components/download/public/common/download_item.h"
- #include "components/offline_items_collection/core/offline_item.h"
-
- @@ -172,6 +174,7 @@ class DownloadUIModel {
- // Change what's returned by ShouldPreferOpeningInBrowser to |preference|.
- virtual void SetShouldPreferOpeningInBrowser(bool preference);
-
- +#if defined(FULL_SAFE_BROWSING)
- // Return the danger level determined during download target determination.
- // The value returned here is independent of the danger level as determined by
- // the Safe Browsing.
- @@ -180,6 +183,7 @@ class DownloadUIModel {
- // Change what's returned by GetDangerLevel().
- virtual void SetDangerLevel(
- safe_browsing::DownloadFileType::DangerLevel danger_level);
- +#endif
-
- // Open the download using the platform handler for the download. The behavior
- // of this method will be different from DownloadItem::OpenDownload() if
- diff --git a/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc
- --- a/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc
- +++ b/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc
- @@ -399,7 +399,9 @@ void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles(
- content::ResourceContext* resource_context,
- ResourceType resource_type,
- std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) {
- +#if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE)
- ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
- +#endif // defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE)
-
- // Insert safe browsing to decide if the resource is safe.
- content::ResourceThrottle* first_throttle = NULL;
- diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
- --- a/chrome/browser/net/chrome_network_delegate.cc
- +++ b/chrome/browser/net/chrome_network_delegate.cc
- @@ -78,19 +78,6 @@ namespace {
-
- bool g_access_to_all_files_enabled = false;
-
- -// Gets called when the extensions finish work on the URL. If the extensions
- -// did not do a redirect (so |new_url| is empty) then we enforce the
- -// SafeSearch parameters. Otherwise we will get called again after the
- -// redirect and we enforce SafeSearch then.
- -void ForceGoogleSafeSearchCallbackWrapper(net::CompletionOnceCallback callback,
- - net::URLRequest* request,
- - GURL* new_url,
- - int rv) {
- - if (rv == net::OK && new_url->is_empty())
- - safe_search_util::ForceGoogleSafeSearch(request->url(), new_url);
- - std::move(callback).Run(rv);
- -}
- -
- bool IsAccessAllowedInternal(const base::FilePath& path,
- const base::FilePath& profile_path) {
- if (g_access_to_all_files_enabled)
- @@ -212,26 +199,8 @@ int ChromeNetworkDelegate::OnBeforeURLRequest(
- GURL* new_url) {
- extensions_delegate_->ForwardStartRequestStatus(request);
-
- - // The non-redirect case is handled in GoogleURLLoaderThrottle.
- - bool force_safe_search =
- - (force_google_safe_search_ && force_google_safe_search_->GetValue() &&
- - request->is_redirecting());
- -
- - net::CompletionOnceCallback wrapped_callback = std::move(callback);
- -
- - if (force_safe_search) {
- - wrapped_callback = base::BindOnce(
- - &ForceGoogleSafeSearchCallbackWrapper, std::move(wrapped_callback),
- - base::Unretained(request), base::Unretained(new_url));
- - }
- -
- - int rv = extensions_delegate_->NotifyBeforeURLRequest(
- - request, std::move(wrapped_callback), new_url);
- -
- - if (force_safe_search && rv == net::OK && new_url->is_empty())
- - safe_search_util::ForceGoogleSafeSearch(request->url(), new_url);
- -
- - return rv;
- + return extensions_delegate_->NotifyBeforeURLRequest(
- + request, std::move(callback), new_url);
- }
-
- int ChromeNetworkDelegate::OnBeforeStartTransaction(
- --
- 2.11.0
|