Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 pref_change_registrar_.Add( | 508 pref_change_registrar_.Add( |
| 509 prefs::kVideoCaptureAllowed, | 509 prefs::kVideoCaptureAllowed, |
| 510 base::Bind(&ContentSettingsHandler::UpdateMediaSettingsView, | 510 base::Bind(&ContentSettingsHandler::UpdateMediaSettingsView, |
| 511 base::Unretained(this))); | 511 base::Unretained(this))); |
| 512 pref_change_registrar_.Add( | 512 pref_change_registrar_.Add( |
| 513 prefs::kEnableDRM, | 513 prefs::kEnableDRM, |
| 514 base::Bind( | 514 base::Bind( |
| 515 &ContentSettingsHandler::UpdateProtectedContentExceptionsButton, | 515 &ContentSettingsHandler::UpdateProtectedContentExceptionsButton, |
| 516 base::Unretained(this))); | 516 base::Unretained(this))); |
| 517 | 517 |
| 518 content::HostZoomMap* host_zoom_map = | 518 // Here we only subscribe to the HostZoomMap for the default storage partition |
| 519 content::HostZoomMap::GetForBrowserContext(context); | 519 // since we don't allow the user to manage the zoom levels for apps. |
| 520 // We're only interested in zoom-levels that are persisted, since the user | |
| 521 // is given the opportunity to view/delete these in the content-settings page. | |
| 520 host_zoom_map_subscription_ = | 522 host_zoom_map_subscription_ = |
| 521 host_zoom_map->AddZoomLevelChangedCallback( | 523 content::HostZoomMap::GetDefaultForBrowserContext(context) |
| 522 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, | 524 ->AddZoomLevelChangedCallback( |
| 523 base::Unretained(this))); | 525 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, |
| 526 base::Unretained(this))); | |
|
Fady Samuel
2014/08/14 18:56:26
Is there a lifetime issue here?
wjmaclean
2014/08/14 19:12:20
I don't think so. Assuming the previous code was c
| |
| 524 | 527 |
| 525 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context)); | 528 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context)); |
| 526 } | 529 } |
| 527 | 530 |
| 528 void ContentSettingsHandler::InitializePage() { | 531 void ContentSettingsHandler::InitializePage() { |
| 529 media_settings_ = MediaSettingsInfo(); | 532 media_settings_ = MediaSettingsInfo(); |
| 530 RefreshFlashMediaSettings(); | 533 RefreshFlashMediaSettings(); |
| 531 | 534 |
| 532 UpdateHandlersEnabledRadios(); | 535 UpdateHandlersEnabledRadios(); |
| 533 UpdateAllExceptionsViewsFromModel(); | 536 UpdateAllExceptionsViewsFromModel(); |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 992 | 995 |
| 993 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); | 996 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
| 994 UpdateExceptionsViewFromHostContentSettingsMap( | 997 UpdateExceptionsViewFromHostContentSettingsMap( |
| 995 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); | 998 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
| 996 } | 999 } |
| 997 | 1000 |
| 998 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { | 1001 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { |
| 999 base::ListValue zoom_levels_exceptions; | 1002 base::ListValue zoom_levels_exceptions; |
| 1000 | 1003 |
| 1001 content::HostZoomMap* host_zoom_map = | 1004 content::HostZoomMap* host_zoom_map = |
| 1002 content::HostZoomMap::GetForBrowserContext(GetBrowserContext(web_ui())); | 1005 content::HostZoomMap::GetDefaultForBrowserContext( |
| 1006 GetBrowserContext(web_ui())); | |
| 1003 content::HostZoomMap::ZoomLevelVector zoom_levels( | 1007 content::HostZoomMap::ZoomLevelVector zoom_levels( |
| 1004 host_zoom_map->GetAllZoomLevels()); | 1008 host_zoom_map->GetAllZoomLevels()); |
| 1005 std::sort(zoom_levels.begin(), zoom_levels.end(), HostZoomSort); | 1009 std::sort(zoom_levels.begin(), zoom_levels.end(), HostZoomSort); |
| 1006 | 1010 |
| 1007 for (content::HostZoomMap::ZoomLevelVector::const_iterator i = | 1011 for (content::HostZoomMap::ZoomLevelVector::const_iterator i = |
| 1008 zoom_levels.begin(); | 1012 zoom_levels.begin(); |
| 1009 i != zoom_levels.end(); | 1013 i != zoom_levels.end(); |
| 1010 ++i) { | 1014 ++i) { |
| 1011 scoped_ptr<base::DictionaryValue> exception(new base::DictionaryValue); | 1015 scoped_ptr<base::DictionaryValue> exception(new base::DictionaryValue); |
| 1012 switch (i->mode) { | 1016 switch (i->mode) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 const base::ListValue* args) { | 1249 const base::ListValue* args) { |
| 1246 std::string mode; | 1250 std::string mode; |
| 1247 bool rv = args->GetString(1, &mode); | 1251 bool rv = args->GetString(1, &mode); |
| 1248 DCHECK(rv); | 1252 DCHECK(rv); |
| 1249 | 1253 |
| 1250 std::string pattern; | 1254 std::string pattern; |
| 1251 rv = args->GetString(2, &pattern); | 1255 rv = args->GetString(2, &pattern); |
| 1252 DCHECK(rv); | 1256 DCHECK(rv); |
| 1253 | 1257 |
| 1254 content::HostZoomMap* host_zoom_map = | 1258 content::HostZoomMap* host_zoom_map = |
| 1255 content::HostZoomMap::GetForBrowserContext(GetBrowserContext(web_ui())); | 1259 content::HostZoomMap::GetDefaultForBrowserContext( |
| 1260 GetBrowserContext(web_ui())); | |
| 1256 double default_level = host_zoom_map->GetDefaultZoomLevel(); | 1261 double default_level = host_zoom_map->GetDefaultZoomLevel(); |
| 1257 host_zoom_map->SetZoomLevelForHost(pattern, default_level); | 1262 host_zoom_map->SetZoomLevelForHost(pattern, default_level); |
| 1258 } | 1263 } |
| 1259 | 1264 |
| 1260 void ContentSettingsHandler::RegisterMessages() { | 1265 void ContentSettingsHandler::RegisterMessages() { |
| 1261 web_ui()->RegisterMessageCallback("setContentFilter", | 1266 web_ui()->RegisterMessageCallback("setContentFilter", |
| 1262 base::Bind(&ContentSettingsHandler::SetContentFilter, | 1267 base::Bind(&ContentSettingsHandler::SetContentFilter, |
| 1263 base::Unretained(this))); | 1268 base::Unretained(this))); |
| 1264 web_ui()->RegisterMessageCallback("removeException", | 1269 web_ui()->RegisterMessageCallback("removeException", |
| 1265 base::Bind(&ContentSettingsHandler::RemoveException, | 1270 base::Bind(&ContentSettingsHandler::RemoveException, |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1574 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { | 1579 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { |
| 1575 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1580 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1576 // Exceptions apply only when the feature is enabled. | 1581 // Exceptions apply only when the feature is enabled. |
| 1577 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1582 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1578 web_ui()->CallJavascriptFunction( | 1583 web_ui()->CallJavascriptFunction( |
| 1579 "ContentSettings.enableProtectedContentExceptions", | 1584 "ContentSettings.enableProtectedContentExceptions", |
| 1580 base::FundamentalValue(enable_exceptions)); | 1585 base::FundamentalValue(enable_exceptions)); |
| 1581 } | 1586 } |
| 1582 | 1587 |
| 1583 } // namespace options | 1588 } // namespace options |
| OLD | NEW |