OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/geolocation/geolocation_settings_state.h" | 5 #include "chrome/browser/geolocation/geolocation_settings_state.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/content_settings/host_content_settings_map.h" | 11 #include "chrome/browser/content_settings/host_content_settings_map.h" |
12 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | |
13 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
16 #include "content/browser/tab_contents/navigation_details.h" | 15 #include "content/browser/tab_contents/navigation_details.h" |
17 #include "content/browser/tab_contents/navigation_entry.h" | 16 #include "content/browser/tab_contents/navigation_entry.h" |
18 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
19 | 18 |
20 GeolocationSettingsState::GeolocationSettingsState(Profile* profile) | 19 GeolocationSettingsState::GeolocationSettingsState(Profile* profile) |
21 : profile_(profile) { | 20 : profile_(profile) { |
22 } | 21 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 std::string formatted_host = GURLToFormattedHost(i->first); | 79 std::string formatted_host = GURLToFormattedHost(i->first); |
81 std::string final_formatted_host = | 80 std::string final_formatted_host = |
82 repeated_formatted_hosts.find(formatted_host) == | 81 repeated_formatted_hosts.find(formatted_host) == |
83 repeated_formatted_hosts.end() ? | 82 repeated_formatted_hosts.end() ? |
84 formatted_host : | 83 formatted_host : |
85 i->first.spec(); | 84 i->first.spec(); |
86 (*formatted_hosts_per_state)[i->second].insert(final_formatted_host); | 85 (*formatted_hosts_per_state)[i->second].insert(final_formatted_host); |
87 } | 86 } |
88 | 87 |
89 const ContentSetting saved_setting = | 88 const ContentSetting saved_setting = |
90 profile_->GetGeolocationContentSettingsMap()->GetContentSetting( | 89 profile_->GetHostContentSettingsMap()->GetContentSetting( |
91 i->first, embedder_url_); | 90 i->first, |
| 91 embedder_url_, |
| 92 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 93 std::string()); |
92 if (saved_setting != default_setting) | 94 if (saved_setting != default_setting) |
93 *tab_state_flags |= TABSTATE_HAS_EXCEPTION; | 95 *tab_state_flags |= TABSTATE_HAS_EXCEPTION; |
94 if (saved_setting != i->second) | 96 if (saved_setting != i->second) |
95 *tab_state_flags |= TABSTATE_HAS_CHANGED; | 97 *tab_state_flags |= TABSTATE_HAS_CHANGED; |
96 if (saved_setting != CONTENT_SETTING_ASK) | 98 if (saved_setting != CONTENT_SETTING_ASK) |
97 *tab_state_flags |= TABSTATE_HAS_ANY_ICON; | 99 *tab_state_flags |= TABSTATE_HAS_ANY_ICON; |
98 } | 100 } |
99 } | 101 } |
100 | 102 |
101 std::string GeolocationSettingsState::GURLToFormattedHost( | 103 std::string GeolocationSettingsState::GURLToFormattedHost( |
102 const GURL& url) const { | 104 const GURL& url) const { |
103 string16 display_host; | 105 string16 display_host; |
104 net::AppendFormattedHost(url, | 106 net::AppendFormattedHost(url, |
105 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &display_host); | 107 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &display_host); |
106 return UTF16ToUTF8(display_host); | 108 return UTF16ToUTF8(display_host); |
107 } | 109 } |
OLD | NEW |