Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/site_settings_handler.cc |
| diff --git a/chrome/browser/ui/webui/settings/site_settings_handler.cc b/chrome/browser/ui/webui/settings/site_settings_handler.cc |
| index 71d5f144c607e1f73669a0ca3df838326d92b6ae..820ef072fefb9e42be9b1d4e2c04f43a2c01a0df 100644 |
| --- a/chrome/browser/ui/webui/settings/site_settings_handler.cc |
| +++ b/chrome/browser/ui/webui/settings/site_settings_handler.cc |
| @@ -418,18 +418,20 @@ void SiteSettingsHandler::HandleGetExceptionList(const base::ListValue* args) { |
| HostContentSettingsMap* map = |
| HostContentSettingsMapFactory::GetForProfile(profile_); |
| + const auto* extension_registry = extensions::ExtensionRegistry::Get(profile_); |
| AddExceptionsGrantedByHostedApps(profile_, APIPermissionFromGroupName(type), |
| exceptions.get()); |
| site_settings::GetExceptionsFromHostContentSettingsMap( |
| - map, content_type, web_ui(), /*incognito=*/false, /*filter=*/nullptr, |
| - exceptions.get()); |
| + map, content_type, extension_registry, web_ui(), /*incognito=*/false, |
| + /*filter=*/nullptr, exceptions.get()); |
| if (profile_->HasOffTheRecordProfile()) { |
| Profile* incognito = profile_->GetOffTheRecordProfile(); |
| map = HostContentSettingsMapFactory::GetForProfile(incognito); |
| + extension_registry = extensions::ExtensionRegistry::Get(incognito); |
| site_settings::GetExceptionsFromHostContentSettingsMap( |
| - map, content_type, web_ui(), /*incognito=*/true, /*filter=*/nullptr, |
| - exceptions.get()); |
| + map, content_type, extension_registry, web_ui(), /*incognito=*/true, |
| + /*filter=*/nullptr, exceptions.get()); |
| } |
| ResolveJavascriptCallback(*callback_id, *exceptions.get()); |
| @@ -546,16 +548,19 @@ void SiteSettingsHandler::HandleGetSiteDetails( |
| HostContentSettingsMap* map = |
| HostContentSettingsMapFactory::GetForProfile(profile_); |
| + const auto* extension_registry = |
| + extensions::ExtensionRegistry::Get(profile_); |
| site_settings::GetExceptionsFromHostContentSettingsMap( |
| - map, content_type, web_ui(), /*incognito=*/false, /*filter=*/&site, |
| - exceptions.get()); |
| + map, content_type, extension_registry, web_ui(), /*incognito=*/false, |
| + /*filter=*/&site, exceptions.get()); |
| if (profile_->HasOffTheRecordProfile()) { |
| Profile* incognito = profile_->GetOffTheRecordProfile(); |
| map = HostContentSettingsMapFactory::GetForProfile(incognito); |
| + extension_registry = extensions::ExtensionRegistry::Get(incognito); |
| site_settings::GetExceptionsFromHostContentSettingsMap( |
| - map, content_type, web_ui(), /*incognito=*/true, /*filter=*/&site, |
| - exceptions.get()); |
| + map, content_type, extension_registry, web_ui(), /*incognito=*/true, |
| + /*filter=*/&site, exceptions.get()); |
| } |
| } |
| @@ -622,6 +627,8 @@ void SiteSettingsHandler::SendZoomLevels() { |
| content::HostZoomMap::ZoomLevelVector zoom_levels( |
| host_zoom_map->GetAllZoomLevels()); |
| + const auto* extension_registry = extensions::ExtensionRegistry::Get(profile_); |
| + |
| // Sort ZoomLevelChanges by host and scheme |
| // (a.com < http://a.com < https://a.com < b.com). |
| std::sort(zoom_levels.begin(), zoom_levels.end(), |
| @@ -629,20 +636,32 @@ void SiteSettingsHandler::SendZoomLevels() { |
| const content::HostZoomMap::ZoomLevelChange& b) { |
| return a.host == b.host ? a.scheme < b.scheme : a.host < b.host; |
| }); |
| - |
| - for (content::HostZoomMap::ZoomLevelVector::const_iterator i = |
| - zoom_levels.begin(); |
| - i != zoom_levels.end(); |
| - ++i) { |
| + for (const auto& zoom_level : zoom_levels) { |
| std::unique_ptr<base::DictionaryValue> exception(new base::DictionaryValue); |
| - switch (i->mode) { |
| + switch (zoom_level.mode) { |
| case content::HostZoomMap::ZOOM_CHANGED_FOR_HOST: { |
| - std::string host = i->host; |
| + std::string host = zoom_level.host; |
| if (host == content::kUnreachableWebDataURL) { |
| host = |
| l10n_util::GetStringUTF8(IDS_ZOOMLEVELS_CHROME_ERROR_PAGES_LABEL); |
| } |
| exception->SetString(site_settings::kOrigin, host); |
| + |
| + std::string displayName = host; |
| + std::string originForFavicon = host; |
| + // If it looks like an extension check if there is one with this id. |
| + if (host.length() == 32) { |
|
dschuyler
2016/11/28 21:58:42
The code is ok, maybe change the comments around a
dullweber
2016/11/29 09:34:18
That's right. I wanted to avoid checking every ent
|
| + const extensions::Extension* extension = |
| + extension_registry->GetExtensionById( |
| + host, extensions::ExtensionRegistry::EVERYTHING); |
| + if (extension) { |
| + originForFavicon = extension->url().spec(); |
| + displayName = extension->name(); |
| + } |
| + } |
| + exception->SetString(site_settings::kDisplayName, displayName); |
| + exception->SetString(site_settings::kOriginForFavicon, |
| + originForFavicon); |
| break; |
| } |
| case content::HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: |
| @@ -664,7 +683,7 @@ void SiteSettingsHandler::SendZoomLevels() { |
| // Calculate the zoom percent from the factor. Round up to the nearest whole |
| // number. |
| int zoom_percent = static_cast<int>( |
| - content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5); |
| + content::ZoomLevelToZoomFactor(zoom_level.zoom_level) * 100 + 0.5); |
| exception->SetString(kZoom, base::FormatPercent(zoom_percent)); |
| exception->SetString( |
| site_settings::kSource, site_settings::kPreferencesSource); |