| Index: chrome/browser/ui/content_settings/content_setting_image_model.cc
|
| diff --git a/chrome/browser/ui/content_settings/content_setting_image_model.cc b/chrome/browser/ui/content_settings/content_setting_image_model.cc
|
| index 1bef3be8a1f4d1faa43c6f0c1379345e4de734e6..9f888143a46b2dca309cc5530fc6854fa6902e7a 100644
|
| --- a/chrome/browser/ui/content_settings/content_setting_image_model.cc
|
| +++ b/chrome/browser/ui/content_settings/content_setting_image_model.cc
|
| @@ -8,8 +8,10 @@
|
| #include "base/macros.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "build/build_config.h"
|
| +#include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
| #include "chrome/browser/content_settings/tab_specific_content_settings.h"
|
| +#include "chrome/browser/download/download_request_limiter.h"
|
| #include "chrome/browser/plugins/plugin_utils.h"
|
| #include "chrome/browser/prerender/prerender_manager.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| @@ -36,6 +38,7 @@ using content::WebContents;
|
| // ContentSettingGeolocationImageModel - geolocation
|
| // ContentSettingRPHImageModel - protocol handlers
|
| // ContentSettingMIDISysExImageModel - midi sysex
|
| +// ContentSettingDownloadsImageModel - automatic downloads
|
| // ContentSettingMediaImageModel - media
|
| // ContentSettingSubresourceFilterImageModel - deceptive content
|
|
|
| @@ -97,6 +100,17 @@ class ContentSettingMIDISysExImageModel
|
| DISALLOW_COPY_AND_ASSIGN(ContentSettingMIDISysExImageModel);
|
| };
|
|
|
| +class ContentSettingDownloadsImageModel
|
| + : public ContentSettingSimpleImageModel {
|
| + public:
|
| + ContentSettingDownloadsImageModel();
|
| +
|
| + void UpdateFromWebContents(WebContents* web_contents) override;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(ContentSettingDownloadsImageModel);
|
| +};
|
| +
|
| namespace {
|
|
|
| struct ContentSettingsImageDetails {
|
| @@ -122,9 +136,6 @@ const ContentSettingsImageDetails kImageDetails[] = {
|
| IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT, 0, 0},
|
| {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, gfx::VectorIconId::EXTENSION,
|
| IDS_BLOCKED_PPAPI_BROKER_TITLE, 0, IDS_ALLOWED_PPAPI_BROKER_TITLE},
|
| - {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
|
| - gfx::VectorIconId::FILE_DOWNLOAD, IDS_BLOCKED_DOWNLOAD_TITLE,
|
| - IDS_BLOCKED_DOWNLOADS_EXPLANATION, IDS_ALLOWED_DOWNLOAD_TITLE},
|
| };
|
|
|
| const ContentSettingsImageDetails* GetImageDetails(ContentSettingsType type) {
|
| @@ -192,6 +203,9 @@ ContentSettingSimpleImageModel::CreateForContentTypeForTesting(
|
| if (content_settings_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX)
|
| return base::MakeUnique<ContentSettingMIDISysExImageModel>();
|
|
|
| + if (content_settings_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS)
|
| + return base::MakeUnique<ContentSettingDownloadsImageModel>();
|
| +
|
| return base::MakeUnique<ContentSettingBlockedImageModel>(
|
| content_settings_type);
|
| }
|
| @@ -502,6 +516,40 @@ void ContentSettingMIDISysExImageModel::UpdateFromWebContents(
|
| : IDS_MIDI_SYSEX_BLOCKED_TOOLTIP));
|
| }
|
|
|
| +// Automatic downloads ---------------------------------------------------------
|
| +
|
| +ContentSettingDownloadsImageModel::ContentSettingDownloadsImageModel()
|
| + : ContentSettingSimpleImageModel(
|
| + CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) {}
|
| +
|
| +void ContentSettingDownloadsImageModel::UpdateFromWebContents(
|
| + WebContents* web_contents) {
|
| + set_visible(false);
|
| + if (!web_contents)
|
| + return;
|
| +
|
| + switch (g_browser_process->download_request_limiter()->GetDownloadStatus(
|
| + web_contents)) {
|
| + case DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS:
|
| + set_visible(true);
|
| + set_icon_by_vector_id(gfx::VectorIconId::FILE_DOWNLOAD,
|
| + gfx::VectorIconId::VECTOR_ICON_NONE);
|
| + set_explanatory_string_id(0);
|
| + set_tooltip(l10n_util::GetStringUTF16(IDS_ALLOWED_DOWNLOAD_TITLE));
|
| + return;
|
| + case DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED:
|
| + set_visible(true);
|
| + set_icon_by_vector_id(gfx::VectorIconId::FILE_DOWNLOAD,
|
| + gfx::VectorIconId::BLOCKED_BADGE);
|
| + set_explanatory_string_id(IDS_BLOCKED_DOWNLOADS_EXPLANATION);
|
| + set_tooltip(l10n_util::GetStringUTF16(IDS_BLOCKED_DOWNLOAD_TITLE));
|
| + return;
|
| + default:
|
| + // No need to show icon otherwise.
|
| + return;
|
| + }
|
| +}
|
| +
|
| // Base class ------------------------------------------------------------------
|
|
|
| gfx::Image ContentSettingImageModel::GetIcon(SkColor nearby_text_color) const {
|
| @@ -547,8 +595,7 @@ ContentSettingImageModel::GenerateContentSettingImageModels() {
|
| result.push_back(base::MakeUnique<ContentSettingMediaImageModel>());
|
| result.push_back(
|
| base::MakeUnique<ContentSettingSubresourceFilterImageModel>());
|
| - result.push_back(base::MakeUnique<ContentSettingBlockedImageModel>(
|
| - CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS));
|
| + result.push_back(base::MakeUnique<ContentSettingDownloadsImageModel>());
|
| result.push_back(base::MakeUnique<ContentSettingMIDISysExImageModel>());
|
|
|
| return result;
|
|
|