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

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: Rebase to 291677. 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 pref_change_registrar_.Add( 474 pref_change_registrar_.Add(
475 prefs::kVideoCaptureAllowed, 475 prefs::kVideoCaptureAllowed,
476 base::Bind(&ContentSettingsHandler::UpdateMediaSettingsView, 476 base::Bind(&ContentSettingsHandler::UpdateMediaSettingsView,
477 base::Unretained(this))); 477 base::Unretained(this)));
478 pref_change_registrar_.Add( 478 pref_change_registrar_.Add(
479 prefs::kEnableDRM, 479 prefs::kEnableDRM,
480 base::Bind( 480 base::Bind(
481 &ContentSettingsHandler::UpdateProtectedContentExceptionsButton, 481 &ContentSettingsHandler::UpdateProtectedContentExceptionsButton,
482 base::Unretained(this))); 482 base::Unretained(this)));
483 483
484 content::HostZoomMap* host_zoom_map = 484 // Here we only subscribe to the HostZoomMap for the default storage partition
485 content::HostZoomMap::GetForBrowserContext(context); 485 // since we don't allow the user to manage the zoom levels for apps.
486 // We're only interested in zoom-levels that are persisted, since the user
487 // is given the opportunity to view/delete these in the content-settings page.
486 host_zoom_map_subscription_ = 488 host_zoom_map_subscription_ =
487 host_zoom_map->AddZoomLevelChangedCallback( 489 content::HostZoomMap::GetDefaultForBrowserContext(context)
488 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, 490 ->AddZoomLevelChangedCallback(
489 base::Unretained(this))); 491 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged,
492 base::Unretained(this)));
490 493
491 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context)); 494 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context));
492 observer_.Add(Profile::FromWebUI(web_ui())->GetHostContentSettingsMap()); 495 observer_.Add(Profile::FromWebUI(web_ui())->GetHostContentSettingsMap());
493 } 496 }
494 497
495 void ContentSettingsHandler::InitializePage() { 498 void ContentSettingsHandler::InitializePage() {
496 media_settings_ = MediaSettingsInfo(); 499 media_settings_ = MediaSettingsInfo();
497 RefreshFlashMediaSettings(); 500 RefreshFlashMediaSettings();
498 501
499 UpdateHandlersEnabledRadios(); 502 UpdateHandlersEnabledRadios();
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 957
955 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); 958 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
956 UpdateExceptionsViewFromHostContentSettingsMap( 959 UpdateExceptionsViewFromHostContentSettingsMap(
957 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); 960 CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
958 } 961 }
959 962
960 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { 963 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() {
961 base::ListValue zoom_levels_exceptions; 964 base::ListValue zoom_levels_exceptions;
962 965
963 content::HostZoomMap* host_zoom_map = 966 content::HostZoomMap* host_zoom_map =
964 content::HostZoomMap::GetForBrowserContext(GetBrowserContext(web_ui())); 967 content::HostZoomMap::GetDefaultForBrowserContext(
968 GetBrowserContext(web_ui()));
965 content::HostZoomMap::ZoomLevelVector zoom_levels( 969 content::HostZoomMap::ZoomLevelVector zoom_levels(
966 host_zoom_map->GetAllZoomLevels()); 970 host_zoom_map->GetAllZoomLevels());
967 std::sort(zoom_levels.begin(), zoom_levels.end(), HostZoomSort); 971 std::sort(zoom_levels.begin(), zoom_levels.end(), HostZoomSort);
968 972
969 for (content::HostZoomMap::ZoomLevelVector::const_iterator i = 973 for (content::HostZoomMap::ZoomLevelVector::const_iterator i =
970 zoom_levels.begin(); 974 zoom_levels.begin();
971 i != zoom_levels.end(); 975 i != zoom_levels.end();
972 ++i) { 976 ++i) {
973 scoped_ptr<base::DictionaryValue> exception(new base::DictionaryValue); 977 scoped_ptr<base::DictionaryValue> exception(new base::DictionaryValue);
974 switch (i->mode) { 978 switch (i->mode) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 const base::ListValue* args) { 1211 const base::ListValue* args) {
1208 std::string mode; 1212 std::string mode;
1209 bool rv = args->GetString(1, &mode); 1213 bool rv = args->GetString(1, &mode);
1210 DCHECK(rv); 1214 DCHECK(rv);
1211 1215
1212 std::string pattern; 1216 std::string pattern;
1213 rv = args->GetString(2, &pattern); 1217 rv = args->GetString(2, &pattern);
1214 DCHECK(rv); 1218 DCHECK(rv);
1215 1219
1216 content::HostZoomMap* host_zoom_map = 1220 content::HostZoomMap* host_zoom_map =
1217 content::HostZoomMap::GetForBrowserContext(GetBrowserContext(web_ui())); 1221 content::HostZoomMap::GetDefaultForBrowserContext(
1222 GetBrowserContext(web_ui()));
1218 double default_level = host_zoom_map->GetDefaultZoomLevel(); 1223 double default_level = host_zoom_map->GetDefaultZoomLevel();
1219 host_zoom_map->SetZoomLevelForHost(pattern, default_level); 1224 host_zoom_map->SetZoomLevelForHost(pattern, default_level);
1220 } 1225 }
1221 1226
1222 void ContentSettingsHandler::RegisterMessages() { 1227 void ContentSettingsHandler::RegisterMessages() {
1223 web_ui()->RegisterMessageCallback("setContentFilter", 1228 web_ui()->RegisterMessageCallback("setContentFilter",
1224 base::Bind(&ContentSettingsHandler::SetContentFilter, 1229 base::Bind(&ContentSettingsHandler::SetContentFilter,
1225 base::Unretained(this))); 1230 base::Unretained(this)));
1226 web_ui()->RegisterMessageCallback("removeException", 1231 web_ui()->RegisterMessageCallback("removeException",
1227 base::Bind(&ContentSettingsHandler::RemoveException, 1232 base::Bind(&ContentSettingsHandler::RemoveException,
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { 1541 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() {
1537 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1542 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1538 // Exceptions apply only when the feature is enabled. 1543 // Exceptions apply only when the feature is enabled.
1539 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1544 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1540 web_ui()->CallJavascriptFunction( 1545 web_ui()->CallJavascriptFunction(
1541 "ContentSettings.enableProtectedContentExceptions", 1546 "ContentSettings.enableProtectedContentExceptions",
1542 base::FundamentalValue(enable_exceptions)); 1547 base::FundamentalValue(enable_exceptions));
1543 } 1548 }
1544 1549
1545 } // namespace options 1550 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698