| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 9 #include "chrome/browser/geolocation/geolocation_settings_state.h" | 9 #include "chrome/browser/geolocation/geolocation_settings_state.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 TestingProfile profile; | 34 TestingProfile profile; |
| 35 GeolocationSettingsState state(&profile); | 35 GeolocationSettingsState state(&profile); |
| 36 GURL url_0("http://www.example.com"); | 36 GURL url_0("http://www.example.com"); |
| 37 | 37 |
| 38 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 38 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
| 39 entry->SetURL(url_0); | 39 entry->SetURL(url_0); |
| 40 content::LoadCommittedDetails load_committed_details; | 40 content::LoadCommittedDetails load_committed_details; |
| 41 load_committed_details.entry = entry.get(); | 41 load_committed_details.entry = entry.get(); |
| 42 state.DidNavigate(load_committed_details); | 42 state.DidNavigate(load_committed_details); |
| 43 | 43 |
| 44 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( | 44 HostContentSettingsMapFactory::GetForProfile(profile) |
| 45 ContentSettingsPattern::FromURLNoWildcard(url_0), | 45 ->SetContentSettingDefaultScope(url_0, url_0, |
| 46 ContentSettingsPattern::FromURLNoWildcard(url_0), | 46 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 47 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 47 std::string(), CONTENT_SETTING_ALLOW); |
| 48 std::string(), | |
| 49 CONTENT_SETTING_ALLOW); | |
| 50 state.OnGeolocationPermissionSet(url_0, true); | 48 state.OnGeolocationPermissionSet(url_0, true); |
| 51 | 49 |
| 52 GURL url_1("http://www.example1.com"); | 50 GURL url_1("http://www.example1.com"); |
| 53 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( | 51 HostContentSettingsMapFactory::GetForProfile(profile) |
| 54 ContentSettingsPattern::FromURLNoWildcard(url_1), | 52 ->SetContentSettingDefaultScope(url_1, url_0, |
| 55 ContentSettingsPattern::FromURLNoWildcard(url_0), | 53 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 56 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 54 std::string(), CONTENT_SETTING_BLOCK); |
| 57 std::string(), | |
| 58 CONTENT_SETTING_BLOCK); | |
| 59 state.OnGeolocationPermissionSet(url_1, false); | 55 state.OnGeolocationPermissionSet(url_1, false); |
| 60 | 56 |
| 61 GeolocationSettingsState::StateMap state_map = | 57 GeolocationSettingsState::StateMap state_map = |
| 62 state.state_map(); | 58 state.state_map(); |
| 63 EXPECT_EQ(2U, state_map.size()); | 59 EXPECT_EQ(2U, state_map.size()); |
| 64 | 60 |
| 65 GeolocationSettingsState::FormattedHostsPerState formatted_host_per_state; | 61 GeolocationSettingsState::FormattedHostsPerState formatted_host_per_state; |
| 66 unsigned int tab_state_flags = 0; | 62 unsigned int tab_state_flags = 0; |
| 67 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); | 63 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); |
| 68 EXPECT_TRUE(tab_state_flags & | 64 EXPECT_TRUE(tab_state_flags & |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 TestingProfile profile; | 135 TestingProfile profile; |
| 140 GeolocationSettingsState state(&profile); | 136 GeolocationSettingsState state(&profile); |
| 141 GURL url_0("http://www.example.com"); | 137 GURL url_0("http://www.example.com"); |
| 142 | 138 |
| 143 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 139 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
| 144 entry->SetURL(url_0); | 140 entry->SetURL(url_0); |
| 145 content::LoadCommittedDetails load_committed_details; | 141 content::LoadCommittedDetails load_committed_details; |
| 146 load_committed_details.entry = entry.get(); | 142 load_committed_details.entry = entry.get(); |
| 147 state.DidNavigate(load_committed_details); | 143 state.DidNavigate(load_committed_details); |
| 148 | 144 |
| 149 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( | 145 HostContentSettingsMapFactory::GetForProfile(profile) |
| 150 ContentSettingsPattern::FromURLNoWildcard(url_0), | 146 ->SetContentSettingDefaultScope(url_0, url_0, |
| 151 ContentSettingsPattern::FromURLNoWildcard(url_0), | 147 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 152 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 148 std::string(), CONTENT_SETTING_ALLOW); |
| 153 std::string(), | |
| 154 CONTENT_SETTING_ALLOW); | |
| 155 state.OnGeolocationPermissionSet(url_0, true); | 149 state.OnGeolocationPermissionSet(url_0, true); |
| 156 | 150 |
| 157 GURL url_1("https://www.example.com"); | 151 GURL url_1("https://www.example.com"); |
| 158 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( | 152 HostContentSettingsMapFactory::GetForProfile(profile) |
| 159 ContentSettingsPattern::FromURLNoWildcard(url_1), | 153 ->SetContentSettingDefaultScope(url_1, url_0, |
| 160 ContentSettingsPattern::FromURLNoWildcard(url_0), | 154 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 161 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 155 std::string(), CONTENT_SETTING_ALLOW); |
| 162 std::string(), | |
| 163 CONTENT_SETTING_ALLOW); | |
| 164 state.OnGeolocationPermissionSet(url_1, true); | 156 state.OnGeolocationPermissionSet(url_1, true); |
| 165 | 157 |
| 166 GURL url_2("http://www.example1.com"); | 158 GURL url_2("http://www.example1.com"); |
| 167 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( | 159 HostContentSettingsMapFactory::GetForProfile(profile) |
| 168 ContentSettingsPattern::FromURLNoWildcard(url_2), | 160 ->SetContentSettingDefaultScope(url_2, url_0, |
| 169 ContentSettingsPattern::FromURLNoWildcard(url_0), | 161 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 170 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 162 std::string(), CONTENT_SETTING_ALLOW); |
| 171 std::string(), | |
| 172 CONTENT_SETTING_ALLOW); | |
| 173 state.OnGeolocationPermissionSet(url_2, true); | 163 state.OnGeolocationPermissionSet(url_2, true); |
| 174 | 164 |
| 175 GeolocationSettingsState::StateMap state_map = | 165 GeolocationSettingsState::StateMap state_map = |
| 176 state.state_map(); | 166 state.state_map(); |
| 177 EXPECT_EQ(3U, state_map.size()); | 167 EXPECT_EQ(3U, state_map.size()); |
| 178 | 168 |
| 179 GeolocationSettingsState::FormattedHostsPerState formatted_host_per_state; | 169 GeolocationSettingsState::FormattedHostsPerState formatted_host_per_state; |
| 180 unsigned int tab_state_flags = 0; | 170 unsigned int tab_state_flags = 0; |
| 181 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); | 171 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); |
| 182 | 172 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 204 formatted_host_per_state[CONTENT_SETTING_ALLOW].count( | 194 formatted_host_per_state[CONTENT_SETTING_ALLOW].count( |
| 205 url_2.host())); | 195 url_2.host())); |
| 206 EXPECT_EQ(1U, formatted_host_per_state[CONTENT_SETTING_BLOCK].size()); | 196 EXPECT_EQ(1U, formatted_host_per_state[CONTENT_SETTING_BLOCK].size()); |
| 207 EXPECT_EQ(1U, | 197 EXPECT_EQ(1U, |
| 208 formatted_host_per_state[CONTENT_SETTING_BLOCK].count( | 198 formatted_host_per_state[CONTENT_SETTING_BLOCK].count( |
| 209 url_1.spec())); | 199 url_1.spec())); |
| 210 } | 200 } |
| 211 | 201 |
| 212 | 202 |
| 213 } // namespace | 203 } // namespace |
| OLD | NEW |