| 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/options2/content_settings_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/content_settings_handler2.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 {CONTENT_SETTINGS_TYPE_IMAGES, "images"}, | 73 {CONTENT_SETTINGS_TYPE_IMAGES, "images"}, |
| 74 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"}, | 74 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"}, |
| 75 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"}, | 75 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"}, |
| 76 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, | 76 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, |
| 77 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, | 77 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, |
| 78 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, | 78 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, |
| 79 {CONTENT_SETTINGS_TYPE_INTENTS, "intents"}, | 79 {CONTENT_SETTINGS_TYPE_INTENTS, "intents"}, |
| 80 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"}, | 80 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"}, |
| 81 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, | 81 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, |
| 82 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, | 82 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, |
| 83 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, "mediastream"}, |
| 83 }; | 84 }; |
| 84 COMPILE_ASSERT(arraysize(kContentSettingsTypeGroupNames) == | 85 COMPILE_ASSERT(arraysize(kContentSettingsTypeGroupNames) == |
| 85 CONTENT_SETTINGS_NUM_TYPES, | 86 CONTENT_SETTINGS_NUM_TYPES, |
| 86 MISSING_CONTENT_SETTINGS_TYPE); | 87 MISSING_CONTENT_SETTINGS_TYPE); |
| 87 | 88 |
| 88 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) { | 89 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) { |
| 89 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { | 90 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { |
| 90 if (name == kContentSettingsTypeGroupNames[i].name) | 91 if (name == kContentSettingsTypeGroupNames[i].name) |
| 91 return kContentSettingsTypeGroupNames[i].type; | 92 return kContentSettingsTypeGroupNames[i].type; |
| 92 } | 93 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 ContentSetting setting, | 191 ContentSetting setting, |
| 191 const std::string& provider_name) { | 192 const std::string& provider_name) { |
| 192 DictionaryValue* exception = new DictionaryValue(); | 193 DictionaryValue* exception = new DictionaryValue(); |
| 193 exception->SetString(kDisplayPattern, pattern.ToString()); | 194 exception->SetString(kDisplayPattern, pattern.ToString()); |
| 194 exception->SetString(kSetting, ContentSettingToString(setting)); | 195 exception->SetString(kSetting, ContentSettingToString(setting)); |
| 195 exception->SetString(kOrigin, pattern.ToString()); | 196 exception->SetString(kOrigin, pattern.ToString()); |
| 196 exception->SetString(kSource, provider_name); | 197 exception->SetString(kSource, provider_name); |
| 197 return exception; | 198 return exception; |
| 198 } | 199 } |
| 199 | 200 |
| 201 // Create a DictionaryValue* that will act as a data source for a single row |
| 202 // in the mediastream exceptions table. Ownership of the pointer is |
| 203 // passed to the caller. |
| 204 DictionaryValue* GetMediaStreamExceptionForPage( |
| 205 const ContentSettingsPattern& pattern) { |
| 206 DictionaryValue* exception = new DictionaryValue(); |
| 207 exception->SetString(kDisplayPattern, pattern.ToString()); |
| 208 exception->SetString(kSetting, ContentSettingToString(CONTENT_SETTING_ALLOW)); |
| 209 exception->SetString(kOrigin, pattern.ToString()); |
| 210 exception->SetString(kSource, std::string()); |
| 211 return exception; |
| 212 } |
| 213 |
| 200 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from | 214 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from |
| 201 // the web extent of a hosted |app|. | 215 // the web extent of a hosted |app|. |
| 202 void AddExceptionForHostedApp(const std::string& url_pattern, | 216 void AddExceptionForHostedApp(const std::string& url_pattern, |
| 203 const extensions::Extension& app, ListValue* exceptions) { | 217 const extensions::Extension& app, ListValue* exceptions) { |
| 204 DictionaryValue* exception = new DictionaryValue(); | 218 DictionaryValue* exception = new DictionaryValue(); |
| 205 exception->SetString(kDisplayPattern, url_pattern); | 219 exception->SetString(kDisplayPattern, url_pattern); |
| 206 exception->SetString(kSetting, ContentSettingToString(CONTENT_SETTING_ALLOW)); | 220 exception->SetString(kSetting, ContentSettingToString(CONTENT_SETTING_ALLOW)); |
| 207 exception->SetString(kOrigin, url_pattern); | 221 exception->SetString(kOrigin, url_pattern); |
| 208 exception->SetString(kEmbeddingOrigin, url_pattern); | 222 exception->SetString(kEmbeddingOrigin, url_pattern); |
| 209 exception->SetString(kSource, "HostedApp"); | 223 exception->SetString(kSource, "HostedApp"); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 { "mouselock_header", IDS_MOUSE_LOCK_HEADER }, | 341 { "mouselock_header", IDS_MOUSE_LOCK_HEADER }, |
| 328 { "mouselock_allow", IDS_MOUSE_LOCK_ALLOW_RADIO }, | 342 { "mouselock_allow", IDS_MOUSE_LOCK_ALLOW_RADIO }, |
| 329 { "mouselock_ask", IDS_MOUSE_LOCK_ASK_RADIO }, | 343 { "mouselock_ask", IDS_MOUSE_LOCK_ASK_RADIO }, |
| 330 { "mouselock_block", IDS_MOUSE_LOCK_BLOCK_RADIO }, | 344 { "mouselock_block", IDS_MOUSE_LOCK_BLOCK_RADIO }, |
| 331 #if defined(OS_CHROMEOS) | 345 #if defined(OS_CHROMEOS) |
| 332 // Protected Content filter | 346 // Protected Content filter |
| 333 { "protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL }, | 347 { "protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL }, |
| 334 { "protectedContentInfo", IDS_PROTECTED_CONTENT_INFO }, | 348 { "protectedContentInfo", IDS_PROTECTED_CONTENT_INFO }, |
| 335 { "protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE}, | 349 { "protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE}, |
| 336 #endif // defined(OS_CHROMEOS) | 350 #endif // defined(OS_CHROMEOS) |
| 351 // Media stream capture device filter. |
| 352 { "mediastream_tab_label", IDS_MEDIA_STREAM_TAB_LABEL }, |
| 353 { "mediastream_header", IDS_MEDIA_STREAM_HEADER }, |
| 354 { "mediastream_ask", IDS_MEDIA_STREAM_ASK_RADIO }, |
| 355 { "mediastream_block", IDS_MEDIA_STREAM_BLOCK_RADIO }, |
| 337 }; | 356 }; |
| 338 | 357 |
| 339 RegisterStrings(localized_strings, resources, arraysize(resources)); | 358 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 340 RegisterTitle(localized_strings, "contentSettingsPage", | 359 RegisterTitle(localized_strings, "contentSettingsPage", |
| 341 IDS_CONTENT_SETTINGS_TITLE); | 360 IDS_CONTENT_SETTINGS_TITLE); |
| 342 | 361 |
| 343 // Register titles for each of the individual settings whose exception | 362 // Register titles for each of the individual settings whose exception |
| 344 // dialogs will be processed by |ContentSettingsHandler|. | 363 // dialogs will be processed by |ContentSettingsHandler|. |
| 345 RegisterTitle(localized_strings, "cookies", | 364 RegisterTitle(localized_strings, "cookies", |
| 346 IDS_COOKIES_TAB_LABEL); | 365 IDS_COOKIES_TAB_LABEL); |
| 347 RegisterTitle(localized_strings, "images", | 366 RegisterTitle(localized_strings, "images", |
| 348 IDS_IMAGES_TAB_LABEL); | 367 IDS_IMAGES_TAB_LABEL); |
| 349 RegisterTitle(localized_strings, "javascript", | 368 RegisterTitle(localized_strings, "javascript", |
| 350 IDS_JAVASCRIPT_TAB_LABEL); | 369 IDS_JAVASCRIPT_TAB_LABEL); |
| 351 RegisterTitle(localized_strings, "plugins", | 370 RegisterTitle(localized_strings, "plugins", |
| 352 IDS_PLUGIN_TAB_LABEL); | 371 IDS_PLUGIN_TAB_LABEL); |
| 353 RegisterTitle(localized_strings, "popups", | 372 RegisterTitle(localized_strings, "popups", |
| 354 IDS_POPUP_TAB_LABEL); | 373 IDS_POPUP_TAB_LABEL); |
| 355 RegisterTitle(localized_strings, "location", | 374 RegisterTitle(localized_strings, "location", |
| 356 IDS_GEOLOCATION_TAB_LABEL); | 375 IDS_GEOLOCATION_TAB_LABEL); |
| 357 RegisterTitle(localized_strings, "notifications", | 376 RegisterTitle(localized_strings, "notifications", |
| 358 IDS_NOTIFICATIONS_TAB_LABEL); | 377 IDS_NOTIFICATIONS_TAB_LABEL); |
| 359 RegisterTitle(localized_strings, "fullscreen", | 378 RegisterTitle(localized_strings, "fullscreen", |
| 360 IDS_FULLSCREEN_TAB_LABEL); | 379 IDS_FULLSCREEN_TAB_LABEL); |
| 361 RegisterTitle(localized_strings, "mouselock", | 380 RegisterTitle(localized_strings, "mouselock", |
| 362 IDS_MOUSE_LOCK_TAB_LABEL); | 381 IDS_MOUSE_LOCK_TAB_LABEL); |
| 382 RegisterTitle(localized_strings, "mediastream", |
| 383 IDS_MEDIA_STREAM_TAB_LABEL); |
| 363 | 384 |
| 364 Profile* profile = Profile::FromWebUI(web_ui()); | 385 Profile* profile = Profile::FromWebUI(web_ui()); |
| 365 localized_strings->SetBoolean( | 386 localized_strings->SetBoolean( |
| 366 "enable_web_intents", | 387 "enable_web_intents", |
| 367 web_intents::IsWebIntentsEnabledForProfile(profile)); | 388 web_intents::IsWebIntentsEnabledForProfile(profile)); |
| 368 // TODO(marja): clean up the options UI after the decision on the session | 389 // TODO(marja): clean up the options UI after the decision on the session |
| 369 // restore changes has stabilized. | 390 // restore changes has stabilized. |
| 370 localized_strings->SetBoolean( | 391 localized_strings->SetBoolean( |
| 371 "enable_restore_session_state", false); | 392 "enable_restore_session_state", false); |
| 372 } | 393 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 if (type == CONTENT_SETTINGS_TYPE_INTENTS) | 550 if (type == CONTENT_SETTINGS_TYPE_INTENTS) |
| 530 return; | 551 return; |
| 531 | 552 |
| 532 switch (type) { | 553 switch (type) { |
| 533 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 554 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 534 UpdateGeolocationExceptionsView(); | 555 UpdateGeolocationExceptionsView(); |
| 535 break; | 556 break; |
| 536 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 557 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 537 UpdateNotificationExceptionsView(); | 558 UpdateNotificationExceptionsView(); |
| 538 break; | 559 break; |
| 560 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
| 561 UpdateMediaStreamExceptionsView(); |
| 562 break; |
| 539 default: | 563 default: |
| 540 UpdateExceptionsViewFromHostContentSettingsMap(type); | 564 UpdateExceptionsViewFromHostContentSettingsMap(type); |
| 541 break; | 565 break; |
| 542 } | 566 } |
| 543 } | 567 } |
| 544 | 568 |
| 545 void ContentSettingsHandler::UpdateOTRExceptionsViewFromModel( | 569 void ContentSettingsHandler::UpdateOTRExceptionsViewFromModel( |
| 546 ContentSettingsType type) { | 570 ContentSettingsType type) { |
| 547 switch (type) { | 571 switch (type) { |
| 548 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 572 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 549 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 573 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 550 case CONTENT_SETTINGS_TYPE_INTENTS: | 574 case CONTENT_SETTINGS_TYPE_INTENTS: |
| 551 case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE: | 575 case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE: |
| 576 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
| 577 // TODO(xians): Add MediaStream support to OTRExceptionsView. |
| 552 break; | 578 break; |
| 553 default: | 579 default: |
| 554 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); | 580 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); |
| 555 break; | 581 break; |
| 556 } | 582 } |
| 557 } | 583 } |
| 558 | 584 |
| 559 void ContentSettingsHandler::UpdateGeolocationExceptionsView() { | 585 void ContentSettingsHandler::UpdateGeolocationExceptionsView() { |
| 560 Profile* profile = Profile::FromWebUI(web_ui()); | 586 Profile* profile = Profile::FromWebUI(web_ui()); |
| 561 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); | 587 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 StringValue type_string( | 682 StringValue type_string( |
| 657 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); | 683 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); |
| 658 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | 684 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", |
| 659 type_string, exceptions); | 685 type_string, exceptions); |
| 660 | 686 |
| 661 // This is mainly here to keep this function ideologically parallel to | 687 // This is mainly here to keep this function ideologically parallel to |
| 662 // UpdateExceptionsViewFromHostContentSettingsMap(). | 688 // UpdateExceptionsViewFromHostContentSettingsMap(). |
| 663 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 689 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 664 } | 690 } |
| 665 | 691 |
| 692 void ContentSettingsHandler::UpdateMediaStreamExceptionsView() { |
| 693 ContentSettingsForOneType entries; |
| 694 GetContentSettingsMap()->GetSettingsForOneType( |
| 695 CONTENT_SETTINGS_TYPE_MEDIASTREAM, "", &entries); |
| 696 |
| 697 ListValue exceptions; |
| 698 for (size_t i = 0; i < entries.size(); ++i) { |
| 699 // Don't add default settings. |
| 700 if (entries[i].primary_pattern == ContentSettingsPattern::Wildcard() && |
| 701 entries[i].secondary_pattern == ContentSettingsPattern::Wildcard() && |
| 702 entries[i].source != "preference") { |
| 703 continue; |
| 704 } |
| 705 |
| 706 exceptions.Append( |
| 707 GetMediaStreamExceptionForPage(entries[i].primary_pattern)); |
| 708 } |
| 709 |
| 710 StringValue type_string(ContentSettingsTypeToGroupName( |
| 711 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); |
| 712 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, |
| 713 exceptions); |
| 714 |
| 715 // This is mainly here to keep this function ideologically parallel to |
| 716 // UpdateExceptionsViewFromHostContentSettingsMap(). |
| 717 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MEDIASTREAM); |
| 718 } |
| 719 |
| 666 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( | 720 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( |
| 667 ContentSettingsType type) { | 721 ContentSettingsType type) { |
| 668 ContentSettingsForOneType entries; | 722 ContentSettingsForOneType entries; |
| 669 GetContentSettingsMap()->GetSettingsForOneType(type, "", &entries); | 723 GetContentSettingsMap()->GetSettingsForOneType(type, "", &entries); |
| 670 | 724 |
| 671 ListValue exceptions; | 725 ListValue exceptions; |
| 672 for (size_t i = 0; i < entries.size(); ++i) { | 726 for (size_t i = 0; i < entries.size(); ++i) { |
| 673 // Skip default settings from extensions and policy, and the default content | 727 // Skip default settings from extensions and policy, and the default content |
| 674 // settings; all of them will affect the default setting UI. | 728 // settings; all of them will affect the default setting UI. |
| 675 if (entries[i].primary_pattern == ContentSettingsPattern::Wildcard() && | 729 if (entries[i].primary_pattern == ContentSettingsPattern::Wildcard() && |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 UserMetricsAction("Options_DefaultGeolocationSettingChanged")); | 904 UserMetricsAction("Options_DefaultGeolocationSettingChanged")); |
| 851 break; | 905 break; |
| 852 case CONTENT_SETTINGS_TYPE_INTENTS: | 906 case CONTENT_SETTINGS_TYPE_INTENTS: |
| 853 content::RecordAction( | 907 content::RecordAction( |
| 854 UserMetricsAction("Options_DefaultHandlersSettingChanged")); | 908 UserMetricsAction("Options_DefaultHandlersSettingChanged")); |
| 855 break; | 909 break; |
| 856 case CONTENT_SETTINGS_TYPE_MOUSELOCK: | 910 case CONTENT_SETTINGS_TYPE_MOUSELOCK: |
| 857 content::RecordAction( | 911 content::RecordAction( |
| 858 UserMetricsAction("Options_DefaultMouseLockSettingChanged")); | 912 UserMetricsAction("Options_DefaultMouseLockSettingChanged")); |
| 859 break; | 913 break; |
| 914 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
| 915 content::RecordAction( |
| 916 UserMetricsAction("Options_DefaultMediaStreamSettingChanged")); |
| 917 break; |
| 860 default: | 918 default: |
| 861 break; | 919 break; |
| 862 } | 920 } |
| 863 } | 921 } |
| 864 | 922 |
| 865 void ContentSettingsHandler::RemoveException(const ListValue* args) { | 923 void ContentSettingsHandler::RemoveException(const ListValue* args) { |
| 866 size_t arg_i = 0; | 924 size_t arg_i = 0; |
| 867 std::string type_string; | 925 std::string type_string; |
| 868 CHECK(args->GetString(arg_i++, &type_string)); | 926 CHECK(args->GetString(arg_i++, &type_string)); |
| 869 | 927 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 std::string pattern; | 962 std::string pattern; |
| 905 rv = args->GetString(arg_i++, &pattern); | 963 rv = args->GetString(arg_i++, &pattern); |
| 906 DCHECK(rv); | 964 DCHECK(rv); |
| 907 | 965 |
| 908 HostContentSettingsMap* settings_map = | 966 HostContentSettingsMap* settings_map = |
| 909 mode == "normal" ? GetContentSettingsMap() : | 967 mode == "normal" ? GetContentSettingsMap() : |
| 910 GetOTRContentSettingsMap(); | 968 GetOTRContentSettingsMap(); |
| 911 // The settings map could be null if the mode was OTR but the OTR profile | 969 // The settings map could be null if the mode was OTR but the OTR profile |
| 912 // got destroyed before we received this message. | 970 // got destroyed before we received this message. |
| 913 if (settings_map) { | 971 if (settings_map) { |
| 914 settings_map->SetContentSetting( | 972 // MediaStream is using compound value, so we need to use |
| 915 ContentSettingsPattern::FromString(pattern), | 973 // SetWebsiteSetting instead of SetContentSetting. |
| 916 ContentSettingsPattern::Wildcard(), | 974 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
| 917 ContentSettingsTypeFromGroupName(type_string), | 975 settings_map->SetWebsiteSetting( |
| 918 "", | 976 ContentSettingsPattern::FromString(pattern), |
| 919 CONTENT_SETTING_DEFAULT); | 977 ContentSettingsPattern::Wildcard(), |
| 978 ContentSettingsTypeFromGroupName(type_string), |
| 979 "", |
| 980 NULL); |
| 981 } else { |
| 982 settings_map->SetContentSetting( |
| 983 ContentSettingsPattern::FromString(pattern), |
| 984 ContentSettingsPattern::Wildcard(), |
| 985 ContentSettingsTypeFromGroupName(type_string), |
| 986 "", |
| 987 CONTENT_SETTING_DEFAULT); |
| 988 } |
| 920 } | 989 } |
| 921 } | 990 } |
| 922 } | 991 } |
| 923 | 992 |
| 924 void ContentSettingsHandler::SetException(const ListValue* args) { | 993 void ContentSettingsHandler::SetException(const ListValue* args) { |
| 925 size_t arg_i = 0; | 994 size_t arg_i = 0; |
| 926 std::string type_string; | 995 std::string type_string; |
| 927 CHECK(args->GetString(arg_i++, &type_string)); | 996 CHECK(args->GetString(arg_i++, &type_string)); |
| 928 std::string mode; | 997 std::string mode; |
| 929 CHECK(args->GetString(arg_i++, &mode)); | 998 CHECK(args->GetString(arg_i++, &mode)); |
| 930 std::string pattern; | 999 std::string pattern; |
| 931 CHECK(args->GetString(arg_i++, &pattern)); | 1000 CHECK(args->GetString(arg_i++, &pattern)); |
| 932 std::string setting; | 1001 std::string setting; |
| 933 CHECK(args->GetString(arg_i++, &setting)); | 1002 CHECK(args->GetString(arg_i++, &setting)); |
| 934 | 1003 |
| 935 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); | 1004 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); |
| 936 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || | 1005 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || |
| 937 type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 1006 type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || |
| 1007 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
| 938 NOTREACHED(); | 1008 NOTREACHED(); |
| 939 return; | 1009 return; |
| 940 } | 1010 } |
| 941 | 1011 |
| 942 HostContentSettingsMap* settings_map = | 1012 HostContentSettingsMap* settings_map = |
| 943 mode == "normal" ? GetContentSettingsMap() : | 1013 mode == "normal" ? GetContentSettingsMap() : |
| 944 GetOTRContentSettingsMap(); | 1014 GetOTRContentSettingsMap(); |
| 945 | 1015 |
| 946 // The settings map could be null if the mode was OTR but the OTR profile | 1016 // The settings map could be null if the mode was OTR but the OTR profile |
| 947 // got destroyed before we received this message. | 1017 // got destroyed before we received this message. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 | 1071 |
| 1002 HostContentSettingsMap* | 1072 HostContentSettingsMap* |
| 1003 ContentSettingsHandler::GetOTRContentSettingsMap() { | 1073 ContentSettingsHandler::GetOTRContentSettingsMap() { |
| 1004 Profile* profile = Profile::FromWebUI(web_ui()); | 1074 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1005 if (profile->HasOffTheRecordProfile()) | 1075 if (profile->HasOffTheRecordProfile()) |
| 1006 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 1076 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
| 1007 return NULL; | 1077 return NULL; |
| 1008 } | 1078 } |
| 1009 | 1079 |
| 1010 } // namespace options2 | 1080 } // namespace options2 |
| OLD | NEW |