OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/content_setting_bubble_model.h" | 5 #include "chrome/browser/content_setting_bubble_model.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "chrome/browser/blocked_popup_container.h" | 8 #include "chrome/browser/blocked_popup_container.h" |
9 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 9 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
10 #include "chrome/browser/host_content_settings_map.h" | 10 #include "chrome/browser/host_content_settings_map.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 private: | 192 private: |
193 void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id) { | 193 void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id) { |
194 if (!hosts.empty()) { | 194 if (!hosts.empty()) { |
195 DomainList domain_list; | 195 DomainList domain_list; |
196 domain_list.title = l10n_util::GetStringUTF8(title_id); | 196 domain_list.title = l10n_util::GetStringUTF8(title_id); |
197 domain_list.hosts = hosts; | 197 domain_list.hosts = hosts; |
198 add_domain_list(domain_list); | 198 add_domain_list(domain_list); |
199 } | 199 } |
200 } | 200 } |
201 void SetDomainsAndClearLink() { | 201 void SetDomainsAndClearLink() { |
| 202 TabSpecificContentSettings* content_settings = |
| 203 tab_contents()->GetTabSpecificContentSettings(); |
202 const GeolocationSettingsState& settings = | 204 const GeolocationSettingsState& settings = |
203 tab_contents()->geolocation_settings_state(); | 205 content_settings->geolocation_settings_state(); |
204 GeolocationSettingsState::FormattedHostsPerState formatted_hosts_per_state; | 206 GeolocationSettingsState::FormattedHostsPerState formatted_hosts_per_state; |
205 unsigned int tab_state_flags = 0; | 207 unsigned int tab_state_flags = 0; |
206 settings.GetDetailedInfo(&formatted_hosts_per_state, &tab_state_flags); | 208 settings.GetDetailedInfo(&formatted_hosts_per_state, &tab_state_flags); |
207 // Divide the tab's current geolocation users into sets according to their | 209 // Divide the tab's current geolocation users into sets according to their |
208 // permission state. | 210 // permission state. |
209 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_ALLOW], | 211 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_ALLOW], |
210 IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED); | 212 IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED); |
211 | 213 |
212 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_BLOCK], | 214 MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_BLOCK], |
213 IDS_GEOLOCATION_BUBBLE_SECTION_DENIED); | 215 IDS_GEOLOCATION_BUBBLE_SECTION_DENIED); |
(...skipping 12 matching lines...) Expand all Loading... |
226 IDS_GEOLOCATION_BUBBLE_REQUIRE_RELOAD_TO_CLEAR); | 228 IDS_GEOLOCATION_BUBBLE_REQUIRE_RELOAD_TO_CLEAR); |
227 add_domain_list(reload_section); | 229 add_domain_list(reload_section); |
228 } | 230 } |
229 } | 231 } |
230 virtual void OnClearLinkClicked() { | 232 virtual void OnClearLinkClicked() { |
231 if (!tab_contents()) | 233 if (!tab_contents()) |
232 return; | 234 return; |
233 // Reset this embedder's entry to default for each of the requesting | 235 // Reset this embedder's entry to default for each of the requesting |
234 // origins currently on the page. | 236 // origins currently on the page. |
235 const GURL& embedder_url = tab_contents()->GetURL(); | 237 const GURL& embedder_url = tab_contents()->GetURL(); |
| 238 TabSpecificContentSettings* content_settings = |
| 239 tab_contents()->GetTabSpecificContentSettings(); |
236 const GeolocationSettingsState::StateMap& state_map = | 240 const GeolocationSettingsState::StateMap& state_map = |
237 tab_contents()->geolocation_settings_state().state_map(); | 241 content_settings->geolocation_settings_state().state_map(); |
238 GeolocationContentSettingsMap* settings_map = | 242 GeolocationContentSettingsMap* settings_map = |
239 profile()->GetGeolocationContentSettingsMap(); | 243 profile()->GetGeolocationContentSettingsMap(); |
240 for (GeolocationSettingsState::StateMap::const_iterator it = | 244 for (GeolocationSettingsState::StateMap::const_iterator it = |
241 state_map.begin(); it != state_map.end(); ++it) { | 245 state_map.begin(); it != state_map.end(); ++it) { |
242 settings_map->SetContentSetting(it->first, embedder_url, | 246 settings_map->SetContentSetting(it->first, embedder_url, |
243 CONTENT_SETTING_DEFAULT); | 247 CONTENT_SETTING_DEFAULT); |
244 } | 248 } |
245 } | 249 } |
246 }; | 250 }; |
247 | 251 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 ContentSettingBubbleModel::~ContentSettingBubbleModel() { | 283 ContentSettingBubbleModel::~ContentSettingBubbleModel() { |
280 } | 284 } |
281 | 285 |
282 void ContentSettingBubbleModel::Observe(NotificationType type, | 286 void ContentSettingBubbleModel::Observe(NotificationType type, |
283 const NotificationSource& source, | 287 const NotificationSource& source, |
284 const NotificationDetails& details) { | 288 const NotificationDetails& details) { |
285 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); | 289 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); |
286 DCHECK(source == Source<TabContents>(tab_contents_)); | 290 DCHECK(source == Source<TabContents>(tab_contents_)); |
287 tab_contents_ = NULL; | 291 tab_contents_ = NULL; |
288 } | 292 } |
OLD | NEW |