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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 #include "chrome/browser/permissions/chooser_context_base.h" | 32 #include "chrome/browser/permissions/chooser_context_base.h" |
| 33 #include "chrome/browser/permissions/permission_uma_util.h" | 33 #include "chrome/browser/permissions/permission_uma_util.h" |
| 34 #include "chrome/browser/permissions/permission_util.h" | 34 #include "chrome/browser/permissions/permission_util.h" |
| 35 #include "chrome/browser/plugins/plugins_field_trial.h" | 35 #include "chrome/browser/plugins/plugins_field_trial.h" |
| 36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/browser/ui/browser_list.h" | 37 #include "chrome/browser/ui/browser_list.h" |
| 38 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 38 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
| 39 #include "chrome/browser/ui/webui/site_settings_helper.h" | 39 #include "chrome/browser/ui/webui/site_settings_helper.h" |
| 40 #include "chrome/browser/usb/usb_chooser_context.h" | 40 #include "chrome/browser/usb/usb_chooser_context.h" |
| 41 #include "chrome/browser/usb/usb_chooser_context_factory.h" | 41 #include "chrome/browser/usb/usb_chooser_context_factory.h" |
| 42 #include "chrome/common/chrome_features.h" | |
| 42 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
| 43 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 44 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 44 #include "chrome/common/features.h" | 45 #include "chrome/common/features.h" |
| 45 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 46 #include "chrome/common/url_constants.h" | 47 #include "chrome/common/url_constants.h" |
| 47 #include "chrome/grit/generated_resources.h" | 48 #include "chrome/grit/generated_resources.h" |
| 48 #include "chrome/grit/locale_settings.h" | 49 #include "chrome/grit/locale_settings.h" |
| 49 #include "components/content_settings/core/browser/content_settings_details.h" | 50 #include "components/content_settings/core/browser/content_settings_details.h" |
| 50 #include "components/content_settings/core/browser/content_settings_utils.h" | 51 #include "components/content_settings/core/browser/content_settings_utils.h" |
| 51 #include "components/content_settings/core/browser/host_content_settings_map.h" | 52 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 } | 366 } |
| 366 | 367 |
| 367 void ContentSettingsHandler::GetLocalizedValues( | 368 void ContentSettingsHandler::GetLocalizedValues( |
| 368 base::DictionaryValue* localized_strings) { | 369 base::DictionaryValue* localized_strings) { |
| 369 DCHECK(localized_strings); | 370 DCHECK(localized_strings); |
| 370 | 371 |
| 371 static OptionsStringResource resources[] = { | 372 static OptionsStringResource resources[] = { |
| 372 {"allowException", IDS_EXCEPTIONS_ALLOW_BUTTON}, | 373 {"allowException", IDS_EXCEPTIONS_ALLOW_BUTTON}, |
| 373 {"blockException", IDS_EXCEPTIONS_BLOCK_BUTTON}, | 374 {"blockException", IDS_EXCEPTIONS_BLOCK_BUTTON}, |
| 374 {"sessionException", IDS_EXCEPTIONS_SESSION_ONLY_BUTTON}, | 375 {"sessionException", IDS_EXCEPTIONS_SESSION_ONLY_BUTTON}, |
| 375 {"detectException", IDS_EXCEPTIONS_DETECT_IMPORTANT_CONTENT_BUTTON}, | |
| 376 {"askException", IDS_EXCEPTIONS_ASK_BUTTON}, | 376 {"askException", IDS_EXCEPTIONS_ASK_BUTTON}, |
| 377 {"otrExceptionsExplanation", IDS_EXCEPTIONS_OTR_LABEL}, | 377 {"otrExceptionsExplanation", IDS_EXCEPTIONS_OTR_LABEL}, |
| 378 {"addNewExceptionInstructions", IDS_EXCEPTIONS_ADD_NEW_INSTRUCTIONS}, | 378 {"addNewExceptionInstructions", IDS_EXCEPTIONS_ADD_NEW_INSTRUCTIONS}, |
| 379 {"manageExceptions", IDS_EXCEPTIONS_MANAGE}, | 379 {"manageExceptions", IDS_EXCEPTIONS_MANAGE}, |
| 380 {"manageHandlers", IDS_HANDLERS_MANAGE}, | 380 {"manageHandlers", IDS_HANDLERS_MANAGE}, |
| 381 {"exceptionPatternHeader", IDS_EXCEPTIONS_PATTERN_HEADER}, | 381 {"exceptionPatternHeader", IDS_EXCEPTIONS_PATTERN_HEADER}, |
| 382 {"exceptionBehaviorHeader", IDS_EXCEPTIONS_ACTION_HEADER}, | 382 {"exceptionBehaviorHeader", IDS_EXCEPTIONS_ACTION_HEADER}, |
| 383 {"exceptionUsbDeviceHeader", IDS_EXCEPTIONS_USB_DEVICE_HEADER}, | 383 {"exceptionUsbDeviceHeader", IDS_EXCEPTIONS_USB_DEVICE_HEADER}, |
| 384 {"exceptionZoomHeader", IDS_EXCEPTIONS_ZOOM_HEADER}, | 384 {"exceptionZoomHeader", IDS_EXCEPTIONS_ZOOM_HEADER}, |
| 385 {"embeddedOnHost", IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST}, | 385 {"embeddedOnHost", IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST}, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 405 // JavaScript filter. | 405 // JavaScript filter. |
| 406 {"javascriptTabLabel", IDS_JAVASCRIPT_TAB_LABEL}, | 406 {"javascriptTabLabel", IDS_JAVASCRIPT_TAB_LABEL}, |
| 407 {"javascriptHeader", IDS_JAVASCRIPT_HEADER}, | 407 {"javascriptHeader", IDS_JAVASCRIPT_HEADER}, |
| 408 {"javascriptAllow", IDS_JS_ALLOW_RADIO}, | 408 {"javascriptAllow", IDS_JS_ALLOW_RADIO}, |
| 409 {"javascriptBlock", IDS_JS_DONOTALLOW_RADIO}, | 409 {"javascriptBlock", IDS_JS_DONOTALLOW_RADIO}, |
| 410 // Plugins filter. | 410 // Plugins filter. |
| 411 {"pluginsTabLabel", IDS_PLUGIN_TAB_LABEL}, | 411 {"pluginsTabLabel", IDS_PLUGIN_TAB_LABEL}, |
| 412 {"pluginsHeader", IDS_PLUGIN_HEADER}, | 412 {"pluginsHeader", IDS_PLUGIN_HEADER}, |
| 413 {"pluginsAllow", IDS_PLUGIN_ALLOW_RADIO}, | 413 {"pluginsAllow", IDS_PLUGIN_ALLOW_RADIO}, |
| 414 {"pluginsBlock", IDS_PLUGIN_BLOCK_RADIO}, | 414 {"pluginsBlock", IDS_PLUGIN_BLOCK_RADIO}, |
| 415 {"pluginsDetectImportantContent", IDS_PLUGIN_DETECT_RECOMMENDED_RADIO}, | |
| 416 {"manageIndividualPlugins", IDS_PLUGIN_MANAGE_INDIVIDUAL}, | 415 {"manageIndividualPlugins", IDS_PLUGIN_MANAGE_INDIVIDUAL}, |
| 417 // Pop-ups filter. | 416 // Pop-ups filter. |
| 418 {"popupsTabLabel", IDS_POPUP_TAB_LABEL}, | 417 {"popupsTabLabel", IDS_POPUP_TAB_LABEL}, |
| 419 {"popupsHeader", IDS_POPUP_HEADER}, | 418 {"popupsHeader", IDS_POPUP_HEADER}, |
| 420 {"popupsAllow", IDS_POPUP_ALLOW_RADIO}, | 419 {"popupsAllow", IDS_POPUP_ALLOW_RADIO}, |
| 421 {"popupsBlock", IDS_POPUP_BLOCK_RADIO}, | 420 {"popupsBlock", IDS_POPUP_BLOCK_RADIO}, |
| 422 // Location filter. | 421 // Location filter. |
| 423 {"locationTabLabel", IDS_GEOLOCATION_TAB_LABEL}, | 422 {"locationTabLabel", IDS_GEOLOCATION_TAB_LABEL}, |
| 424 {"locationHeader", IDS_GEOLOCATION_HEADER}, | 423 {"locationHeader", IDS_GEOLOCATION_HEADER}, |
| 425 {"locationAllow", IDS_GEOLOCATION_ALLOW_RADIO}, | 424 {"locationAllow", IDS_GEOLOCATION_ALLOW_RADIO}, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 {"zoomLevelsManage", IDS_ZOOMLEVELS_MANAGE_BUTTON}, | 502 {"zoomLevelsManage", IDS_ZOOMLEVELS_MANAGE_BUTTON}, |
| 504 // Keygen filter. | 503 // Keygen filter. |
| 505 {"keygenTabLabel", IDS_KEYGEN_TAB_LABEL}, | 504 {"keygenTabLabel", IDS_KEYGEN_TAB_LABEL}, |
| 506 {"keygenHeader", IDS_KEYGEN_HEADER}, | 505 {"keygenHeader", IDS_KEYGEN_HEADER}, |
| 507 {"keygenAllow", IDS_KEYGEN_ALLOW_RADIO}, | 506 {"keygenAllow", IDS_KEYGEN_ALLOW_RADIO}, |
| 508 {"keygenBlock", IDS_KEYGEN_DONOTALLOW_RADIO}, | 507 {"keygenBlock", IDS_KEYGEN_DONOTALLOW_RADIO}, |
| 509 }; | 508 }; |
| 510 | 509 |
| 511 RegisterStrings(localized_strings, resources, arraysize(resources)); | 510 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 512 | 511 |
| 512 // TODO(tommycli): When the HTML5 By Default feature flag is on, we want to | |
| 513 // display strings that begin with "Ask...", even though the setting remains | |
| 514 // DETECT. Once this feature is finalized, then we migrate the setting to ASK. | |
|
Dan Beam
2016/09/01 06:15:15
wat
tommycli
2016/09/01 17:59:33
Acknowledged.
| |
| 515 if (base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) { | |
| 516 static OptionsStringResource flash_strings[] = { | |
| 517 {"pluginsDetectImportantContent", IDS_PLUGIN_ASK_RECOMMENDED_RADIO}, | |
| 518 {"detectException", IDS_EXCEPTIONS_ASK_BUTTON}, | |
| 519 }; | |
| 520 RegisterStrings(localized_strings, flash_strings, arraysize(flash_strings)); | |
| 521 } else { | |
| 522 static OptionsStringResource flash_strings[] = { | |
| 523 {"pluginsDetectImportantContent", IDS_PLUGIN_DETECT_RECOMMENDED_RADIO}, | |
| 524 {"detectException", IDS_EXCEPTIONS_DETECT_IMPORTANT_CONTENT_BUTTON}, | |
| 525 }; | |
| 526 RegisterStrings(localized_strings, flash_strings, arraysize(flash_strings)); | |
| 527 } | |
|
Dan Beam
2016/09/01 06:15:15
please tell me there's any other way to do this...
tommycli
2016/09/01 17:59:33
This is unfortunate. The story is:
ASK was origin
tommycli
2016/09/01 18:04:25
I could just also change IDS_PLUGIN_ASK_RECOMMEND_
raymes
2016/09/14 01:48:05
I agree it's confusing but I can't really think of
tommycli
2016/09/14 20:55:16
Okay sounds good, I'll add bauerb. I don't want to
| |
| 528 | |
| 513 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 529 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 514 const base::Value* default_pref = prefs->GetDefaultPrefValue( | 530 const base::Value* default_pref = prefs->GetDefaultPrefValue( |
| 515 content_settings::WebsiteSettingsRegistry::GetInstance() | 531 content_settings::WebsiteSettingsRegistry::GetInstance() |
| 516 ->Get(CONTENT_SETTINGS_TYPE_PLUGINS) | 532 ->Get(CONTENT_SETTINGS_TYPE_PLUGINS) |
| 517 ->default_value_pref_name()); | 533 ->default_value_pref_name()); |
| 518 | 534 |
| 519 int default_value = CONTENT_SETTING_DEFAULT; | 535 int default_value = CONTENT_SETTING_DEFAULT; |
| 520 bool success = default_pref->GetAsInteger(&default_value); | 536 bool success = default_pref->GetAsInteger(&default_value); |
| 521 DCHECK(success); | 537 DCHECK(success); |
| 522 DCHECK_NE(CONTENT_SETTING_DEFAULT, default_value); | 538 DCHECK_NE(CONTENT_SETTING_DEFAULT, default_value); |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1504 | 1520 |
| 1505 // Exceptions apply only when the feature is enabled. | 1521 // Exceptions apply only when the feature is enabled. |
| 1506 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1522 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1507 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1523 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1508 web_ui()->CallJavascriptFunctionUnsafe( | 1524 web_ui()->CallJavascriptFunctionUnsafe( |
| 1509 "ContentSettings.enableProtectedContentExceptions", | 1525 "ContentSettings.enableProtectedContentExceptions", |
| 1510 base::FundamentalValue(enable_exceptions)); | 1526 base::FundamentalValue(enable_exceptions)); |
| 1511 } | 1527 } |
| 1512 | 1528 |
| 1513 } // namespace options | 1529 } // namespace options |
| OLD | NEW |