OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { | 224 void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { |
225 content::WebContents* new_tab = content::WebContents::Create( | 225 content::WebContents* new_tab = content::WebContents::Create( |
226 content::WebContents::CreateParams(profile())); | 226 content::WebContents::CreateParams(profile())); |
227 new_tab->GetController().LoadURL( | 227 new_tab->GetController().LoadURL( |
228 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 228 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
229 content::RenderViewHostTester::For(new_tab->GetRenderViewHost())-> | 229 content::RenderViewHostTester::For(new_tab->GetRenderViewHost())-> |
230 SendNavigate(extra_tabs_.size() + 1, url); | 230 SendNavigate(extra_tabs_.size() + 1, url); |
231 | 231 |
232 // Set up required helpers, and make this be as "tabby" as the code requires. | 232 // Set up required helpers, and make this be as "tabby" as the code requires. |
233 chrome::SetViewType(new_tab, chrome::VIEW_TYPE_TAB_CONTENTS); | 233 chrome::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS); |
234 InfoBarService::CreateForWebContents(new_tab); | 234 InfoBarService::CreateForWebContents(new_tab); |
235 | 235 |
236 extra_tabs_.push_back(new_tab); | 236 extra_tabs_.push_back(new_tab); |
237 } | 237 } |
238 | 238 |
239 void GeolocationPermissionContextTests::CheckTabContentsState( | 239 void GeolocationPermissionContextTests::CheckTabContentsState( |
240 const GURL& requesting_frame, | 240 const GURL& requesting_frame, |
241 ContentSetting expected_content_setting) { | 241 ContentSetting expected_content_setting) { |
242 TabSpecificContentSettings* content_settings = | 242 TabSpecificContentSettings* content_settings = |
243 TabSpecificContentSettings::FromWebContents(web_contents()); | 243 TabSpecificContentSettings::FromWebContents(web_contents()); |
244 const GeolocationSettingsState::StateMap& state_map = | 244 const GeolocationSettingsState::StateMap& state_map = |
245 content_settings->geolocation_settings_state().state_map(); | 245 content_settings->geolocation_settings_state().state_map(); |
246 EXPECT_EQ(1U, state_map.count(requesting_frame.GetOrigin())); | 246 EXPECT_EQ(1U, state_map.count(requesting_frame.GetOrigin())); |
247 EXPECT_EQ(0U, state_map.count(requesting_frame)); | 247 EXPECT_EQ(0U, state_map.count(requesting_frame)); |
248 GeolocationSettingsState::StateMap::const_iterator settings = | 248 GeolocationSettingsState::StateMap::const_iterator settings = |
249 state_map.find(requesting_frame.GetOrigin()); | 249 state_map.find(requesting_frame.GetOrigin()); |
250 ASSERT_FALSE(settings == state_map.end()) | 250 ASSERT_FALSE(settings == state_map.end()) |
251 << "geolocation state not found " << requesting_frame; | 251 << "geolocation state not found " << requesting_frame; |
252 EXPECT_EQ(expected_content_setting, settings->second); | 252 EXPECT_EQ(expected_content_setting, settings->second); |
253 } | 253 } |
254 | 254 |
255 void GeolocationPermissionContextTests::SetUp() { | 255 void GeolocationPermissionContextTests::SetUp() { |
256 db_thread_.Start(); | 256 db_thread_.Start(); |
257 ChromeRenderViewHostTestHarness::SetUp(); | 257 ChromeRenderViewHostTestHarness::SetUp(); |
258 | 258 |
259 // Set up required helpers, and make this be as "tabby" as the code requires. | 259 // Set up required helpers, and make this be as "tabby" as the code requires. |
260 chrome::SetViewType(web_contents(), chrome::VIEW_TYPE_TAB_CONTENTS); | 260 chrome::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS); |
261 InfoBarService::CreateForWebContents(web_contents()); | 261 InfoBarService::CreateForWebContents(web_contents()); |
262 TabSpecificContentSettings::CreateForWebContents(web_contents()); | 262 TabSpecificContentSettings::CreateForWebContents(web_contents()); |
263 #if defined(OS_ANDROID) | 263 #if defined(OS_ANDROID) |
264 MockGoogleLocationSettingsHelper::SetLocationStatus(true, true); | 264 MockGoogleLocationSettingsHelper::SetLocationStatus(true, true); |
265 #endif | 265 #endif |
266 geolocation_permission_context_ = | 266 geolocation_permission_context_ = |
267 ChromeGeolocationPermissionContextFactory::GetForProfile(profile()); | 267 ChromeGeolocationPermissionContextFactory::GetForProfile(profile()); |
268 } | 268 } |
269 | 269 |
270 void GeolocationPermissionContextTests::TearDown() { | 270 void GeolocationPermissionContextTests::TearDown() { |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 details.entry = web_contents()->GetController().GetLastCommittedEntry(); | 700 details.entry = web_contents()->GetController().GetLastCommittedEntry(); |
701 EXPECT_FALSE(infobar_0->ShouldExpire(details)); | 701 EXPECT_FALSE(infobar_0->ShouldExpire(details)); |
702 // Ensure the infobar will expire when we commit the pending navigation. | 702 // Ensure the infobar will expire when we commit the pending navigation. |
703 details.entry = web_contents()->GetController().GetActiveEntry(); | 703 details.entry = web_contents()->GetController().GetActiveEntry(); |
704 EXPECT_TRUE(infobar_0->ShouldExpire(details)); | 704 EXPECT_TRUE(infobar_0->ShouldExpire(details)); |
705 | 705 |
706 // Delete the tab contents. | 706 // Delete the tab contents. |
707 DeleteContents(); | 707 DeleteContents(); |
708 delete infobar_0; | 708 delete infobar_0; |
709 } | 709 } |
OLD | NEW |