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 26 matching lines...) Expand all Loading... | |
37 #include "components/google/core/browser/google_util.h" | 37 #include "components/google/core/browser/google_util.h" |
38 #include "components/user_prefs/user_prefs.h" | 38 #include "components/user_prefs/user_prefs.h" |
39 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
40 #include "content/public/browser/notification_source.h" | 40 #include "content/public/browser/notification_source.h" |
41 #include "content/public/browser/notification_types.h" | 41 #include "content/public/browser/notification_types.h" |
42 #include "content/public/browser/user_metrics.h" | 42 #include "content/public/browser/user_metrics.h" |
43 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
44 #include "content/public/browser/web_ui.h" | 44 #include "content/public/browser/web_ui.h" |
45 #include "content/public/common/content_switches.h" | 45 #include "content/public/common/content_switches.h" |
46 #include "content/public/common/page_zoom.h" | 46 #include "content/public/common/page_zoom.h" |
47 #include "content/public/common/url_constants.h" | |
47 #include "extensions/browser/extension_registry.h" | 48 #include "extensions/browser/extension_registry.h" |
48 #include "extensions/common/extension_set.h" | 49 #include "extensions/common/extension_set.h" |
49 #include "extensions/common/permissions/api_permission.h" | 50 #include "extensions/common/permissions/api_permission.h" |
50 #include "extensions/common/permissions/permissions_data.h" | 51 #include "extensions/common/permissions/permissions_data.h" |
51 #include "ui/base/l10n/l10n_util.h" | 52 #include "ui/base/l10n/l10n_util.h" |
52 | 53 |
53 #if defined(OS_CHROMEOS) | 54 #if defined(OS_CHROMEOS) |
54 #include "components/user_manager/user_manager.h" | 55 #include "components/user_manager/user_manager.h" |
55 #endif | 56 #endif |
56 | 57 |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
976 content::HostZoomMap::ZoomLevelVector zoom_levels( | 977 content::HostZoomMap::ZoomLevelVector zoom_levels( |
977 host_zoom_map->GetAllZoomLevels()); | 978 host_zoom_map->GetAllZoomLevels()); |
978 std::sort(zoom_levels.begin(), zoom_levels.end(), HostZoomSort); | 979 std::sort(zoom_levels.begin(), zoom_levels.end(), HostZoomSort); |
979 | 980 |
980 for (content::HostZoomMap::ZoomLevelVector::const_iterator i = | 981 for (content::HostZoomMap::ZoomLevelVector::const_iterator i = |
981 zoom_levels.begin(); | 982 zoom_levels.begin(); |
982 i != zoom_levels.end(); | 983 i != zoom_levels.end(); |
983 ++i) { | 984 ++i) { |
984 scoped_ptr<base::DictionaryValue> exception(new base::DictionaryValue); | 985 scoped_ptr<base::DictionaryValue> exception(new base::DictionaryValue); |
985 switch (i->mode) { | 986 switch (i->mode) { |
986 case content::HostZoomMap::ZOOM_CHANGED_FOR_HOST: | 987 case content::HostZoomMap::ZOOM_CHANGED_FOR_HOST: { |
987 exception->SetString(kOrigin, i->host); | 988 exception->SetString(kOrigin, i->host); |
988 break; | 989 std::string host = i->host; |
990 if (host == content::kUnreachableWebDataURL) { | |
991 host = | |
992 l10n_util::GetStringUTF8(IDS_ZOOMLEVELS_CHROME_ERROR_PAGES_LABEL); | |
993 } | |
994 exception->SetString(kOrigin, host); | |
995 } | |
989 case content::HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | 996 case content::HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: |
990 // These are not stored in preferences and get cleared on next browser | 997 // These are not stored in preferences and get cleared on next browser |
991 // start. Therefore, we don't care for them. | 998 // start. Therefore, we don't care for them. |
992 break; | 999 break; |
993 case content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | 1000 case content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: |
994 NOTREACHED(); | 1001 NOTREACHED(); |
995 } | 1002 } |
996 exception->SetString(kSetting, | 1003 exception->SetString(kSetting, |
997 ContentSettingToString(CONTENT_SETTING_DEFAULT)); | 1004 ContentSettingToString(CONTENT_SETTING_DEFAULT)); |
998 | 1005 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1199 void ContentSettingsHandler::RemoveZoomLevelException( | 1206 void ContentSettingsHandler::RemoveZoomLevelException( |
1200 const base::ListValue* args) { | 1207 const base::ListValue* args) { |
1201 std::string mode; | 1208 std::string mode; |
1202 bool rv = args->GetString(1, &mode); | 1209 bool rv = args->GetString(1, &mode); |
1203 DCHECK(rv); | 1210 DCHECK(rv); |
1204 | 1211 |
1205 std::string pattern; | 1212 std::string pattern; |
1206 rv = args->GetString(2, &pattern); | 1213 rv = args->GetString(2, &pattern); |
1207 DCHECK(rv); | 1214 DCHECK(rv); |
1208 | 1215 |
1216 if (pattern == | |
1217 l10n_util::GetStringUTF8(IDS_ZOOMLEVELS_CHROME_ERROR_PAGES_LABEL)) { | |
Bernhard Bauer
2014/10/28 14:55:22
This feels kind of hacky, but it's probably not wo
wjmaclean
2014/10/28 17:37:04
Acknowledged.
| |
1218 pattern = content::kUnreachableWebDataURL; | |
1219 } | |
1220 | |
1209 content::HostZoomMap* host_zoom_map = | 1221 content::HostZoomMap* host_zoom_map = |
1210 content::HostZoomMap::GetDefaultForBrowserContext( | 1222 content::HostZoomMap::GetDefaultForBrowserContext( |
1211 GetBrowserContext(web_ui())); | 1223 GetBrowserContext(web_ui())); |
1212 double default_level = host_zoom_map->GetDefaultZoomLevel(); | 1224 double default_level = host_zoom_map->GetDefaultZoomLevel(); |
1213 host_zoom_map->SetZoomLevelForHost(pattern, default_level); | 1225 host_zoom_map->SetZoomLevelForHost(pattern, default_level); |
1214 } | 1226 } |
1215 | 1227 |
1216 void ContentSettingsHandler::RegisterMessages() { | 1228 void ContentSettingsHandler::RegisterMessages() { |
1217 web_ui()->RegisterMessageCallback("setContentFilter", | 1229 web_ui()->RegisterMessageCallback("setContentFilter", |
1218 base::Bind(&ContentSettingsHandler::SetContentFilter, | 1230 base::Bind(&ContentSettingsHandler::SetContentFilter, |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1500 | 1512 |
1501 // Exceptions apply only when the feature is enabled. | 1513 // Exceptions apply only when the feature is enabled. |
1502 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1514 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
1503 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1515 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1504 web_ui()->CallJavascriptFunction( | 1516 web_ui()->CallJavascriptFunction( |
1505 "ContentSettings.enableProtectedContentExceptions", | 1517 "ContentSettings.enableProtectedContentExceptions", |
1506 base::FundamentalValue(enable_exceptions)); | 1518 base::FundamentalValue(enable_exceptions)); |
1507 } | 1519 } |
1508 | 1520 |
1509 } // namespace options | 1521 } // namespace options |
OLD | NEW |