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

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

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test compilation. Created 6 years, 4 months 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 | Annotate | Revision Log
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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 pref_change_registrar_.Add( 505 pref_change_registrar_.Add(
506 prefs::kVideoCaptureAllowed, 506 prefs::kVideoCaptureAllowed,
507 base::Bind(&ContentSettingsHandler::UpdateMediaSettingsView, 507 base::Bind(&ContentSettingsHandler::UpdateMediaSettingsView,
508 base::Unretained(this))); 508 base::Unretained(this)));
509 pref_change_registrar_.Add( 509 pref_change_registrar_.Add(
510 prefs::kEnableDRM, 510 prefs::kEnableDRM,
511 base::Bind( 511 base::Bind(
512 &ContentSettingsHandler::UpdateProtectedContentExceptionsButton, 512 &ContentSettingsHandler::UpdateProtectedContentExceptionsButton,
513 base::Unretained(this))); 513 base::Unretained(this)));
514 514
515 content::HostZoomMap* host_zoom_map = 515 // Here we only subscribe to the HostZoomMap for the default storage partition
516 content::HostZoomMap::GetForBrowserContext(context); 516 // since we don't allow the user to manage the zoom levels for apps.
517 // We're only interested in zoom-levels that are persisted, since the user
518 // is given the opportunity to view/delete these in the content-settings page.
517 host_zoom_map_subscription_ = 519 host_zoom_map_subscription_ =
518 host_zoom_map->AddZoomLevelChangedCallback( 520 content::HostZoomMap::GetDefaultForBrowserContext(context)
519 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, 521 ->AddZoomLevelChangedCallback(
520 base::Unretained(this))); 522 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged,
523 base::Unretained(this)));
521 524
522 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context)); 525 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context));
523 observer_.Add(Profile::FromWebUI(web_ui())->GetHostContentSettingsMap()); 526 observer_.Add(Profile::FromWebUI(web_ui())->GetHostContentSettingsMap());
524 } 527 }
525 528
526 void ContentSettingsHandler::InitializePage() { 529 void ContentSettingsHandler::InitializePage() {
527 media_settings_ = MediaSettingsInfo(); 530 media_settings_ = MediaSettingsInfo();
528 RefreshFlashMediaSettings(); 531 RefreshFlashMediaSettings();
529 532
530 UpdateHandlersEnabledRadios(); 533 UpdateHandlersEnabledRadios();
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 988
986 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); 989 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
987 UpdateExceptionsViewFromHostContentSettingsMap( 990 UpdateExceptionsViewFromHostContentSettingsMap(
988 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); 991 CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
989 } 992 }
990 993
991 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { 994 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() {
992 base::ListValue zoom_levels_exceptions; 995 base::ListValue zoom_levels_exceptions;
993 996
994 content::HostZoomMap* host_zoom_map = 997 content::HostZoomMap* host_zoom_map =
995 content::HostZoomMap::GetForBrowserContext(GetBrowserContext(web_ui())); 998 content::HostZoomMap::GetDefaultForBrowserContext(
999 GetBrowserContext(web_ui()));
996 content::HostZoomMap::ZoomLevelVector zoom_levels( 1000 content::HostZoomMap::ZoomLevelVector zoom_levels(
997 host_zoom_map->GetAllZoomLevels()); 1001 host_zoom_map->GetAllZoomLevels());
998 std::sort(zoom_levels.begin(), zoom_levels.end(), HostZoomSort); 1002 std::sort(zoom_levels.begin(), zoom_levels.end(), HostZoomSort);
999 1003
1000 for (content::HostZoomMap::ZoomLevelVector::const_iterator i = 1004 for (content::HostZoomMap::ZoomLevelVector::const_iterator i =
1001 zoom_levels.begin(); 1005 zoom_levels.begin();
1002 i != zoom_levels.end(); 1006 i != zoom_levels.end();
1003 ++i) { 1007 ++i) {
1004 scoped_ptr<base::DictionaryValue> exception(new base::DictionaryValue); 1008 scoped_ptr<base::DictionaryValue> exception(new base::DictionaryValue);
1005 switch (i->mode) { 1009 switch (i->mode) {
1006 case content::HostZoomMap::ZOOM_CHANGED_FOR_HOST: 1010 case content::HostZoomMap::ZOOM_CHANGED_FOR_HOST:
1007 exception->SetString(kOrigin, i->host); 1011 exception->SetString(kOrigin, i->host);
1008 break; 1012 break;
1009 case content::HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: 1013 case content::HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST:
1010 // These are not stored in preferences and get cleared on next browser 1014 // These are not stored in preferences and get cleared on next browser
1011 // start. Therefore, we don't care for them. 1015 // start. Therefore, we don't care for them.
1012 break; 1016 break;
1013 case content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: 1017 case content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM:
1014 NOTREACHED(); 1018 NOTREACHED();
1019 case content::HostZoomMap::ZOOM_CHANGED_DEFAULT_ZOOM_LEVEL:
1020 break;
1015 } 1021 }
1016 exception->SetString(kSetting, 1022 exception->SetString(kSetting,
1017 ContentSettingToString(CONTENT_SETTING_DEFAULT)); 1023 ContentSettingToString(CONTENT_SETTING_DEFAULT));
1018 1024
1019 // Calculate the zoom percent from the factor. Round up to the nearest whole 1025 // Calculate the zoom percent from the factor. Round up to the nearest whole
1020 // number. 1026 // number.
1021 int zoom_percent = static_cast<int>( 1027 int zoom_percent = static_cast<int>(
1022 content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5); 1028 content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5);
1023 exception->SetString( 1029 exception->SetString(
1024 kZoom, 1030 kZoom,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 const base::ListValue* args) { 1244 const base::ListValue* args) {
1239 std::string mode; 1245 std::string mode;
1240 bool rv = args->GetString(1, &mode); 1246 bool rv = args->GetString(1, &mode);
1241 DCHECK(rv); 1247 DCHECK(rv);
1242 1248
1243 std::string pattern; 1249 std::string pattern;
1244 rv = args->GetString(2, &pattern); 1250 rv = args->GetString(2, &pattern);
1245 DCHECK(rv); 1251 DCHECK(rv);
1246 1252
1247 content::HostZoomMap* host_zoom_map = 1253 content::HostZoomMap* host_zoom_map =
1248 content::HostZoomMap::GetForBrowserContext(GetBrowserContext(web_ui())); 1254 content::HostZoomMap::GetDefaultForBrowserContext(
1255 GetBrowserContext(web_ui()));
1249 double default_level = host_zoom_map->GetDefaultZoomLevel(); 1256 double default_level = host_zoom_map->GetDefaultZoomLevel();
1250 host_zoom_map->SetZoomLevelForHost(pattern, default_level); 1257 host_zoom_map->SetZoomLevelForHost(pattern, default_level);
1251 } 1258 }
1252 1259
1253 void ContentSettingsHandler::RegisterMessages() { 1260 void ContentSettingsHandler::RegisterMessages() {
1254 web_ui()->RegisterMessageCallback("setContentFilter", 1261 web_ui()->RegisterMessageCallback("setContentFilter",
1255 base::Bind(&ContentSettingsHandler::SetContentFilter, 1262 base::Bind(&ContentSettingsHandler::SetContentFilter,
1256 base::Unretained(this))); 1263 base::Unretained(this)));
1257 web_ui()->RegisterMessageCallback("removeException", 1264 web_ui()->RegisterMessageCallback("removeException",
1258 base::Bind(&ContentSettingsHandler::RemoveException, 1265 base::Bind(&ContentSettingsHandler::RemoveException,
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { 1574 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() {
1568 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1575 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1569 // Exceptions apply only when the feature is enabled. 1576 // Exceptions apply only when the feature is enabled.
1570 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1577 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1571 web_ui()->CallJavascriptFunction( 1578 web_ui()->CallJavascriptFunction(
1572 "ContentSettings.enableProtectedContentExceptions", 1579 "ContentSettings.enableProtectedContentExceptions",
1573 base::FundamentalValue(enable_exceptions)); 1580 base::FundamentalValue(enable_exceptions));
1574 } 1581 }
1575 1582
1576 } // namespace options 1583 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698