| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/content_settings/core/browser/content_settings_usages_state
.h" | 5 #include "components/content_settings/core/browser/content_settings_usages_state
.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 class ContentSettingsUsagesStateTests : public testing::Test { | 29 class ContentSettingsUsagesStateTests : public testing::Test { |
| 30 public: | 30 public: |
| 31 ContentSettingsUsagesStateTests() | 31 ContentSettingsUsagesStateTests() |
| 32 : ui_thread_(BrowserThread::UI, &message_loop_) { | 32 : ui_thread_(BrowserThread::UI, &message_loop_) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 void ClearOnNewOrigin(ContentSettingsType type) { | 36 void ClearOnNewOrigin(ContentSettingsType type) { |
| 37 TestingProfile profile; | 37 TestingProfile profile; |
| 38 ContentSettingsUsagesState state( | 38 ContentSettingsUsagesState state( |
| 39 HostContentSettingsMapFactory::GetForProfile(&profile), | 39 HostContentSettingsMapFactory::GetForProfile(&profile), type); |
| 40 type, | |
| 41 prefs::kAcceptLanguages, | |
| 42 profile.GetPrefs()); | |
| 43 GURL url_0("http://www.example.com"); | 40 GURL url_0("http://www.example.com"); |
| 44 | 41 |
| 45 ContentSettingsUsagesState::CommittedDetails details = | 42 ContentSettingsUsagesState::CommittedDetails details = |
| 46 CreateDetailsWithURL(url_0); | 43 CreateDetailsWithURL(url_0); |
| 47 state.DidNavigate(details); | 44 state.DidNavigate(details); |
| 48 | 45 |
| 49 HostContentSettingsMapFactory::GetForProfile(&profile) | 46 HostContentSettingsMapFactory::GetForProfile(&profile) |
| 50 ->SetContentSettingDefaultScope(url_0, url_0, type, std::string(), | 47 ->SetContentSettingDefaultScope(url_0, url_0, type, std::string(), |
| 51 CONTENT_SETTING_ALLOW); | 48 CONTENT_SETTING_ALLOW); |
| 52 state.OnPermissionSet(url_0, true); | 49 state.OnPermissionSet(url_0, true); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 formatted_host_per_state.clear(); | 126 formatted_host_per_state.clear(); |
| 130 tab_state_flags = 0; | 127 tab_state_flags = 0; |
| 131 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); | 128 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); |
| 132 EXPECT_TRUE(formatted_host_per_state.empty()); | 129 EXPECT_TRUE(formatted_host_per_state.empty()); |
| 133 EXPECT_EQ(0U, tab_state_flags); | 130 EXPECT_EQ(0U, tab_state_flags); |
| 134 } | 131 } |
| 135 | 132 |
| 136 void ShowPortOnSameHost(ContentSettingsType type) { | 133 void ShowPortOnSameHost(ContentSettingsType type) { |
| 137 TestingProfile profile; | 134 TestingProfile profile; |
| 138 ContentSettingsUsagesState state( | 135 ContentSettingsUsagesState state( |
| 139 HostContentSettingsMapFactory::GetForProfile(&profile), | 136 HostContentSettingsMapFactory::GetForProfile(&profile), type); |
| 140 type, | |
| 141 prefs::kAcceptLanguages, | |
| 142 profile.GetPrefs()); | |
| 143 GURL url_0("http://www.example.com"); | 137 GURL url_0("http://www.example.com"); |
| 144 | 138 |
| 145 ContentSettingsUsagesState::CommittedDetails details = | 139 ContentSettingsUsagesState::CommittedDetails details = |
| 146 CreateDetailsWithURL(url_0); | 140 CreateDetailsWithURL(url_0); |
| 147 state.DidNavigate(details); | 141 state.DidNavigate(details); |
| 148 | 142 |
| 149 HostContentSettingsMapFactory::GetForProfile(&profile) | 143 HostContentSettingsMapFactory::GetForProfile(&profile) |
| 150 ->SetContentSettingDefaultScope(url_0, url_0, type, std::string(), | 144 ->SetContentSettingDefaultScope(url_0, url_0, type, std::string(), |
| 151 CONTENT_SETTING_ALLOW); | 145 CONTENT_SETTING_ALLOW); |
| 152 state.OnPermissionSet(url_0, true); | 146 state.OnPermissionSet(url_0, true); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 209 |
| 216 TEST_F(ContentSettingsUsagesStateTests, ShowPortOnSameHostForGeolocation) { | 210 TEST_F(ContentSettingsUsagesStateTests, ShowPortOnSameHostForGeolocation) { |
| 217 ShowPortOnSameHost(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 211 ShowPortOnSameHost(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 218 } | 212 } |
| 219 | 213 |
| 220 TEST_F(ContentSettingsUsagesStateTests, ShowPortOnSameHostForMidi) { | 214 TEST_F(ContentSettingsUsagesStateTests, ShowPortOnSameHostForMidi) { |
| 221 ShowPortOnSameHost(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); | 215 ShowPortOnSameHost(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
| 222 } | 216 } |
| 223 | 217 |
| 224 } // namespace | 218 } // namespace |
| OLD | NEW |