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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc

Issue 7484072: Migrate geolocation settings to host content settings map. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 4 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 "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "chrome/browser/content_settings/host_content_settings_map.h" 7 #include "chrome/browser/content_settings/host_content_settings_map.h"
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/geolocation/geolocation_content_settings_map.h"
11 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
13 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" 12 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
14 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
15 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
16 #include "content/browser/browser_thread.h" 15 #include "content/browser/browser_thread.h"
17 #include "content/browser/tab_contents/test_tab_contents.h" 16 #include "content/browser/tab_contents/test_tab_contents.h"
18 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
19 18
20 class ContentSettingBubbleModelTest : public TabContentsWrapperTestHarness { 19 class ContentSettingBubbleModelTest : public TabContentsWrapperTestHarness {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 176
178 NavigateAndCommit(page_url); 177 NavigateAndCommit(page_url);
179 TabSpecificContentSettings* content_settings = 178 TabSpecificContentSettings* content_settings =
180 contents_wrapper()->content_settings(); 179 contents_wrapper()->content_settings();
181 180
182 // One permitted frame, but not in the content map: requires reload. 181 // One permitted frame, but not in the content map: requires reload.
183 content_settings->OnGeolocationPermissionSet(frame1_url, true); 182 content_settings->OnGeolocationPermissionSet(frame1_url, true);
184 CheckGeolocationBubble(1, false, true); 183 CheckGeolocationBubble(1, false, true);
185 184
186 // Add it to the content map, should now have a clear link. 185 // Add it to the content map, should now have a clear link.
187 GeolocationContentSettingsMap* setting_map = 186 HostContentSettingsMap* setting_map =
188 profile_->GetGeolocationContentSettingsMap(); 187 profile_->GetHostContentSettingsMap();
189 setting_map->SetContentSetting(frame1_url, page_url, CONTENT_SETTING_ALLOW); 188 setting_map->SetContentSetting(
189 ContentSettingsPattern::FromURLNoWildcard(frame1_url),
190 ContentSettingsPattern::FromURLNoWildcard(page_url),
191 CONTENT_SETTINGS_TYPE_GEOLOCATION,
192 std::string(),
193 CONTENT_SETTING_ALLOW);
190 CheckGeolocationBubble(1, true, false); 194 CheckGeolocationBubble(1, true, false);
191 195
192 // Change the default to allow: no message needed. 196 // Change the default to allow: no message needed.
193 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( 197 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting(
194 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW); 198 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW);
195 CheckGeolocationBubble(1, false, false); 199 CheckGeolocationBubble(1, false, false);
196 200
197 // Second frame denied, but not stored in the content map: requires reload. 201 // Second frame denied, but not stored in the content map: requires reload.
198 content_settings->OnGeolocationPermissionSet(frame2_url, false); 202 content_settings->OnGeolocationPermissionSet(frame2_url, false);
199 CheckGeolocationBubble(2, false, true); 203 CheckGeolocationBubble(2, false, true);
200 204
201 // Change the default to block: offer a clear link for the persisted frame 1. 205 // Change the default to block: offer a clear link for the persisted frame 1.
202 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( 206 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting(
203 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_BLOCK); 207 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_BLOCK);
204 CheckGeolocationBubble(2, true, false); 208 CheckGeolocationBubble(2, true, false);
205 } 209 }
206 210
207 TEST_F(ContentSettingBubbleModelTest, FileURL) { 211 TEST_F(ContentSettingBubbleModelTest, FileURL) {
208 std::string file_url("file:///tmp/test.html"); 212 std::string file_url("file:///tmp/test.html");
209 NavigateAndCommit(GURL(file_url)); 213 NavigateAndCommit(GURL(file_url));
210 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( 214 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
211 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 215 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
212 NULL, contents_wrapper(), profile_.get(), 216 NULL, contents_wrapper(), profile_.get(),
213 CONTENT_SETTINGS_TYPE_IMAGES)); 217 CONTENT_SETTINGS_TYPE_IMAGES));
214 std::string title = 218 std::string title =
215 content_setting_bubble_model->bubble_content().radio_group.radio_items[0]; 219 content_setting_bubble_model->bubble_content().radio_group.radio_items[0];
216 ASSERT_NE(std::string::npos, title.find(file_url)); 220 ASSERT_NE(std::string::npos, title.find(file_url));
217 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698