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 15 matching lines...) Expand all Loading... | |
| 401 {"imagesTabLabel", IDS_IMAGES_TAB_LABEL}, | 401 {"imagesTabLabel", IDS_IMAGES_TAB_LABEL}, |
| 402 {"imagesHeader", IDS_IMAGES_HEADER}, | 402 {"imagesHeader", IDS_IMAGES_HEADER}, |
| 403 {"imagesAllow", IDS_IMAGES_LOAD_RADIO}, | 403 {"imagesAllow", IDS_IMAGES_LOAD_RADIO}, |
| 404 {"imagesBlock", IDS_IMAGES_NOLOAD_RADIO}, | 404 {"imagesBlock", IDS_IMAGES_NOLOAD_RADIO}, |
| 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_FLASH_TAB_LABEL}, |
| 412 {"pluginsHeader", IDS_PLUGIN_HEADER}, | 412 {"pluginsHeader", IDS_FLASH_HEADER}, |
| 413 {"pluginsAllow", IDS_PLUGIN_ALLOW_RADIO}, | 413 {"pluginsAllow", IDS_FLASH_ALLOW_RADIO}, |
| 414 {"pluginsBlock", IDS_PLUGIN_BLOCK_RADIO}, | 414 {"pluginsBlock", IDS_FLASH_BLOCK_RADIO}, |
| 415 {"pluginsDetectImportantContent", IDS_PLUGIN_DETECT_RECOMMENDED_RADIO}, | |
| 416 {"manageIndividualPlugins", IDS_PLUGIN_MANAGE_INDIVIDUAL}, | |
| 417 // Pop-ups filter. | 415 // Pop-ups filter. |
| 418 {"popupsTabLabel", IDS_POPUP_TAB_LABEL}, | 416 {"popupsTabLabel", IDS_POPUP_TAB_LABEL}, |
| 419 {"popupsHeader", IDS_POPUP_HEADER}, | 417 {"popupsHeader", IDS_POPUP_HEADER}, |
| 420 {"popupsAllow", IDS_POPUP_ALLOW_RADIO}, | 418 {"popupsAllow", IDS_POPUP_ALLOW_RADIO}, |
| 421 {"popupsBlock", IDS_POPUP_BLOCK_RADIO}, | 419 {"popupsBlock", IDS_POPUP_BLOCK_RADIO}, |
| 422 // Location filter. | 420 // Location filter. |
| 423 {"locationTabLabel", IDS_GEOLOCATION_TAB_LABEL}, | 421 {"locationTabLabel", IDS_GEOLOCATION_TAB_LABEL}, |
| 424 {"locationHeader", IDS_GEOLOCATION_HEADER}, | 422 {"locationHeader", IDS_GEOLOCATION_HEADER}, |
| 425 {"locationAllow", IDS_GEOLOCATION_ALLOW_RADIO}, | 423 {"locationAllow", IDS_GEOLOCATION_ALLOW_RADIO}, |
| 426 {"locationAsk", IDS_GEOLOCATION_ASK_RADIO}, | 424 {"locationAsk", IDS_GEOLOCATION_ASK_RADIO}, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 {"zoomLevelsManage", IDS_ZOOMLEVELS_MANAGE_BUTTON}, | 501 {"zoomLevelsManage", IDS_ZOOMLEVELS_MANAGE_BUTTON}, |
| 504 // Keygen filter. | 502 // Keygen filter. |
| 505 {"keygenTabLabel", IDS_KEYGEN_TAB_LABEL}, | 503 {"keygenTabLabel", IDS_KEYGEN_TAB_LABEL}, |
| 506 {"keygenHeader", IDS_KEYGEN_HEADER}, | 504 {"keygenHeader", IDS_KEYGEN_HEADER}, |
| 507 {"keygenAllow", IDS_KEYGEN_ALLOW_RADIO}, | 505 {"keygenAllow", IDS_KEYGEN_ALLOW_RADIO}, |
| 508 {"keygenBlock", IDS_KEYGEN_DONOTALLOW_RADIO}, | 506 {"keygenBlock", IDS_KEYGEN_DONOTALLOW_RADIO}, |
| 509 }; | 507 }; |
| 510 | 508 |
| 511 RegisterStrings(localized_strings, resources, arraysize(resources)); | 509 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 512 | 510 |
| 511 // TODO(tommycli): When the HTML5 By Default feature flag is on, we want to | |
| 512 // display strings that begin with "Ask...", even though the setting remains | |
| 513 // DETECT. Once this feature is finalized, then we migrate the setting to ASK. | |
| 514 if (base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) { | |
| 515 static OptionsStringResource flash_strings[] = { | |
| 516 {"pluginsDetectImportantContent", IDS_FLASH_ASK_RECOMMENDED_RADIO}, | |
|
Dan Beam
2016/09/20 22:53:20
make this ternary if possible or otherwise de-dupe
tommycli
2016/09/20 23:39:04
Done.
| |
| 517 {"detectException", IDS_EXCEPTIONS_ASK_BUTTON}, | |
| 518 }; | |
| 519 RegisterStrings(localized_strings, flash_strings, arraysize(flash_strings)); | |
| 520 } else { | |
| 521 static OptionsStringResource flash_strings[] = { | |
| 522 {"pluginsDetectImportantContent", IDS_FLASH_DETECT_RECOMMENDED_RADIO}, | |
| 523 {"detectException", IDS_EXCEPTIONS_DETECT_IMPORTANT_CONTENT_BUTTON}, | |
| 524 }; | |
| 525 RegisterStrings(localized_strings, flash_strings, arraysize(flash_strings)); | |
| 526 } | |
| 527 | |
| 513 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 528 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 514 const base::Value* default_pref = prefs->GetDefaultPrefValue( | 529 const base::Value* default_pref = prefs->GetDefaultPrefValue( |
| 515 content_settings::WebsiteSettingsRegistry::GetInstance() | 530 content_settings::WebsiteSettingsRegistry::GetInstance() |
| 516 ->Get(CONTENT_SETTINGS_TYPE_PLUGINS) | 531 ->Get(CONTENT_SETTINGS_TYPE_PLUGINS) |
| 517 ->default_value_pref_name()); | 532 ->default_value_pref_name()); |
| 518 | 533 |
| 519 int default_value = CONTENT_SETTING_DEFAULT; | 534 int default_value = CONTENT_SETTING_DEFAULT; |
| 520 bool success = default_pref->GetAsInteger(&default_value); | 535 bool success = default_pref->GetAsInteger(&default_value); |
| 521 DCHECK(success); | 536 DCHECK(success); |
| 522 DCHECK_NE(CONTENT_SETTING_DEFAULT, default_value); | 537 DCHECK_NE(CONTENT_SETTING_DEFAULT, default_value); |
| 523 | 538 |
| 524 RegisterTitle(localized_strings, "contentSettingsPage", | 539 RegisterTitle(localized_strings, "contentSettingsPage", |
| 525 IDS_CONTENT_SETTINGS_TITLE); | 540 IDS_CONTENT_SETTINGS_TITLE); |
| 526 | 541 |
| 527 // Register titles for each of the individual settings whose exception | 542 // Register titles for each of the individual settings whose exception |
| 528 // dialogs will be processed by |ContentSettingsHandler|. | 543 // dialogs will be processed by |ContentSettingsHandler|. |
| 529 RegisterTitle(localized_strings, "cookies", | 544 RegisterTitle(localized_strings, "cookies", |
| 530 IDS_COOKIES_TAB_LABEL); | 545 IDS_COOKIES_TAB_LABEL); |
| 531 RegisterTitle(localized_strings, "images", | 546 RegisterTitle(localized_strings, "images", |
| 532 IDS_IMAGES_TAB_LABEL); | 547 IDS_IMAGES_TAB_LABEL); |
| 533 RegisterTitle(localized_strings, "javascript", | 548 RegisterTitle(localized_strings, "javascript", |
| 534 IDS_JAVASCRIPT_TAB_LABEL); | 549 IDS_JAVASCRIPT_TAB_LABEL); |
| 535 RegisterTitle(localized_strings, "plugins", | 550 RegisterTitle(localized_strings, "plugins", |
| 536 IDS_PLUGIN_TAB_LABEL); | 551 IDS_FLASH_TAB_LABEL); |
| 537 RegisterTitle(localized_strings, "popups", | 552 RegisterTitle(localized_strings, "popups", |
| 538 IDS_POPUP_TAB_LABEL); | 553 IDS_POPUP_TAB_LABEL); |
| 539 RegisterTitle(localized_strings, "location", | 554 RegisterTitle(localized_strings, "location", |
| 540 IDS_GEOLOCATION_TAB_LABEL); | 555 IDS_GEOLOCATION_TAB_LABEL); |
| 541 RegisterTitle(localized_strings, "notifications", | 556 RegisterTitle(localized_strings, "notifications", |
| 542 IDS_NOTIFICATIONS_TAB_LABEL); | 557 IDS_NOTIFICATIONS_TAB_LABEL); |
| 543 RegisterTitle(localized_strings, "fullscreen", | 558 RegisterTitle(localized_strings, "fullscreen", |
| 544 IDS_FULLSCREEN_TAB_LABEL); | 559 IDS_FULLSCREEN_TAB_LABEL); |
| 545 RegisterTitle(localized_strings, "mouselock", | 560 RegisterTitle(localized_strings, "mouselock", |
| 546 IDS_MOUSE_LOCK_TAB_LABEL); | 561 IDS_MOUSE_LOCK_TAB_LABEL); |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1504 | 1519 |
| 1505 // Exceptions apply only when the feature is enabled. | 1520 // Exceptions apply only when the feature is enabled. |
| 1506 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1521 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1507 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1522 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1508 web_ui()->CallJavascriptFunctionUnsafe( | 1523 web_ui()->CallJavascriptFunctionUnsafe( |
| 1509 "ContentSettings.enableProtectedContentExceptions", | 1524 "ContentSettings.enableProtectedContentExceptions", |
| 1510 base::FundamentalValue(enable_exceptions)); | 1525 base::FundamentalValue(enable_exceptions)); |
| 1511 } | 1526 } |
| 1512 | 1527 |
| 1513 } // namespace options | 1528 } // namespace options |
| OLD | NEW |