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/content_settings/content_setting_bubble_model.h" | 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 DomainList domain_list; | 946 DomainList domain_list; |
947 domain_list.title = l10n_util::GetStringUTF8(title_id); | 947 domain_list.title = l10n_util::GetStringUTF8(title_id); |
948 domain_list.hosts = hosts; | 948 domain_list.hosts = hosts; |
949 add_domain_list(domain_list); | 949 add_domain_list(domain_list); |
950 } | 950 } |
951 } | 951 } |
952 | 952 |
953 void ContentSettingDomainListBubbleModel::SetDomainsAndCustomLink() { | 953 void ContentSettingDomainListBubbleModel::SetDomainsAndCustomLink() { |
954 TabSpecificContentSettings* content_settings = | 954 TabSpecificContentSettings* content_settings = |
955 TabSpecificContentSettings::FromWebContents(web_contents()); | 955 TabSpecificContentSettings::FromWebContents(web_contents()); |
956 const GeolocationSettingsState& settings = | 956 const ContentSettingsUsagesState& usages = |
957 content_settings->geolocation_settings_state(); | 957 content_settings->geolocation_usages_state(); |
958 GeolocationSettingsState::FormattedHostsPerState formatted_hosts_per_state; | 958 ContentSettingsUsagesState::FormattedHostsPerState formatted_hosts_per_state; |
959 unsigned int tab_state_flags = 0; | 959 unsigned int tab_state_flags = 0; |
960 settings.GetDetailedInfo(&formatted_hosts_per_state, &tab_state_flags); | 960 usages.GetDetailedInfo(&formatted_hosts_per_state, &tab_state_flags); |
961 // Divide the tab's current geolocation users into sets according to their | 961 // Divide the tab's current geolocation users into sets according to their |
962 // permission state. | 962 // permission state. |
963 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_ALLOW], | 963 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_ALLOW], |
964 IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED); | 964 IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED); |
965 | 965 |
966 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_BLOCK], | 966 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_BLOCK], |
967 IDS_GEOLOCATION_BUBBLE_SECTION_DENIED); | 967 IDS_GEOLOCATION_BUBBLE_SECTION_DENIED); |
968 | 968 |
969 if (tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_EXCEPTION) { | 969 if (tab_state_flags & ContentSettingsUsagesState::TABSTATE_HAS_EXCEPTION) { |
970 set_custom_link(l10n_util::GetStringUTF8( | 970 set_custom_link(l10n_util::GetStringUTF8( |
971 IDS_GEOLOCATION_BUBBLE_CLEAR_LINK)); | 971 IDS_GEOLOCATION_BUBBLE_CLEAR_LINK)); |
972 set_custom_link_enabled(true); | 972 set_custom_link_enabled(true); |
973 } else if (tab_state_flags & | 973 } else if (tab_state_flags & |
974 GeolocationSettingsState::TABSTATE_HAS_CHANGED) { | 974 ContentSettingsUsagesState::TABSTATE_HAS_CHANGED) { |
975 set_custom_link(l10n_util::GetStringUTF8( | 975 set_custom_link(l10n_util::GetStringUTF8( |
976 IDS_GEOLOCATION_BUBBLE_REQUIRE_RELOAD_TO_CLEAR)); | 976 IDS_GEOLOCATION_BUBBLE_REQUIRE_RELOAD_TO_CLEAR)); |
977 } | 977 } |
978 } | 978 } |
979 | 979 |
980 void ContentSettingDomainListBubbleModel::OnCustomLinkClicked() { | 980 void ContentSettingDomainListBubbleModel::OnCustomLinkClicked() { |
981 if (!web_contents()) | 981 if (!web_contents()) |
982 return; | 982 return; |
983 // Reset this embedder's entry to default for each of the requesting | 983 // Reset this embedder's entry to default for each of the requesting |
984 // origins currently on the page. | 984 // origins currently on the page. |
985 const GURL& embedder_url = web_contents()->GetURL(); | 985 const GURL& embedder_url = web_contents()->GetURL(); |
986 TabSpecificContentSettings* content_settings = | 986 TabSpecificContentSettings* content_settings = |
987 TabSpecificContentSettings::FromWebContents(web_contents()); | 987 TabSpecificContentSettings::FromWebContents(web_contents()); |
988 const GeolocationSettingsState::StateMap& state_map = | 988 const ContentSettingsUsagesState::StateMap& state_map = |
989 content_settings->geolocation_settings_state().state_map(); | 989 content_settings->geolocation_usages_state().state_map(); |
990 HostContentSettingsMap* settings_map = | 990 HostContentSettingsMap* settings_map = |
991 profile()->GetHostContentSettingsMap(); | 991 profile()->GetHostContentSettingsMap(); |
992 | 992 |
993 for (GeolocationSettingsState::StateMap::const_iterator it = | 993 for (ContentSettingsUsagesState::StateMap::const_iterator it = |
994 state_map.begin(); it != state_map.end(); ++it) { | 994 state_map.begin(); it != state_map.end(); ++it) { |
995 settings_map->SetContentSetting( | 995 settings_map->SetContentSetting( |
996 ContentSettingsPattern::FromURLNoWildcard(it->first), | 996 ContentSettingsPattern::FromURLNoWildcard(it->first), |
997 ContentSettingsPattern::FromURLNoWildcard(embedder_url), | 997 ContentSettingsPattern::FromURLNoWildcard(embedder_url), |
998 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 998 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
999 std::string(), | 999 std::string(), |
1000 CONTENT_SETTING_DEFAULT); | 1000 CONTENT_SETTING_DEFAULT); |
1001 } | 1001 } |
1002 } | 1002 } |
1003 | 1003 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1250 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
1251 DCHECK_EQ(web_contents_, | 1251 DCHECK_EQ(web_contents_, |
1252 content::Source<WebContents>(source).ptr()); | 1252 content::Source<WebContents>(source).ptr()); |
1253 web_contents_ = NULL; | 1253 web_contents_ = NULL; |
1254 } else { | 1254 } else { |
1255 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1255 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
1256 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1256 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
1257 profile_ = NULL; | 1257 profile_ = NULL; |
1258 } | 1258 } |
1259 } | 1259 } |
OLD | NEW |