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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/i18n/number_formatting.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
19 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
20 #include "base/strings/string_number_conversions.h" | |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/values.h" | 22 #include "base/values.h" |
23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
27 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" | 27 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" |
28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
29 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 29 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
30 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 30 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 std::string setting_string = | 1182 std::string setting_string = |
1183 content_settings::ContentSettingToString(CONTENT_SETTING_DEFAULT); | 1183 content_settings::ContentSettingToString(CONTENT_SETTING_DEFAULT); |
1184 DCHECK(!setting_string.empty()); | 1184 DCHECK(!setting_string.empty()); |
1185 | 1185 |
1186 exception->SetString(site_settings::kSetting, setting_string); | 1186 exception->SetString(site_settings::kSetting, setting_string); |
1187 | 1187 |
1188 // Calculate the zoom percent from the factor. Round up to the nearest whole | 1188 // Calculate the zoom percent from the factor. Round up to the nearest whole |
1189 // number. | 1189 // number. |
1190 int zoom_percent = static_cast<int>( | 1190 int zoom_percent = static_cast<int>( |
1191 content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5); | 1191 content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5); |
1192 exception->SetString( | 1192 exception->SetString(kZoom, base::FormatPercent(zoom_percent)); |
1193 kZoom, | |
1194 l10n_util::GetStringFUTF16(IDS_ZOOM_PERCENT, | |
1195 base::IntToString16(zoom_percent))); | |
1196 exception->SetString( | 1193 exception->SetString( |
1197 site_settings::kSource, site_settings::kPreferencesSource); | 1194 site_settings::kSource, site_settings::kPreferencesSource); |
1198 // Append the new entry to the list and map. | 1195 // Append the new entry to the list and map. |
1199 zoom_levels_exceptions.Append(exception.release()); | 1196 zoom_levels_exceptions.Append(exception.release()); |
1200 } | 1197 } |
1201 | 1198 |
1202 base::StringValue type_string(kZoomContentType); | 1199 base::StringValue type_string(kZoomContentType); |
1203 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | 1200 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", |
1204 type_string, zoom_levels_exceptions); | 1201 type_string, zoom_levels_exceptions); |
1205 } | 1202 } |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 | 1703 |
1707 // Exceptions apply only when the feature is enabled. | 1704 // Exceptions apply only when the feature is enabled. |
1708 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1705 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
1709 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1706 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1710 web_ui()->CallJavascriptFunction( | 1707 web_ui()->CallJavascriptFunction( |
1711 "ContentSettings.enableProtectedContentExceptions", | 1708 "ContentSettings.enableProtectedContentExceptions", |
1712 base::FundamentalValue(enable_exceptions)); | 1709 base::FundamentalValue(enable_exceptions)); |
1713 } | 1710 } |
1714 | 1711 |
1715 } // namespace options | 1712 } // namespace options |
OLD | NEW |