Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 1412453002: Remove enable-iframe-based-signin flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded test class Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/content_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 // Here we only subscribe to the HostZoomMap for the default storage partition 585 // Here we only subscribe to the HostZoomMap for the default storage partition
586 // since we don't allow the user to manage the zoom levels for apps. 586 // since we don't allow the user to manage the zoom levels for apps.
587 // We're only interested in zoom-levels that are persisted, since the user 587 // We're only interested in zoom-levels that are persisted, since the user
588 // is given the opportunity to view/delete these in the content-settings page. 588 // is given the opportunity to view/delete these in the content-settings page.
589 host_zoom_map_subscription_ = 589 host_zoom_map_subscription_ =
590 content::HostZoomMap::GetDefaultForBrowserContext(context) 590 content::HostZoomMap::GetDefaultForBrowserContext(context)
591 ->AddZoomLevelChangedCallback( 591 ->AddZoomLevelChangedCallback(
592 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, 592 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged,
593 base::Unretained(this))); 593 base::Unretained(this)));
594 594
595 if (!switches::IsEnableWebviewBasedSignin()) {
596 // The legacy signin page uses a different storage partition, so we need to
597 // add a subscription for its HostZoomMap separately.
598 GURL signin_url(chrome::kChromeUIChromeSigninURL);
599 content::StoragePartition* signin_partition =
600 content::BrowserContext::GetStoragePartitionForSite(
601 GetBrowserContext(web_ui()), signin_url);
602 content::HostZoomMap* signin_host_zoom_map =
603 signin_partition->GetHostZoomMap();
604 signin_host_zoom_map_subscription_ =
605 signin_host_zoom_map->AddZoomLevelChangedCallback(
606 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged,
607 base::Unretained(this)));
608 }
609
610 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context)); 595 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context));
611 596
612 Profile* profile = Profile::FromWebUI(web_ui()); 597 Profile* profile = Profile::FromWebUI(web_ui());
613 observer_.Add(HostContentSettingsMapFactory::GetForProfile(profile)); 598 observer_.Add(HostContentSettingsMapFactory::GetForProfile(profile));
614 if (profile->HasOffTheRecordProfile()) { 599 if (profile->HasOffTheRecordProfile()) {
615 auto map = HostContentSettingsMapFactory::GetForProfile( 600 auto map = HostContentSettingsMapFactory::GetForProfile(
616 profile->GetOffTheRecordProfile()); 601 profile->GetOffTheRecordProfile());
617 if (!observer_.IsObserving(map)) 602 if (!observer_.IsObserving(map))
618 observer_.Add(map); 603 observer_.Add(map);
619 } 604 }
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 settings.exceptions_initialized = true; 941 settings.exceptions_initialized = true;
957 UpdateFlashMediaLinksVisibility(type); 942 UpdateFlashMediaLinksVisibility(type);
958 } 943 }
959 944
960 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() { 945 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() {
961 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); 946 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
962 UpdateExceptionsViewFromHostContentSettingsMap( 947 UpdateExceptionsViewFromHostContentSettingsMap(
963 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); 948 CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
964 } 949 }
965 950
966 void ContentSettingsHandler::AdjustZoomLevelsListForSigninPageIfNecessary(
967 content::HostZoomMap::ZoomLevelVector* zoom_levels) {
968 if (switches::IsEnableWebviewBasedSignin())
969 return;
970
971 GURL signin_url(chrome::kChromeUIChromeSigninURL);
972 content::HostZoomMap* signin_host_zoom_map =
973 content::BrowserContext::GetStoragePartitionForSite(
974 GetBrowserContext(web_ui()), signin_url)->GetHostZoomMap();
975
976 // Since zoom levels set for scheme + host are not persisted, and since the
977 // signin page zoom levels need to be persisted, they are stored without
978 // a scheme. We use an empty scheme string to indicate this.
979 std::string scheme;
980 std::string host = signin_url.host();
981
982 // If there's a WebView signin zoom level, remove it.
983 content::HostZoomMap::ZoomLevelVector::iterator it =
984 std::find_if(zoom_levels->begin(), zoom_levels->end(),
985 [&host](content::HostZoomMap::ZoomLevelChange change) {
986 return change.host == host;
987 });
988 if (it != zoom_levels->end())
989 zoom_levels->erase(it);
990
991 // If there's a non-WebView signin zoom level, add it.
992 if (signin_host_zoom_map->HasZoomLevel(scheme, host)) {
993 content::HostZoomMap::ZoomLevelChange change = {
994 content::HostZoomMap::ZOOM_CHANGED_FOR_HOST,
995 host,
996 scheme,
997 signin_host_zoom_map->GetZoomLevelForHostAndScheme(scheme, host)};
998 zoom_levels->push_back(change);
999 }
1000 }
1001
1002 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { 951 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() {
1003 base::ListValue zoom_levels_exceptions; 952 base::ListValue zoom_levels_exceptions;
1004 953
1005 content::HostZoomMap* host_zoom_map = 954 content::HostZoomMap* host_zoom_map =
1006 content::HostZoomMap::GetDefaultForBrowserContext( 955 content::HostZoomMap::GetDefaultForBrowserContext(
1007 GetBrowserContext(web_ui())); 956 GetBrowserContext(web_ui()));
1008 content::HostZoomMap::ZoomLevelVector zoom_levels( 957 content::HostZoomMap::ZoomLevelVector zoom_levels(
1009 host_zoom_map->GetAllZoomLevels()); 958 host_zoom_map->GetAllZoomLevels());
1010 959
1011 AdjustZoomLevelsListForSigninPageIfNecessary(&zoom_levels);
1012
1013 // Sort ZoomLevelChanges by host and scheme 960 // Sort ZoomLevelChanges by host and scheme
1014 // (a.com < http://a.com < https://a.com < b.com). 961 // (a.com < http://a.com < https://a.com < b.com).
1015 std::sort(zoom_levels.begin(), zoom_levels.end(), 962 std::sort(zoom_levels.begin(), zoom_levels.end(),
1016 [](const content::HostZoomMap::ZoomLevelChange& a, 963 [](const content::HostZoomMap::ZoomLevelChange& a,
1017 const content::HostZoomMap::ZoomLevelChange& b) { 964 const content::HostZoomMap::ZoomLevelChange& b) {
1018 return a.host == b.host ? a.scheme < b.scheme : a.host < b.host; 965 return a.host == b.host ? a.scheme < b.scheme : a.host < b.host;
1019 }); 966 });
1020 967
1021 for (content::HostZoomMap::ZoomLevelVector::const_iterator i = 968 for (content::HostZoomMap::ZoomLevelVector::const_iterator i =
1022 zoom_levels.begin(); 969 zoom_levels.begin();
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 std::string pattern; 1252 std::string pattern;
1306 rv = args->GetString(2, &pattern); 1253 rv = args->GetString(2, &pattern);
1307 DCHECK(rv); 1254 DCHECK(rv);
1308 1255
1309 if (pattern == 1256 if (pattern ==
1310 l10n_util::GetStringUTF8(IDS_ZOOMLEVELS_CHROME_ERROR_PAGES_LABEL)) { 1257 l10n_util::GetStringUTF8(IDS_ZOOMLEVELS_CHROME_ERROR_PAGES_LABEL)) {
1311 pattern = content::kUnreachableWebDataURL; 1258 pattern = content::kUnreachableWebDataURL;
1312 } 1259 }
1313 1260
1314 content::HostZoomMap* host_zoom_map; 1261 content::HostZoomMap* host_zoom_map;
1315 if (switches::IsEnableWebviewBasedSignin() || 1262 host_zoom_map =
1316 pattern != chrome::kChromeUIChromeSigninHost) { 1263 content::HostZoomMap::GetDefaultForBrowserContext(
1317 host_zoom_map = 1264 GetBrowserContext(web_ui()));
1318 content::HostZoomMap::GetDefaultForBrowserContext(
1319 GetBrowserContext(web_ui()));
1320 } else {
1321 host_zoom_map =
1322 content::BrowserContext::GetStoragePartitionForSite(
1323 GetBrowserContext(web_ui()), GURL(chrome::kChromeUIChromeSigninURL))
1324 ->GetHostZoomMap();
1325 }
1326 double default_level = host_zoom_map->GetDefaultZoomLevel(); 1265 double default_level = host_zoom_map->GetDefaultZoomLevel();
1327 host_zoom_map->SetZoomLevelForHost(pattern, default_level); 1266 host_zoom_map->SetZoomLevelForHost(pattern, default_level);
1328 } 1267 }
1329 1268
1330 void ContentSettingsHandler::RegisterMessages() { 1269 void ContentSettingsHandler::RegisterMessages() {
1331 web_ui()->RegisterMessageCallback("setContentFilter", 1270 web_ui()->RegisterMessageCallback("setContentFilter",
1332 base::Bind(&ContentSettingsHandler::SetContentFilter, 1271 base::Bind(&ContentSettingsHandler::SetContentFilter,
1333 base::Unretained(this))); 1272 base::Unretained(this)));
1334 web_ui()->RegisterMessageCallback("removeException", 1273 web_ui()->RegisterMessageCallback("removeException",
1335 base::Bind(&ContentSettingsHandler::RemoveException, 1274 base::Bind(&ContentSettingsHandler::RemoveException,
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 1601
1663 // Exceptions apply only when the feature is enabled. 1602 // Exceptions apply only when the feature is enabled.
1664 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1603 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1665 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1604 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1666 web_ui()->CallJavascriptFunction( 1605 web_ui()->CallJavascriptFunction(
1667 "ContentSettings.enableProtectedContentExceptions", 1606 "ContentSettings.enableProtectedContentExceptions",
1668 base::FundamentalValue(enable_exceptions)); 1607 base::FundamentalValue(enable_exceptions));
1669 } 1608 }
1670 1609
1671 } // namespace options 1610 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698