| 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/geolocation/geolocation_settings_state.h" | 9 #include "chrome/browser/geolocation/geolocation_settings_state.h" |
| 9 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 10 #include "components/content_settings/core/browser/host_content_settings_map.h" | 11 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 11 #include "content/public/browser/navigation_details.h" | 12 #include "content/public/browser/navigation_details.h" |
| 12 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
| 13 #include "content/public/test/test_browser_thread.h" | 14 #include "content/public/test/test_browser_thread.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 using content::BrowserThread; | 17 using content::BrowserThread; |
| 17 using content::NavigationEntry; | 18 using content::NavigationEntry; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 33 TestingProfile profile; | 34 TestingProfile profile; |
| 34 GeolocationSettingsState state(&profile); | 35 GeolocationSettingsState state(&profile); |
| 35 GURL url_0("http://www.example.com"); | 36 GURL url_0("http://www.example.com"); |
| 36 | 37 |
| 37 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 38 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
| 38 entry->SetURL(url_0); | 39 entry->SetURL(url_0); |
| 39 content::LoadCommittedDetails load_committed_details; | 40 content::LoadCommittedDetails load_committed_details; |
| 40 load_committed_details.entry = entry.get(); | 41 load_committed_details.entry = entry.get(); |
| 41 state.DidNavigate(load_committed_details); | 42 state.DidNavigate(load_committed_details); |
| 42 | 43 |
| 43 profile.GetHostContentSettingsMap()->SetContentSetting( | 44 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( |
| 44 ContentSettingsPattern::FromURLNoWildcard(url_0), | 45 ContentSettingsPattern::FromURLNoWildcard(url_0), |
| 45 ContentSettingsPattern::FromURLNoWildcard(url_0), | 46 ContentSettingsPattern::FromURLNoWildcard(url_0), |
| 46 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 47 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 47 std::string(), | 48 std::string(), |
| 48 CONTENT_SETTING_ALLOW); | 49 CONTENT_SETTING_ALLOW); |
| 49 state.OnGeolocationPermissionSet(url_0, true); | 50 state.OnGeolocationPermissionSet(url_0, true); |
| 50 | 51 |
| 51 GURL url_1("http://www.example1.com"); | 52 GURL url_1("http://www.example1.com"); |
| 52 profile.GetHostContentSettingsMap()->SetContentSetting( | 53 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( |
| 53 ContentSettingsPattern::FromURLNoWildcard(url_1), | 54 ContentSettingsPattern::FromURLNoWildcard(url_1), |
| 54 ContentSettingsPattern::FromURLNoWildcard(url_0), | 55 ContentSettingsPattern::FromURLNoWildcard(url_0), |
| 55 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 56 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 56 std::string(), | 57 std::string(), |
| 57 CONTENT_SETTING_BLOCK); | 58 CONTENT_SETTING_BLOCK); |
| 58 state.OnGeolocationPermissionSet(url_1, false); | 59 state.OnGeolocationPermissionSet(url_1, false); |
| 59 | 60 |
| 60 GeolocationSettingsState::StateMap state_map = | 61 GeolocationSettingsState::StateMap state_map = |
| 61 state.state_map(); | 62 state.state_map(); |
| 62 EXPECT_EQ(2U, state_map.size()); | 63 EXPECT_EQ(2U, state_map.size()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 TestingProfile profile; | 139 TestingProfile profile; |
| 139 GeolocationSettingsState state(&profile); | 140 GeolocationSettingsState state(&profile); |
| 140 GURL url_0("http://www.example.com"); | 141 GURL url_0("http://www.example.com"); |
| 141 | 142 |
| 142 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 143 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
| 143 entry->SetURL(url_0); | 144 entry->SetURL(url_0); |
| 144 content::LoadCommittedDetails load_committed_details; | 145 content::LoadCommittedDetails load_committed_details; |
| 145 load_committed_details.entry = entry.get(); | 146 load_committed_details.entry = entry.get(); |
| 146 state.DidNavigate(load_committed_details); | 147 state.DidNavigate(load_committed_details); |
| 147 | 148 |
| 148 profile.GetHostContentSettingsMap()->SetContentSetting( | 149 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( |
| 149 ContentSettingsPattern::FromURLNoWildcard(url_0), | 150 ContentSettingsPattern::FromURLNoWildcard(url_0), |
| 150 ContentSettingsPattern::FromURLNoWildcard(url_0), | 151 ContentSettingsPattern::FromURLNoWildcard(url_0), |
| 151 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 152 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 152 std::string(), | 153 std::string(), |
| 153 CONTENT_SETTING_ALLOW); | 154 CONTENT_SETTING_ALLOW); |
| 154 state.OnGeolocationPermissionSet(url_0, true); | 155 state.OnGeolocationPermissionSet(url_0, true); |
| 155 | 156 |
| 156 GURL url_1("https://www.example.com"); | 157 GURL url_1("https://www.example.com"); |
| 157 profile.GetHostContentSettingsMap()->SetContentSetting( | 158 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( |
| 158 ContentSettingsPattern::FromURLNoWildcard(url_1), | 159 ContentSettingsPattern::FromURLNoWildcard(url_1), |
| 159 ContentSettingsPattern::FromURLNoWildcard(url_0), | 160 ContentSettingsPattern::FromURLNoWildcard(url_0), |
| 160 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 161 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 161 std::string(), | 162 std::string(), |
| 162 CONTENT_SETTING_ALLOW); | 163 CONTENT_SETTING_ALLOW); |
| 163 state.OnGeolocationPermissionSet(url_1, true); | 164 state.OnGeolocationPermissionSet(url_1, true); |
| 164 | 165 |
| 165 GURL url_2("http://www.example1.com"); | 166 GURL url_2("http://www.example1.com"); |
| 166 profile.GetHostContentSettingsMap()->SetContentSetting( | 167 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( |
| 167 ContentSettingsPattern::FromURLNoWildcard(url_2), | 168 ContentSettingsPattern::FromURLNoWildcard(url_2), |
| 168 ContentSettingsPattern::FromURLNoWildcard(url_0), | 169 ContentSettingsPattern::FromURLNoWildcard(url_0), |
| 169 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 170 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 170 std::string(), | 171 std::string(), |
| 171 CONTENT_SETTING_ALLOW); | 172 CONTENT_SETTING_ALLOW); |
| 172 state.OnGeolocationPermissionSet(url_2, true); | 173 state.OnGeolocationPermissionSet(url_2, true); |
| 173 | 174 |
| 174 GeolocationSettingsState::StateMap state_map = | 175 GeolocationSettingsState::StateMap state_map = |
| 175 state.state_map(); | 176 state.state_map(); |
| 176 EXPECT_EQ(3U, state_map.size()); | 177 EXPECT_EQ(3U, state_map.size()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 203 formatted_host_per_state[CONTENT_SETTING_ALLOW].count( | 204 formatted_host_per_state[CONTENT_SETTING_ALLOW].count( |
| 204 url_2.host())); | 205 url_2.host())); |
| 205 EXPECT_EQ(1U, formatted_host_per_state[CONTENT_SETTING_BLOCK].size()); | 206 EXPECT_EQ(1U, formatted_host_per_state[CONTENT_SETTING_BLOCK].size()); |
| 206 EXPECT_EQ(1U, | 207 EXPECT_EQ(1U, |
| 207 formatted_host_per_state[CONTENT_SETTING_BLOCK].count( | 208 formatted_host_per_state[CONTENT_SETTING_BLOCK].count( |
| 208 url_1.spec())); | 209 url_1.spec())); |
| 209 } | 210 } |
| 210 | 211 |
| 211 | 212 |
| 212 } // namespace | 213 } // namespace |
| OLD | NEW |