| 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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/content_settings/content_settings_utils.h" | 10 #include "chrome/browser/content_settings/content_settings_utils.h" |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 DomainList domain_list; | 913 DomainList domain_list; |
| 914 domain_list.title = l10n_util::GetStringUTF8(title_id); | 914 domain_list.title = l10n_util::GetStringUTF8(title_id); |
| 915 domain_list.hosts = hosts; | 915 domain_list.hosts = hosts; |
| 916 add_domain_list(domain_list); | 916 add_domain_list(domain_list); |
| 917 } | 917 } |
| 918 } | 918 } |
| 919 | 919 |
| 920 void ContentSettingDomainListBubbleModel::SetDomainsAndCustomLink() { | 920 void ContentSettingDomainListBubbleModel::SetDomainsAndCustomLink() { |
| 921 TabSpecificContentSettings* content_settings = | 921 TabSpecificContentSettings* content_settings = |
| 922 TabSpecificContentSettings::FromWebContents(web_contents()); | 922 TabSpecificContentSettings::FromWebContents(web_contents()); |
| 923 const GeolocationSettingsState& settings = | 923 const ContentSettingsUsagesState& usages = |
| 924 content_settings->geolocation_settings_state(); | 924 content_settings->geolocation_usages_state(); |
| 925 GeolocationSettingsState::FormattedHostsPerState formatted_hosts_per_state; | 925 ContentSettingsUsagesState::FormattedHostsPerState formatted_hosts_per_state; |
| 926 unsigned int tab_state_flags = 0; | 926 unsigned int tab_state_flags = 0; |
| 927 settings.GetDetailedInfo(&formatted_hosts_per_state, &tab_state_flags); | 927 usages.GetDetailedInfo(&formatted_hosts_per_state, &tab_state_flags); |
| 928 // Divide the tab's current geolocation users into sets according to their | 928 // Divide the tab's current geolocation users into sets according to their |
| 929 // permission state. | 929 // permission state. |
| 930 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_ALLOW], | 930 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_ALLOW], |
| 931 IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED); | 931 IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED); |
| 932 | 932 |
| 933 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_BLOCK], | 933 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_BLOCK], |
| 934 IDS_GEOLOCATION_BUBBLE_SECTION_DENIED); | 934 IDS_GEOLOCATION_BUBBLE_SECTION_DENIED); |
| 935 | 935 |
| 936 if (tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_EXCEPTION) { | 936 if (tab_state_flags & ContentSettingsUsagesState::TABSTATE_HAS_EXCEPTION) { |
| 937 set_custom_link(l10n_util::GetStringUTF8( | 937 set_custom_link(l10n_util::GetStringUTF8( |
| 938 IDS_GEOLOCATION_BUBBLE_CLEAR_LINK)); | 938 IDS_GEOLOCATION_BUBBLE_CLEAR_LINK)); |
| 939 set_custom_link_enabled(true); | 939 set_custom_link_enabled(true); |
| 940 } else if (tab_state_flags & | 940 } else if (tab_state_flags & |
| 941 GeolocationSettingsState::TABSTATE_HAS_CHANGED) { | 941 ContentSettingsUsagesState::TABSTATE_HAS_CHANGED) { |
| 942 set_custom_link(l10n_util::GetStringUTF8( | 942 set_custom_link(l10n_util::GetStringUTF8( |
| 943 IDS_GEOLOCATION_BUBBLE_REQUIRE_RELOAD_TO_CLEAR)); | 943 IDS_GEOLOCATION_BUBBLE_REQUIRE_RELOAD_TO_CLEAR)); |
| 944 } | 944 } |
| 945 } | 945 } |
| 946 | 946 |
| 947 void ContentSettingDomainListBubbleModel::OnCustomLinkClicked() { | 947 void ContentSettingDomainListBubbleModel::OnCustomLinkClicked() { |
| 948 if (!web_contents()) | 948 if (!web_contents()) |
| 949 return; | 949 return; |
| 950 // Reset this embedder's entry to default for each of the requesting | 950 // Reset this embedder's entry to default for each of the requesting |
| 951 // origins currently on the page. | 951 // origins currently on the page. |
| 952 const GURL& embedder_url = web_contents()->GetURL(); | 952 const GURL& embedder_url = web_contents()->GetURL(); |
| 953 TabSpecificContentSettings* content_settings = | 953 TabSpecificContentSettings* content_settings = |
| 954 TabSpecificContentSettings::FromWebContents(web_contents()); | 954 TabSpecificContentSettings::FromWebContents(web_contents()); |
| 955 const GeolocationSettingsState::StateMap& state_map = | 955 const ContentSettingsUsagesState::StateMap& state_map = |
| 956 content_settings->geolocation_settings_state().state_map(); | 956 content_settings->geolocation_usages_state().state_map(); |
| 957 HostContentSettingsMap* settings_map = | 957 HostContentSettingsMap* settings_map = |
| 958 profile()->GetHostContentSettingsMap(); | 958 profile()->GetHostContentSettingsMap(); |
| 959 | 959 |
| 960 for (GeolocationSettingsState::StateMap::const_iterator it = | 960 for (ContentSettingsUsagesState::StateMap::const_iterator it = |
| 961 state_map.begin(); it != state_map.end(); ++it) { | 961 state_map.begin(); it != state_map.end(); ++it) { |
| 962 settings_map->SetContentSetting( | 962 settings_map->SetContentSetting( |
| 963 ContentSettingsPattern::FromURLNoWildcard(it->first), | 963 ContentSettingsPattern::FromURLNoWildcard(it->first), |
| 964 ContentSettingsPattern::FromURLNoWildcard(embedder_url), | 964 ContentSettingsPattern::FromURLNoWildcard(embedder_url), |
| 965 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 965 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 966 std::string(), | 966 std::string(), |
| 967 CONTENT_SETTING_DEFAULT); | 967 CONTENT_SETTING_DEFAULT); |
| 968 } | 968 } |
| 969 } | 969 } |
| 970 | 970 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1217 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
| 1218 DCHECK_EQ(web_contents_, | 1218 DCHECK_EQ(web_contents_, |
| 1219 content::Source<WebContents>(source).ptr()); | 1219 content::Source<WebContents>(source).ptr()); |
| 1220 web_contents_ = NULL; | 1220 web_contents_ = NULL; |
| 1221 } else { | 1221 } else { |
| 1222 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1222 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 1223 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1223 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| 1224 profile_ = NULL; | 1224 profile_ = NULL; |
| 1225 } | 1225 } |
| 1226 } | 1226 } |
| OLD | NEW |