| 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> |
| 8 |
| 7 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
| 8 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 9 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 12 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 13 #include "content/browser/tab_contents/navigation_details.h" | 16 #include "content/browser/tab_contents/navigation_details.h" |
| 14 #include "content/browser/tab_contents/navigation_entry.h" | 17 #include "content/browser/tab_contents/navigation_entry.h" |
| 15 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 16 | 19 |
| 17 GeolocationSettingsState::GeolocationSettingsState(Profile* profile) | 20 GeolocationSettingsState::GeolocationSettingsState(Profile* profile) |
| 18 : profile_(profile) { | 21 : profile_(profile) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 47 | 50 |
| 48 void GeolocationSettingsState::ClearStateMap() { | 51 void GeolocationSettingsState::ClearStateMap() { |
| 49 state_map_.clear(); | 52 state_map_.clear(); |
| 50 } | 53 } |
| 51 | 54 |
| 52 void GeolocationSettingsState::GetDetailedInfo( | 55 void GeolocationSettingsState::GetDetailedInfo( |
| 53 FormattedHostsPerState* formatted_hosts_per_state, | 56 FormattedHostsPerState* formatted_hosts_per_state, |
| 54 unsigned int* tab_state_flags) const { | 57 unsigned int* tab_state_flags) const { |
| 55 DCHECK(tab_state_flags); | 58 DCHECK(tab_state_flags); |
| 56 DCHECK(embedder_url_.is_valid()); | 59 DCHECK(embedder_url_.is_valid()); |
| 57 const ContentSetting default_setting = | 60 ContentSetting default_setting = |
| 58 profile_->GetGeolocationContentSettingsMap()->GetDefaultContentSetting(); | 61 profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( |
| 62 CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 59 std::set<std::string> formatted_hosts; | 63 std::set<std::string> formatted_hosts; |
| 60 std::set<std::string> repeated_formatted_hosts; | 64 std::set<std::string> repeated_formatted_hosts; |
| 61 | 65 |
| 62 // Build a set of repeated formatted hosts | 66 // Build a set of repeated formatted hosts |
| 63 for (StateMap::const_iterator i(state_map_.begin()); | 67 for (StateMap::const_iterator i(state_map_.begin()); |
| 64 i != state_map_.end(); ++i) { | 68 i != state_map_.end(); ++i) { |
| 65 std::string formatted_host = GURLToFormattedHost(i->first); | 69 std::string formatted_host = GURLToFormattedHost(i->first); |
| 66 if (!formatted_hosts.insert(formatted_host).second) { | 70 if (!formatted_hosts.insert(formatted_host).second) { |
| 67 repeated_formatted_hosts.insert(formatted_host); | 71 repeated_formatted_hosts.insert(formatted_host); |
| 68 } | 72 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 94 } | 98 } |
| 95 } | 99 } |
| 96 | 100 |
| 97 std::string GeolocationSettingsState::GURLToFormattedHost( | 101 std::string GeolocationSettingsState::GURLToFormattedHost( |
| 98 const GURL& url) const { | 102 const GURL& url) const { |
| 99 string16 display_host; | 103 string16 display_host; |
| 100 net::AppendFormattedHost(url, | 104 net::AppendFormattedHost(url, |
| 101 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &display_host); | 105 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &display_host); |
| 102 return UTF16ToUTF8(display_host); | 106 return UTF16ToUTF8(display_host); |
| 103 } | 107 } |
| OLD | NEW |