Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1412)

Side by Side Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 2458453002: [sensors] Add Permission guard to the generic sensor apis.
Patch Set: rebase + blink reformat Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/content_settings_handler.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 10 #include <map>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 exceptions_info_map.insert(std::make_pair( 178 exceptions_info_map.insert(std::make_pair(
179 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, 179 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
180 ContentSettingWithExceptions( 180 ContentSettingWithExceptions(
181 false, UserMetricsAction( 181 false, UserMetricsAction(
182 "Options_DefaultMultipleAutomaticDLSettingChange")))); 182 "Options_DefaultMultipleAutomaticDLSettingChange"))));
183 exceptions_info_map.insert(std::make_pair( 183 exceptions_info_map.insert(std::make_pair(
184 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, 184 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
185 ContentSettingWithExceptions( 185 ContentSettingWithExceptions(
186 false, 186 false,
187 UserMetricsAction("Options_DefaultMIDISysExSettingChanged")))); 187 UserMetricsAction("Options_DefaultMIDISysExSettingChanged"))));
188 // TODO(riju): Add sensor metrics when UMA is added.
188 exceptions_info_map.insert(std::make_pair( 189 exceptions_info_map.insert(std::make_pair(
189 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, 190 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
190 ContentSettingWithExceptions( 191 ContentSettingWithExceptions(
191 false, 192 false,
192 UserMetricsAction("Options_DefaultBackgroundSyncSettingChanged")))); 193 UserMetricsAction("Options_DefaultBackgroundSyncSettingChanged"))));
193 } 194 }
194 195
195 return exceptions_info_map; 196 return exceptions_info_map;
196 } 197 }
197 198
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 {"multipleAutomaticDownloadsTabLabel", IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL}, 458 {"multipleAutomaticDownloadsTabLabel", IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL},
458 {"multipleAutomaticDownloadsHeader", IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL}, 459 {"multipleAutomaticDownloadsHeader", IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL},
459 {"multipleAutomaticDownloadsAllow", IDS_AUTOMATIC_DOWNLOADS_ALLOW_RADIO}, 460 {"multipleAutomaticDownloadsAllow", IDS_AUTOMATIC_DOWNLOADS_ALLOW_RADIO},
460 {"multipleAutomaticDownloadsAsk", IDS_AUTOMATIC_DOWNLOADS_ASK_RADIO}, 461 {"multipleAutomaticDownloadsAsk", IDS_AUTOMATIC_DOWNLOADS_ASK_RADIO},
461 {"multipleAutomaticDownloadsBlock", IDS_AUTOMATIC_DOWNLOADS_BLOCK_RADIO}, 462 {"multipleAutomaticDownloadsBlock", IDS_AUTOMATIC_DOWNLOADS_BLOCK_RADIO},
462 // MIDI system exclusive messages. 463 // MIDI system exclusive messages.
463 {"midiSysexHeader", IDS_MIDI_SYSEX_TAB_LABEL}, 464 {"midiSysexHeader", IDS_MIDI_SYSEX_TAB_LABEL},
464 {"midiSysExAllow", IDS_MIDI_SYSEX_ALLOW_RADIO}, 465 {"midiSysExAllow", IDS_MIDI_SYSEX_ALLOW_RADIO},
465 {"midiSysExAsk", IDS_MIDI_SYSEX_ASK_RADIO}, 466 {"midiSysExAsk", IDS_MIDI_SYSEX_ASK_RADIO},
466 {"midiSysExBlock", IDS_MIDI_SYSEX_BLOCK_RADIO}, 467 {"midiSysExBlock", IDS_MIDI_SYSEX_BLOCK_RADIO},
468 // Sensors filter.
469 {"sensorsHeader", IDS_SENSORS_TAB_LABEL},
470 {"sensorsAllow", IDS_SENSORS_ALLOW_RADIO},
471 {"sensorsAsk", IDS_SENSORS_ASK_RADIO},
472 {"sensorsBlock", IDS_SENSORS_BLOCK_RADIO},
473
467 // Push messaging strings. 474 // Push messaging strings.
468 {"pushMessagingHeader", IDS_PUSH_MESSAGES_TAB_LABEL}, 475 {"pushMessagingHeader", IDS_PUSH_MESSAGES_TAB_LABEL},
469 {"pushMessagingAllow", IDS_PUSH_MESSSAGING_ALLOW_RADIO}, 476 {"pushMessagingAllow", IDS_PUSH_MESSSAGING_ALLOW_RADIO},
470 {"pushMessagingAsk", IDS_PUSH_MESSSAGING_ASK_RADIO}, 477 {"pushMessagingAsk", IDS_PUSH_MESSSAGING_ASK_RADIO},
471 {"pushMessagingBlock", IDS_PUSH_MESSSAGING_BLOCK_RADIO}, 478 {"pushMessagingBlock", IDS_PUSH_MESSSAGING_BLOCK_RADIO},
472 // USB devices. 479 // USB devices.
473 {"usbDevicesHeader", IDS_USB_DEVICES_HEADER_AND_TAB_LABEL}, 480 {"usbDevicesHeader", IDS_USB_DEVICES_HEADER_AND_TAB_LABEL},
474 {"usbDevicesManage", IDS_USB_DEVICES_MANAGE_BUTTON}, 481 {"usbDevicesManage", IDS_USB_DEVICES_MANAGE_BUTTON},
475 // Background sync. 482 // Background sync.
476 {"backgroundSyncHeader", IDS_BACKGROUND_SYNC_HEADER}, 483 {"backgroundSyncHeader", IDS_BACKGROUND_SYNC_HEADER},
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 RegisterTitle(localized_strings, "media-stream-mic", 545 RegisterTitle(localized_strings, "media-stream-mic",
539 IDS_MEDIA_STREAM_MIC_TAB_LABEL); 546 IDS_MEDIA_STREAM_MIC_TAB_LABEL);
540 RegisterTitle(localized_strings, "media-stream-camera", 547 RegisterTitle(localized_strings, "media-stream-camera",
541 IDS_MEDIA_STREAM_CAMERA_TAB_LABEL); 548 IDS_MEDIA_STREAM_CAMERA_TAB_LABEL);
542 RegisterTitle(localized_strings, "ppapi-broker", 549 RegisterTitle(localized_strings, "ppapi-broker",
543 IDS_PPAPI_BROKER_TAB_LABEL); 550 IDS_PPAPI_BROKER_TAB_LABEL);
544 RegisterTitle(localized_strings, "multiple-automatic-downloads", 551 RegisterTitle(localized_strings, "multiple-automatic-downloads",
545 IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL); 552 IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL);
546 RegisterTitle(localized_strings, "midi-sysex", 553 RegisterTitle(localized_strings, "midi-sysex",
547 IDS_MIDI_SYSEX_TAB_LABEL); 554 IDS_MIDI_SYSEX_TAB_LABEL);
555 RegisterTitle(localized_strings, "sensors", IDS_SENSORS_TAB_LABEL);
548 RegisterTitle(localized_strings, "usb-devices", 556 RegisterTitle(localized_strings, "usb-devices",
549 IDS_USB_DEVICES_HEADER_AND_TAB_LABEL); 557 IDS_USB_DEVICES_HEADER_AND_TAB_LABEL);
550 RegisterTitle(localized_strings, "background-sync", 558 RegisterTitle(localized_strings, "background-sync",
551 IDS_BACKGROUND_SYNC_HEADER); 559 IDS_BACKGROUND_SYNC_HEADER);
552 RegisterTitle(localized_strings, "zoomlevels", 560 RegisterTitle(localized_strings, "zoomlevels",
553 IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL); 561 IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL);
554 562
555 localized_strings->SetString("exceptionsLearnMoreUrl", 563 localized_strings->SetString("exceptionsLearnMoreUrl",
556 chrome::kContentSettingsExceptionsLearnMoreURL); 564 chrome::kContentSettingsExceptionsLearnMoreURL);
557 } 565 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 810 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
803 UpdateGeolocationExceptionsView(); 811 UpdateGeolocationExceptionsView();
804 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { 812 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
805 UpdateNotificationExceptionsView(); 813 UpdateNotificationExceptionsView();
806 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 814 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
807 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { 815 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
808 CompareMediaExceptionsWithFlash(type); 816 CompareMediaExceptionsWithFlash(type);
809 UpdateExceptionsViewFromHostContentSettingsMap(type); 817 UpdateExceptionsViewFromHostContentSettingsMap(type);
810 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { 818 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
811 UpdateMIDISysExExceptionsView(); 819 UpdateMIDISysExExceptionsView();
820 } else if (type == CONTENT_SETTINGS_TYPE_SENSORS) {
821 UpdateSensorsExceptionsView();
812 } else { 822 } else {
813 UpdateExceptionsViewFromHostContentSettingsMap(type); 823 UpdateExceptionsViewFromHostContentSettingsMap(type);
814 } 824 }
815 } 825 }
816 826
817 // TODO(estade): merge with GetExceptionsFromHostContentSettingsMap. 827 // TODO(estade): merge with GetExceptionsFromHostContentSettingsMap.
818 void ContentSettingsHandler::UpdateGeolocationExceptionsView() { 828 void ContentSettingsHandler::UpdateGeolocationExceptionsView() {
819 Profile* profile = Profile::FromWebUI(web_ui()); 829 Profile* profile = Profile::FromWebUI(web_ui());
820 HostContentSettingsMap* map = 830 HostContentSettingsMap* map =
821 HostContentSettingsMapFactory::GetForProfile(profile); 831 HostContentSettingsMapFactory::GetForProfile(profile);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 settings.exceptions_initialized = true; 976 settings.exceptions_initialized = true;
967 UpdateFlashMediaLinksVisibility(type); 977 UpdateFlashMediaLinksVisibility(type);
968 } 978 }
969 979
970 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() { 980 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() {
971 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); 981 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
972 UpdateExceptionsViewFromHostContentSettingsMap( 982 UpdateExceptionsViewFromHostContentSettingsMap(
973 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); 983 CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
974 } 984 }
975 985
986 void ContentSettingsHandler::UpdateSensorsExceptionsView() {
987 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_SENSORS);
988 UpdateExceptionsViewFromHostContentSettingsMap(CONTENT_SETTINGS_TYPE_SENSORS);
989 }
990
976 void ContentSettingsHandler::UpdateAllChooserExceptionsViewsFromModel() { 991 void ContentSettingsHandler::UpdateAllChooserExceptionsViewsFromModel() {
977 for (const site_settings::ChooserTypeNameEntry& chooser_type : 992 for (const site_settings::ChooserTypeNameEntry& chooser_type :
978 site_settings::kChooserTypeGroupNames) 993 site_settings::kChooserTypeGroupNames)
979 UpdateChooserExceptionsViewFromModel(chooser_type); 994 UpdateChooserExceptionsViewFromModel(chooser_type);
980 } 995 }
981 996
982 void ContentSettingsHandler::UpdateAllOTRChooserExceptionsViewsFromModel() { 997 void ContentSettingsHandler::UpdateAllOTRChooserExceptionsViewsFromModel() {
983 for (const site_settings::ChooserTypeNameEntry& chooser_type : 998 for (const site_settings::ChooserTypeNameEntry& chooser_type :
984 site_settings::kChooserTypeGroupNames) 999 site_settings::kChooserTypeGroupNames)
985 UpdateOTRChooserExceptionsViewFromModel(chooser_type); 1000 UpdateOTRChooserExceptionsViewFromModel(chooser_type);
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 1500
1486 // Exceptions apply only when the feature is enabled. 1501 // Exceptions apply only when the feature is enabled.
1487 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1502 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1488 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1503 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1489 web_ui()->CallJavascriptFunctionUnsafe( 1504 web_ui()->CallJavascriptFunctionUnsafe(
1490 "ContentSettings.enableProtectedContentExceptions", 1505 "ContentSettings.enableProtectedContentExceptions",
1491 base::Value(enable_exceptions)); 1506 base::Value(enable_exceptions));
1492 } 1507 }
1493 1508
1494 } // namespace options 1509 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/content_settings_handler.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698