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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); | 283 ASSERT_EQ(1U, infobar_tab_helper()->GetInfoBarCount()); |
284 ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> | 284 ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> |
285 GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 285 GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
286 infobar_0->Cancel(); | 286 infobar_0->Cancel(); |
287 infobar_tab_helper()->RemoveInfoBar(infobar_0); | 287 infobar_tab_helper()->RemoveInfoBar(infobar_0); |
288 EXPECT_EQ(1U, closed_delegate_tracker_.size()); | 288 EXPECT_EQ(1U, closed_delegate_tracker_.size()); |
289 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); | 289 EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0)); |
290 infobar_0->InfoBarClosed(); | 290 infobar_0->InfoBarClosed(); |
291 } | 291 } |
292 | 292 |
293 #if defined(OS_ANDROID) | |
294 TEST_F(GeolocationPermissionContextTests, GeolocationEnabledDisabled) { | |
295 profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | |
296 CONTENT_SETTINGS_TYPE_GEOLOCATION, | |
297 CONTENT_SETTING_ALLOW); | |
298 | |
299 // Check that the request is denied with preference disabled, | |
300 // even though the default policy allows it. | |
301 GURL requesting_frame("http://www.example.com/geolocation"); | |
302 NavigateAndCommit(requesting_frame); | |
303 EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); | |
304 profile()->GetPrefs()->SetBoolean(prefs::kGeolocationEnabled, false); | |
305 RequestGeolocationPermission( | |
306 process_id(), render_id(), bridge_id(), requesting_frame); | |
307 ASSERT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); | |
308 CheckPermissionMessageSent(bridge_id(), false); | |
309 | |
310 // Reenable the preference and check that the request now goes though. | |
311 profile()->GetPrefs()->SetBoolean(prefs::kGeolocationEnabled, true); | |
312 RequestGeolocationPermission( | |
313 process_id(), render_id(), bridge_id() + 1, requesting_frame); | |
314 ASSERT_EQ(0U, infobar_tab_helper()->GetInfoBarCount()); | |
315 CheckPermissionMessageSent(bridge_id() + 1, true); | |
316 } | |
317 #endif | |
318 | |
319 TEST_F(GeolocationPermissionContextTests, QueuedPermission) { | 293 TEST_F(GeolocationPermissionContextTests, QueuedPermission) { |
320 GURL requesting_frame_0("http://www.example.com/geolocation"); | 294 GURL requesting_frame_0("http://www.example.com/geolocation"); |
321 GURL requesting_frame_1("http://www.example-2.com/geolocation"); | 295 GURL requesting_frame_1("http://www.example-2.com/geolocation"); |
322 EXPECT_EQ(CONTENT_SETTING_ASK, | 296 EXPECT_EQ(CONTENT_SETTING_ASK, |
323 profile()->GetHostContentSettingsMap()->GetContentSetting( | 297 profile()->GetHostContentSettingsMap()->GetContentSetting( |
324 requesting_frame_0, | 298 requesting_frame_0, |
325 requesting_frame_0, | 299 requesting_frame_0, |
326 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 300 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
327 std::string())); | 301 std::string())); |
328 EXPECT_EQ(CONTENT_SETTING_ASK, | 302 EXPECT_EQ(CONTENT_SETTING_ASK, |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 ASSERT_FALSE(infobar_0->ShouldExpire(details)); | 625 ASSERT_FALSE(infobar_0->ShouldExpire(details)); |
652 // Commit the "GoBack()" above, and ensure the infobar is now expired. | 626 // Commit the "GoBack()" above, and ensure the infobar is now expired. |
653 WebContentsTester::For(web_contents())->CommitPendingNavigation(); | 627 WebContentsTester::For(web_contents())->CommitPendingNavigation(); |
654 details.entry = web_contents()->GetController().GetLastCommittedEntry(); | 628 details.entry = web_contents()->GetController().GetLastCommittedEntry(); |
655 ASSERT_TRUE(infobar_0->ShouldExpire(details)); | 629 ASSERT_TRUE(infobar_0->ShouldExpire(details)); |
656 | 630 |
657 // Delete the tab contents. | 631 // Delete the tab contents. |
658 DeleteContents(); | 632 DeleteContents(); |
659 infobar_0->InfoBarClosed(); | 633 infobar_0->InfoBarClosed(); |
660 } | 634 } |
OLD | NEW |