Chromium Code Reviews| 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/content_settings_utils.h" | |
| 11 #include "chrome/browser/content_settings/host_content_settings_map.h" | 12 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "content/browser/tab_contents/navigation_details.h" | 16 #include "content/browser/tab_contents/navigation_details.h" |
| 16 #include "content/browser/tab_contents/navigation_entry.h" | 17 #include "content/browser/tab_contents/navigation_entry.h" |
| 17 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 18 | 19 |
| 19 GeolocationSettingsState::GeolocationSettingsState(Profile* profile) | 20 GeolocationSettingsState::GeolocationSettingsState(Profile* profile) |
| 20 : profile_(profile) { | 21 : profile_(profile) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 if (formatted_hosts_per_state) { | 79 if (formatted_hosts_per_state) { |
| 79 std::string formatted_host = GURLToFormattedHost(i->first); | 80 std::string formatted_host = GURLToFormattedHost(i->first); |
| 80 std::string final_formatted_host = | 81 std::string final_formatted_host = |
| 81 repeated_formatted_hosts.find(formatted_host) == | 82 repeated_formatted_hosts.find(formatted_host) == |
| 82 repeated_formatted_hosts.end() ? | 83 repeated_formatted_hosts.end() ? |
| 83 formatted_host : | 84 formatted_host : |
| 84 i->first.spec(); | 85 i->first.spec(); |
| 85 (*formatted_hosts_per_state)[i->second].insert(final_formatted_host); | 86 (*formatted_hosts_per_state)[i->second].insert(final_formatted_host); |
| 86 } | 87 } |
| 87 | 88 |
| 88 const ContentSetting saved_setting = | 89 scoped_ptr<base::Value> value( |
| 89 profile_->GetHostContentSettingsMap()->GetContentSetting( | 90 profile_->GetHostContentSettingsMap()->GetWebsiteSetting( |
|
Bernhard Bauer
2011/11/11 14:00:40
Same here.
markusheintz_
2011/11/14 11:15:10
same as other
| |
| 90 i->first, | 91 i->first, |
| 91 embedder_url_, | 92 embedder_url_, |
| 92 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 93 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 93 std::string()); | 94 std::string(), |
| 95 NULL)); | |
| 96 const ContentSetting saved_setting = | |
| 97 content_settings::ValueToContentSetting(value.get()); | |
| 98 | |
| 94 if (saved_setting != default_setting) | 99 if (saved_setting != default_setting) |
| 95 *tab_state_flags |= TABSTATE_HAS_EXCEPTION; | 100 *tab_state_flags |= TABSTATE_HAS_EXCEPTION; |
| 96 if (saved_setting != i->second) | 101 if (saved_setting != i->second) |
| 97 *tab_state_flags |= TABSTATE_HAS_CHANGED; | 102 *tab_state_flags |= TABSTATE_HAS_CHANGED; |
| 98 if (saved_setting != CONTENT_SETTING_ASK) | 103 if (saved_setting != CONTENT_SETTING_ASK) |
| 99 *tab_state_flags |= TABSTATE_HAS_ANY_ICON; | 104 *tab_state_flags |= TABSTATE_HAS_ANY_ICON; |
| 100 } | 105 } |
| 101 } | 106 } |
| 102 | 107 |
| 103 std::string GeolocationSettingsState::GURLToFormattedHost( | 108 std::string GeolocationSettingsState::GURLToFormattedHost( |
| 104 const GURL& url) const { | 109 const GURL& url) const { |
| 105 string16 display_host; | 110 string16 display_host; |
| 106 net::AppendFormattedHost(url, | 111 net::AppendFormattedHost(url, |
| 107 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &display_host); | 112 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &display_host); |
| 108 return UTF16ToUTF8(display_host); | 113 return UTF16ToUTF8(display_host); |
| 109 } | 114 } |
| OLD | NEW |