Chromium Code Reviews| 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..9d38226fed8846b415f4cb9b9405b1b9ee0094c3 100644 |
| --- a/chrome/browser/ui/content_settings/content_setting_image_model.cc |
| +++ b/chrome/browser/ui/content_settings/content_setting_image_model.cc |
| @@ -92,7 +92,6 @@ class ContentSettingMIDISysExImageModel |
| ContentSettingMIDISysExImageModel(); |
| void UpdateFromWebContents(WebContents* web_contents) override; |
| - |
| private: |
| DISALLOW_COPY_AND_ASSIGN(ContentSettingMIDISysExImageModel); |
| }; |
| @@ -521,39 +520,72 @@ ContentSettingImageModel::ContentSettingImageModel() |
| icon_badge_id_(gfx::VectorIconId::VECTOR_ICON_NONE), |
| explanatory_string_id_(0) {} |
| +// The ordering of the models here influences the order in which icons are |
| +// shown in the omnibox. |
| +static constexpr ContentSettingsType content_types[] = { |
|
tapted
2017/02/07 01:23:31
nit: Might be your C roots showing again ;). It's
Peter Kasting
2017/02/07 01:34:06
Don't generalize too hard -- see e.g. https://grou
|
| + CONTENT_SETTINGS_TYPE_COOKIES, |
| + CONTENT_SETTINGS_TYPE_IMAGES, |
| + CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| + CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
| + CONTENT_SETTINGS_TYPE_PLUGINS, |
| + CONTENT_SETTINGS_TYPE_POPUPS, |
| + CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| + CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, |
| + CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, |
| + CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
| + CONTENT_SETTINGS_TYPE_DEFAULT, |
|
tapted
2017/02/07 01:23:31
This at least needs a comment, but.. although I us
kylix_rd
2017/02/07 18:25:21
I started down this path, but it's going to requir
|
| + CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, |
| + CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
| +}; |
| + |
| // static |
| std::vector<std::unique_ptr<ContentSettingImageModel>> |
| ContentSettingImageModel::GenerateContentSettingImageModels() { |
| std::vector<std::unique_ptr<ContentSettingImageModel>> result; |
| - // The ordering of the models here influences the order in which icons are |
| - // shown in the omnibox. |
| - result.push_back(base::MakeUnique<ContentSettingBlockedImageModel>( |
| - CONTENT_SETTINGS_TYPE_COOKIES)); |
| - result.push_back(base::MakeUnique<ContentSettingBlockedImageModel>( |
| - CONTENT_SETTINGS_TYPE_IMAGES)); |
| - result.push_back(base::MakeUnique<ContentSettingBlockedImageModel>( |
| - CONTENT_SETTINGS_TYPE_JAVASCRIPT)); |
| - result.push_back(base::MakeUnique<ContentSettingBlockedImageModel>( |
| - CONTENT_SETTINGS_TYPE_PPAPI_BROKER)); |
| - result.push_back(base::MakeUnique<ContentSettingBlockedImageModel>( |
| - CONTENT_SETTINGS_TYPE_PLUGINS)); |
| - result.push_back(base::MakeUnique<ContentSettingBlockedImageModel>( |
| - CONTENT_SETTINGS_TYPE_POPUPS)); |
| - result.push_back(base::MakeUnique<ContentSettingGeolocationImageModel>()); |
| - result.push_back(base::MakeUnique<ContentSettingBlockedImageModel>( |
| - CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); |
| - result.push_back(base::MakeUnique<ContentSettingRPHImageModel>()); |
| - 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<ContentSettingMIDISysExImageModel>()); |
| - |
| + for (auto content_type : content_types) { |
|
tapted
2017/02/07 01:23:31
(with the above, my preference would be auto -> in
|
| + switch (content_type) { |
| + case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| + result.push_back( |
| + base::MakeUnique<ContentSettingGeolocationImageModel>()); |
| + break; |
| + case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: |
| + result.push_back(base::MakeUnique<ContentSettingRPHImageModel>()); |
| + break; |
| + case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| + result.push_back(base::MakeUnique<ContentSettingMediaImageModel>()); |
| + break; |
| + case CONTENT_SETTINGS_TYPE_DEFAULT: |
| + result.push_back( |
| + base::MakeUnique<ContentSettingSubresourceFilterImageModel>()); |
| + break; |
| + case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| + result.push_back(base::MakeUnique<ContentSettingMIDISysExImageModel>()); |
| + break; |
| + default: |
| + result.push_back( |
|
tapted
2017/02/07 01:23:31
Comment here, e.g.
// All other content settings
kylix_rd
2017/02/07 18:25:21
Done.
|
| + base::MakeUnique<ContentSettingBlockedImageModel>(content_type)); |
| + break; |
| + } |
| + } |
| return result; |
| } |
| +// static |
| +size_t ContentSettingImageModel::GetContentSettingImageModelIndexForTesting( |
|
tapted
2017/02/07 01:23:31
I would actually just expose kContentTypeIconOrder
kylix_rd
2017/02/07 18:25:21
Hmmm... I think keeping it internal and private is
tapted
2017/02/08 00:31:49
Although this is likely true, I've never seen it u
|
| + ContentSettingsType content_type) { |
| + size_t result = 0; |
| + if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) |
| + content_type = CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; |
| + for (size_t i = 0; i < ARRAYSIZE(content_types); ++i) { |
| + if (content_type == content_types[i]) |
| + return result; |
| + ++result; |
| + } |
| + NOTREACHED(); |
| + return ARRAYSIZE(content_types); |
|
tapted
2017/02/07 01:23:31
ARRAYSIZE -> arraysize (I'm not sure where ARRAYSI
kylix_rd
2017/02/07 18:25:21
Done.
|
| +} |
| + |
| #if defined(OS_MACOSX) |
| bool ContentSettingImageModel::UpdateFromWebContentsAndCheckIfIconChanged( |
| content::WebContents* web_contents) { |