| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 const char kEmbeddingOrigin[] = "embeddingOrigin"; | 132 const char kEmbeddingOrigin[] = "embeddingOrigin"; |
| 133 const char kPreferencesSource[] = "preference"; | 133 const char kPreferencesSource[] = "preference"; |
| 134 const char kZoom[] = "zoom"; | 134 const char kZoom[] = "zoom"; |
| 135 const char kObject[] = "object"; | 135 const char kObject[] = "object"; |
| 136 const char kObjectName[] = "objectName"; | 136 const char kObjectName[] = "objectName"; |
| 137 | 137 |
| 138 const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { | 138 const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { |
| 139 {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"}, | 139 {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"}, |
| 140 {CONTENT_SETTINGS_TYPE_IMAGES, "images"}, | 140 {CONTENT_SETTINGS_TYPE_IMAGES, "images"}, |
| 141 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"}, | 141 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"}, |
| 142 {CONTENT_SETTINGS_TYPE_KEYGEN, "keygen"}, |
| 142 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"}, | 143 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"}, |
| 143 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, | 144 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, |
| 144 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, | 145 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, |
| 145 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, | 146 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, |
| 146 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"}, | 147 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"}, |
| 147 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, | 148 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, |
| 148 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, | 149 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, |
| 149 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "register-protocol-handler"}, | 150 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "register-protocol-handler"}, |
| 150 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic"}, | 151 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic"}, |
| 151 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "media-stream-camera"}, | 152 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "media-stream-camera"}, |
| 152 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "ppapi-broker"}, | 153 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "ppapi-broker"}, |
| 153 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "multiple-automatic-downloads"}, | 154 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "multiple-automatic-downloads"}, |
| 154 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"}, | 155 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"}, |
| 155 {CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, "push-messaging"}, | 156 {CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, "push-messaging"}, |
| 156 {CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions"}, | 157 {CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions"}, |
| 157 #if defined(OS_CHROMEOS) | 158 #if defined(OS_CHROMEOS) |
| 158 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"}, | 159 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"}, |
| 159 #endif | 160 #endif |
| 161 {CONTENT_SETTINGS_TYPE_KEYGEN, "keygen"}, |
| 160 }; | 162 }; |
| 161 | 163 |
| 162 ChooserContextBase* GetUsbChooserContext(Profile* profile) { | 164 ChooserContextBase* GetUsbChooserContext(Profile* profile) { |
| 163 return UsbChooserContextFactory::GetForProfile(profile); | 165 return UsbChooserContextFactory::GetForProfile(profile); |
| 164 } | 166 } |
| 165 | 167 |
| 166 const ContentSettingsHandler::ChooserTypeNameEntry kChooserTypeGroupNames[] = { | 168 const ContentSettingsHandler::ChooserTypeNameEntry kChooserTypeGroupNames[] = { |
| 167 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext, | 169 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext, |
| 168 "usb-devices", "name"}, | 170 "usb-devices", "name"}, |
| 169 }; | 171 }; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 true, | 225 true, |
| 224 UserMetricsAction("Options_DefaultPushMessagingSettingChanged")))); | 226 UserMetricsAction("Options_DefaultPushMessagingSettingChanged")))); |
| 225 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 227 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 226 exceptions_info_map.insert(std::make_pair( | 228 exceptions_info_map.insert(std::make_pair( |
| 227 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, | 229 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, |
| 228 ContentSettingWithExceptions( | 230 ContentSettingWithExceptions( |
| 229 true, | 231 true, |
| 230 UserMetricsAction( | 232 UserMetricsAction( |
| 231 "Options_DefaultProtectedMediaIdentifierSettingChanged")))); | 233 "Options_DefaultProtectedMediaIdentifierSettingChanged")))); |
| 232 #endif | 234 #endif |
| 235 exceptions_info_map.insert(std::make_pair( |
| 236 CONTENT_SETTINGS_TYPE_KEYGEN, |
| 237 ContentSettingWithExceptions( |
| 238 true, UserMetricsAction("Options_DefaultKeygenSettingChanged")))); |
| 233 | 239 |
| 234 // Without OTR exceptions. | 240 // Without OTR exceptions. |
| 235 exceptions_info_map.insert(std::make_pair( | 241 exceptions_info_map.insert(std::make_pair( |
| 236 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 242 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 237 ContentSettingWithExceptions( | 243 ContentSettingWithExceptions( |
| 238 false, | 244 false, |
| 239 UserMetricsAction("Options_DefaultNotificationsSettingChanged")))); | 245 UserMetricsAction("Options_DefaultNotificationsSettingChanged")))); |
| 240 exceptions_info_map.insert(std::make_pair( | 246 exceptions_info_map.insert(std::make_pair( |
| 241 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 247 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 242 ContentSettingWithExceptions( | 248 ContentSettingWithExceptions( |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 // Image filter. | 531 // Image filter. |
| 526 {"imagesTabLabel", IDS_IMAGES_TAB_LABEL}, | 532 {"imagesTabLabel", IDS_IMAGES_TAB_LABEL}, |
| 527 {"imagesHeader", IDS_IMAGES_HEADER}, | 533 {"imagesHeader", IDS_IMAGES_HEADER}, |
| 528 {"imagesAllow", IDS_IMAGES_LOAD_RADIO}, | 534 {"imagesAllow", IDS_IMAGES_LOAD_RADIO}, |
| 529 {"imagesBlock", IDS_IMAGES_NOLOAD_RADIO}, | 535 {"imagesBlock", IDS_IMAGES_NOLOAD_RADIO}, |
| 530 // JavaScript filter. | 536 // JavaScript filter. |
| 531 {"javascriptTabLabel", IDS_JAVASCRIPT_TAB_LABEL}, | 537 {"javascriptTabLabel", IDS_JAVASCRIPT_TAB_LABEL}, |
| 532 {"javascriptHeader", IDS_JAVASCRIPT_HEADER}, | 538 {"javascriptHeader", IDS_JAVASCRIPT_HEADER}, |
| 533 {"javascriptAllow", IDS_JS_ALLOW_RADIO}, | 539 {"javascriptAllow", IDS_JS_ALLOW_RADIO}, |
| 534 {"javascriptBlock", IDS_JS_DONOTALLOW_RADIO}, | 540 {"javascriptBlock", IDS_JS_DONOTALLOW_RADIO}, |
| 541 // Keygen filter. |
| 542 {"keygenTabLabel", IDS_KEYGEN_TAB_LABEL}, |
| 543 {"keygenHeader", IDS_KEYGEN_HEADER}, |
| 544 {"keygenAllow", IDS_KEYGEN_ALLOW_RADIO}, |
| 545 {"keygenBlock", IDS_KEYGEN_DONOTALLOW_RADIO}, |
| 535 // Plugins filter. | 546 // Plugins filter. |
| 536 {"pluginsTabLabel", IDS_PLUGIN_TAB_LABEL}, | 547 {"pluginsTabLabel", IDS_PLUGIN_TAB_LABEL}, |
| 537 {"pluginsHeader", IDS_PLUGIN_HEADER}, | 548 {"pluginsHeader", IDS_PLUGIN_HEADER}, |
| 538 {"pluginsAllow", IDS_PLUGIN_ALLOW_RADIO}, | 549 {"pluginsAllow", IDS_PLUGIN_ALLOW_RADIO}, |
| 539 {"pluginsBlock", IDS_PLUGIN_BLOCK_RADIO}, | 550 {"pluginsBlock", IDS_PLUGIN_BLOCK_RADIO}, |
| 540 {"pluginsDetectImportantContent", IDS_PLUGIN_DETECT_RECOMMENDED_RADIO}, | 551 {"pluginsDetectImportantContent", IDS_PLUGIN_DETECT_RECOMMENDED_RADIO}, |
| 541 {"manageIndividualPlugins", IDS_PLUGIN_MANAGE_INDIVIDUAL}, | 552 {"manageIndividualPlugins", IDS_PLUGIN_MANAGE_INDIVIDUAL}, |
| 542 // Pop-ups filter. | 553 // Pop-ups filter. |
| 543 {"popupsTabLabel", IDS_POPUP_TAB_LABEL}, | 554 {"popupsTabLabel", IDS_POPUP_TAB_LABEL}, |
| 544 {"popupsHeader", IDS_POPUP_HEADER}, | 555 {"popupsHeader", IDS_POPUP_HEADER}, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 {"midiSysExBlock", IDS_MIDI_SYSEX_BLOCK_RADIO}, | 625 {"midiSysExBlock", IDS_MIDI_SYSEX_BLOCK_RADIO}, |
| 615 // Push messaging strings | 626 // Push messaging strings |
| 616 {"pushMessagingHeader", IDS_PUSH_MESSAGES_TAB_LABEL}, | 627 {"pushMessagingHeader", IDS_PUSH_MESSAGES_TAB_LABEL}, |
| 617 {"pushMessagingAllow", IDS_PUSH_MESSSAGING_ALLOW_RADIO}, | 628 {"pushMessagingAllow", IDS_PUSH_MESSSAGING_ALLOW_RADIO}, |
| 618 {"pushMessagingAsk", IDS_PUSH_MESSSAGING_ASK_RADIO}, | 629 {"pushMessagingAsk", IDS_PUSH_MESSSAGING_ASK_RADIO}, |
| 619 {"pushMessagingBlock", IDS_PUSH_MESSSAGING_BLOCK_RADIO}, | 630 {"pushMessagingBlock", IDS_PUSH_MESSSAGING_BLOCK_RADIO}, |
| 620 {"usbDevicesHeader", IDS_USB_DEVICES_HEADER_AND_TAB_LABEL}, | 631 {"usbDevicesHeader", IDS_USB_DEVICES_HEADER_AND_TAB_LABEL}, |
| 621 {"usbDevicesManage", IDS_USB_DEVICES_MANAGE_BUTTON}, | 632 {"usbDevicesManage", IDS_USB_DEVICES_MANAGE_BUTTON}, |
| 622 {"zoomlevelsHeader", IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL}, | 633 {"zoomlevelsHeader", IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL}, |
| 623 {"zoomLevelsManage", IDS_ZOOMLEVELS_MANAGE_BUTTON}, | 634 {"zoomLevelsManage", IDS_ZOOMLEVELS_MANAGE_BUTTON}, |
| 635 // Keygen filter. |
| 636 {"keygenTabLabel", IDS_KEYGEN_TAB_LABEL}, |
| 637 {"keygenHeader", IDS_KEYGEN_HEADER}, |
| 638 {"keygenAllow", IDS_KEYGEN_ALLOW_RADIO}, |
| 639 {"keygenBlock", IDS_KEYGEN_DONOTALLOW_RADIO}, |
| 624 }; | 640 }; |
| 625 | 641 |
| 626 RegisterStrings(localized_strings, resources, arraysize(resources)); | 642 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 627 | 643 |
| 628 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 644 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 629 const base::Value* default_pref = prefs->GetDefaultPrefValue( | 645 const base::Value* default_pref = prefs->GetDefaultPrefValue( |
| 630 content_settings::WebsiteSettingsRegistry::GetInstance() | 646 content_settings::WebsiteSettingsRegistry::GetInstance() |
| 631 ->Get(CONTENT_SETTINGS_TYPE_PLUGINS) | 647 ->Get(CONTENT_SETTINGS_TYPE_PLUGINS) |
| 632 ->default_value_pref_name()); | 648 ->default_value_pref_name()); |
| 633 | 649 |
| 634 int default_value = CONTENT_SETTING_DEFAULT; | 650 int default_value = CONTENT_SETTING_DEFAULT; |
| 635 bool success = default_pref->GetAsInteger(&default_value); | 651 bool success = default_pref->GetAsInteger(&default_value); |
| 636 DCHECK(success); | 652 DCHECK(success); |
| 637 DCHECK_NE(CONTENT_SETTING_DEFAULT, default_value); | 653 DCHECK_NE(CONTENT_SETTING_DEFAULT, default_value); |
| 638 | 654 |
| 639 RegisterTitle(localized_strings, "contentSettingsPage", | 655 RegisterTitle(localized_strings, "contentSettingsPage", |
| 640 IDS_CONTENT_SETTINGS_TITLE); | 656 IDS_CONTENT_SETTINGS_TITLE); |
| 641 | 657 |
| 642 // Register titles for each of the individual settings whose exception | 658 // Register titles for each of the individual settings whose exception |
| 643 // dialogs will be processed by |ContentSettingsHandler|. | 659 // dialogs will be processed by |ContentSettingsHandler|. |
| 644 RegisterTitle(localized_strings, "cookies", | 660 RegisterTitle(localized_strings, "cookies", |
| 645 IDS_COOKIES_TAB_LABEL); | 661 IDS_COOKIES_TAB_LABEL); |
| 646 RegisterTitle(localized_strings, "images", | 662 RegisterTitle(localized_strings, "images", |
| 647 IDS_IMAGES_TAB_LABEL); | 663 IDS_IMAGES_TAB_LABEL); |
| 648 RegisterTitle(localized_strings, "javascript", | 664 RegisterTitle(localized_strings, "javascript", |
| 649 IDS_JAVASCRIPT_TAB_LABEL); | 665 IDS_JAVASCRIPT_TAB_LABEL); |
| 666 RegisterTitle(localized_strings, "keygen", IDS_KEYGEN_TAB_LABEL); |
| 650 RegisterTitle(localized_strings, "plugins", | 667 RegisterTitle(localized_strings, "plugins", |
| 651 IDS_PLUGIN_TAB_LABEL); | 668 IDS_PLUGIN_TAB_LABEL); |
| 652 RegisterTitle(localized_strings, "popups", | 669 RegisterTitle(localized_strings, "popups", |
| 653 IDS_POPUP_TAB_LABEL); | 670 IDS_POPUP_TAB_LABEL); |
| 654 RegisterTitle(localized_strings, "location", | 671 RegisterTitle(localized_strings, "location", |
| 655 IDS_GEOLOCATION_TAB_LABEL); | 672 IDS_GEOLOCATION_TAB_LABEL); |
| 656 RegisterTitle(localized_strings, "notifications", | 673 RegisterTitle(localized_strings, "notifications", |
| 657 IDS_NOTIFICATIONS_TAB_LABEL); | 674 IDS_NOTIFICATIONS_TAB_LABEL); |
| 658 RegisterTitle(localized_strings, "fullscreen", | 675 RegisterTitle(localized_strings, "fullscreen", |
| 659 IDS_FULLSCREEN_TAB_LABEL); | 676 IDS_FULLSCREEN_TAB_LABEL); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 670 RegisterTitle(localized_strings, "ppapi-broker", | 687 RegisterTitle(localized_strings, "ppapi-broker", |
| 671 IDS_PPAPI_BROKER_TAB_LABEL); | 688 IDS_PPAPI_BROKER_TAB_LABEL); |
| 672 RegisterTitle(localized_strings, "multiple-automatic-downloads", | 689 RegisterTitle(localized_strings, "multiple-automatic-downloads", |
| 673 IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL); | 690 IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL); |
| 674 RegisterTitle(localized_strings, "midi-sysex", | 691 RegisterTitle(localized_strings, "midi-sysex", |
| 675 IDS_MIDI_SYSEX_TAB_LABEL); | 692 IDS_MIDI_SYSEX_TAB_LABEL); |
| 676 RegisterTitle(localized_strings, "usb-devices", | 693 RegisterTitle(localized_strings, "usb-devices", |
| 677 IDS_USB_DEVICES_HEADER_AND_TAB_LABEL); | 694 IDS_USB_DEVICES_HEADER_AND_TAB_LABEL); |
| 678 RegisterTitle(localized_strings, "zoomlevels", | 695 RegisterTitle(localized_strings, "zoomlevels", |
| 679 IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL); | 696 IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL); |
| 697 RegisterTitle(localized_strings, "keygen", IDS_KEYGEN_TAB_LABEL); |
| 680 | 698 |
| 681 localized_strings->SetString("exceptionsLearnMoreUrl", | 699 localized_strings->SetString("exceptionsLearnMoreUrl", |
| 682 kExceptionsLearnMoreUrl); | 700 kExceptionsLearnMoreUrl); |
| 683 } | 701 } |
| 684 | 702 |
| 685 void ContentSettingsHandler::InitializeHandler() { | 703 void ContentSettingsHandler::InitializeHandler() { |
| 686 notification_registrar_.Add( | 704 notification_registrar_.Add( |
| 687 this, chrome::NOTIFICATION_PROFILE_CREATED, | 705 this, chrome::NOTIFICATION_PROFILE_CREATED, |
| 688 content::NotificationService::AllSources()); | 706 content::NotificationService::AllSources()); |
| 689 notification_registrar_.Add( | 707 notification_registrar_.Add( |
| (...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 | 1880 |
| 1863 // Exceptions apply only when the feature is enabled. | 1881 // Exceptions apply only when the feature is enabled. |
| 1864 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1882 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1865 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1883 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1866 web_ui()->CallJavascriptFunction( | 1884 web_ui()->CallJavascriptFunction( |
| 1867 "ContentSettings.enableProtectedContentExceptions", | 1885 "ContentSettings.enableProtectedContentExceptions", |
| 1868 base::FundamentalValue(enable_exceptions)); | 1886 base::FundamentalValue(enable_exceptions)); |
| 1869 } | 1887 } |
| 1870 | 1888 |
| 1871 } // namespace options | 1889 } // namespace options |
| OLD | NEW |