Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/geolocation/geolocation_settings_state.cc

Issue 7328018: Migrate default geolocation content setting to host content settings map. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698