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 24 matching lines...) Expand all Loading... |
35 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 35 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
37 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
38 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/notification_source.h" | 39 #include "content/public/browser/notification_source.h" |
40 #include "content/public/browser/notification_types.h" | 40 #include "content/public/browser/notification_types.h" |
41 #include "content/public/browser/user_metrics.h" | 41 #include "content/public/browser/user_metrics.h" |
42 #include "content/public/browser/web_ui.h" | 42 #include "content/public/browser/web_ui.h" |
43 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
44 #include "content/public/common/page_zoom.h" | 44 #include "content/public/common/page_zoom.h" |
45 #include "content/public/common/url_constants.h" | |
46 #include "extensions/common/extension_set.h" | 45 #include "extensions/common/extension_set.h" |
47 #include "extensions/common/permissions/api_permission.h" | 46 #include "extensions/common/permissions/api_permission.h" |
48 #include "grit/generated_resources.h" | 47 #include "grit/generated_resources.h" |
49 #include "grit/locale_settings.h" | 48 #include "grit/locale_settings.h" |
50 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
51 | 50 |
52 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
53 #include "chrome/browser/chromeos/login/user_manager.h" | 52 #include "chrome/browser/chromeos/login/user_manager.h" |
54 #endif | 53 #endif |
55 | 54 |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 for (content::HostZoomMap::ZoomLevelVector::const_iterator i = | 998 for (content::HostZoomMap::ZoomLevelVector::const_iterator i = |
1000 zoom_levels.begin(); | 999 zoom_levels.begin(); |
1001 i != zoom_levels.end(); | 1000 i != zoom_levels.end(); |
1002 ++i) { | 1001 ++i) { |
1003 scoped_ptr<base::DictionaryValue> exception(new base::DictionaryValue); | 1002 scoped_ptr<base::DictionaryValue> exception(new base::DictionaryValue); |
1004 switch (i->mode) { | 1003 switch (i->mode) { |
1005 case content::HostZoomMap::ZOOM_CHANGED_FOR_HOST: | 1004 case content::HostZoomMap::ZOOM_CHANGED_FOR_HOST: |
1006 exception->SetString(kOrigin, i->host); | 1005 exception->SetString(kOrigin, i->host); |
1007 break; | 1006 break; |
1008 case content::HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | 1007 case content::HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: |
1009 exception->SetString( | 1008 // These are not stored in preferences and get cleared on next browser |
1010 kOrigin, i->scheme + content::kStandardSchemeSeparator + i->host); | 1009 // start. Therefore, we don't care for them. |
1011 break; | 1010 break; |
1012 case content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | 1011 case content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: |
1013 NOTREACHED(); | 1012 NOTREACHED(); |
1014 } | 1013 } |
1015 exception->SetString(kSetting, | 1014 exception->SetString(kSetting, |
1016 ContentSettingToString(CONTENT_SETTING_DEFAULT)); | 1015 ContentSettingToString(CONTENT_SETTING_DEFAULT)); |
1017 | 1016 |
1018 // Calculate the zoom percent from the factor. Round up to the nearest whole | 1017 // Calculate the zoom percent from the factor. Round up to the nearest whole |
1019 // number. | 1018 // number. |
1020 int zoom_percent = static_cast<int>( | 1019 int zoom_percent = static_cast<int>( |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 bool rv = args->GetString(1, &mode); | 1234 bool rv = args->GetString(1, &mode); |
1236 DCHECK(rv); | 1235 DCHECK(rv); |
1237 | 1236 |
1238 std::string pattern; | 1237 std::string pattern; |
1239 rv = args->GetString(2, &pattern); | 1238 rv = args->GetString(2, &pattern); |
1240 DCHECK(rv); | 1239 DCHECK(rv); |
1241 | 1240 |
1242 content::HostZoomMap* host_zoom_map = | 1241 content::HostZoomMap* host_zoom_map = |
1243 content::HostZoomMap::GetForBrowserContext(Profile::FromWebUI(web_ui())); | 1242 content::HostZoomMap::GetForBrowserContext(Profile::FromWebUI(web_ui())); |
1244 double default_level = host_zoom_map->GetDefaultZoomLevel(); | 1243 double default_level = host_zoom_map->GetDefaultZoomLevel(); |
1245 | 1244 host_zoom_map->SetZoomLevelForHost(pattern, default_level); |
1246 std::string::size_type scheme_separator_position = | |
1247 pattern.find(content::kStandardSchemeSeparator); | |
1248 if (scheme_separator_position == std::string::npos) { | |
1249 host_zoom_map->SetZoomLevelForHost(pattern, default_level); | |
1250 } else { | |
1251 std::string scheme = pattern.substr(0, scheme_separator_position); | |
1252 std::string host = pattern.substr( | |
1253 scheme_separator_position + strlen(content::kStandardSchemeSeparator)); | |
1254 host_zoom_map->SetZoomLevelForHostAndScheme(scheme, host, default_level); | |
1255 } | |
1256 } | 1245 } |
1257 | 1246 |
1258 void ContentSettingsHandler::RegisterMessages() { | 1247 void ContentSettingsHandler::RegisterMessages() { |
1259 web_ui()->RegisterMessageCallback("setContentFilter", | 1248 web_ui()->RegisterMessageCallback("setContentFilter", |
1260 base::Bind(&ContentSettingsHandler::SetContentFilter, | 1249 base::Bind(&ContentSettingsHandler::SetContentFilter, |
1261 base::Unretained(this))); | 1250 base::Unretained(this))); |
1262 web_ui()->RegisterMessageCallback("removeException", | 1251 web_ui()->RegisterMessageCallback("removeException", |
1263 base::Bind(&ContentSettingsHandler::RemoveException, | 1252 base::Bind(&ContentSettingsHandler::RemoveException, |
1264 base::Unretained(this))); | 1253 base::Unretained(this))); |
1265 web_ui()->RegisterMessageCallback("setException", | 1254 web_ui()->RegisterMessageCallback("setException", |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { | 1561 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { |
1573 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 1562 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
1574 // Exceptions apply only when the feature is enabled. | 1563 // Exceptions apply only when the feature is enabled. |
1575 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1564 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1576 web_ui()->CallJavascriptFunction( | 1565 web_ui()->CallJavascriptFunction( |
1577 "ContentSettings.enableProtectedContentExceptions", | 1566 "ContentSettings.enableProtectedContentExceptions", |
1578 base::FundamentalValue(enable_exceptions)); | 1567 base::FundamentalValue(enable_exceptions)); |
1579 } | 1568 } |
1580 | 1569 |
1581 } // namespace options | 1570 } // namespace options |
OLD | NEW |