| 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 "chrome/browser/geolocation/geolocation_permission_context.h" | 5 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 ConfirmInfoBarDelegate* infobar_delegate_0 = | 297 ConfirmInfoBarDelegate* infobar_delegate_0 = |
| 298 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); | 298 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); |
| 299 ASSERT_TRUE(infobar_delegate_0); | 299 ASSERT_TRUE(infobar_delegate_0); |
| 300 base::string16 text_0 = infobar_delegate_0->GetButtonLabel( | 300 base::string16 text_0 = infobar_delegate_0->GetButtonLabel( |
| 301 ConfirmInfoBarDelegate::BUTTON_OK); | 301 ConfirmInfoBarDelegate::BUTTON_OK); |
| 302 | 302 |
| 303 Reload(); | 303 Reload(); |
| 304 MockGoogleLocationSettingsHelper::SetLocationStatus(true, false); | 304 MockGoogleLocationSettingsHelper::SetLocationStatus(true, false); |
| 305 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 305 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 306 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); | 306 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); |
| 307 EXPECT_EQ(1U, infobar_service()->infobar_count()); | |
| 308 ConfirmInfoBarDelegate* infobar_delegate_1 = | |
| 309 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); | |
| 310 ASSERT_TRUE(infobar_delegate_1); | |
| 311 base::string16 text_1 = infobar_delegate_1->GetButtonLabel( | |
| 312 ConfirmInfoBarDelegate::BUTTON_OK); | |
| 313 EXPECT_NE(text_0, text_1); | |
| 314 | |
| 315 Reload(); | |
| 316 MockGoogleLocationSettingsHelper::SetLocationStatus(false, false); | |
| 317 EXPECT_EQ(0U, infobar_service()->infobar_count()); | |
| 318 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); | |
| 319 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 307 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 320 } | 308 } |
| 321 | 309 |
| 322 TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsEnabled) { | 310 TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsEnabled) { |
| 323 GURL requesting_frame("http://www.example.com/geolocation"); | 311 GURL requesting_frame("http://www.example.com/geolocation"); |
| 324 NavigateAndCommit(requesting_frame); | 312 NavigateAndCommit(requesting_frame); |
| 325 MockGoogleLocationSettingsHelper::SetLocationStatus(true, true); | 313 MockGoogleLocationSettingsHelper::SetLocationStatus(true, true); |
| 326 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 314 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 327 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); | 315 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); |
| 328 EXPECT_EQ(1U, infobar_service()->infobar_count()); | 316 EXPECT_EQ(1U, infobar_service()->infobar_count()); |
| 329 ConfirmInfoBarDelegate* infobar_delegate = | 317 ConfirmInfoBarDelegate* infobar_delegate = |
| 330 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); | 318 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); |
| 331 ASSERT_TRUE(infobar_delegate); | 319 ASSERT_TRUE(infobar_delegate); |
| 332 infobar_delegate->Accept(); | 320 infobar_delegate->Accept(); |
| 333 CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); | 321 CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); |
| 334 CheckPermissionMessageSent(0, true); | 322 CheckPermissionMessageSent(0, true); |
| 335 } | 323 } |
| 336 | 324 |
| 337 TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsDisabled) { | 325 TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsDisabled) { |
| 338 GURL requesting_frame("http://www.example.com/geolocation"); | 326 GURL requesting_frame("http://www.example.com/geolocation"); |
| 339 NavigateAndCommit(requesting_frame); | 327 NavigateAndCommit(requesting_frame); |
| 340 MockGoogleLocationSettingsHelper::SetLocationStatus(true, false); | 328 MockGoogleLocationSettingsHelper::SetLocationStatus(true, false); |
| 341 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 329 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 342 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); | 330 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); |
| 343 EXPECT_EQ(1U, infobar_service()->infobar_count()); | 331 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 344 ConfirmInfoBarDelegate* infobar_delegate = | |
| 345 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); | |
| 346 ASSERT_TRUE(infobar_delegate); | |
| 347 infobar_delegate->Accept(); | |
| 348 EXPECT_TRUE( | |
| 349 MockGoogleLocationSettingsHelper::WasGoogleLocationSettingsCalled()); | |
| 350 } | 332 } |
| 351 #endif | 333 #endif |
| 352 | 334 |
| 353 TEST_F(GeolocationPermissionContextTests, QueuedPermission) { | 335 TEST_F(GeolocationPermissionContextTests, QueuedPermission) { |
| 354 GURL requesting_frame_0("http://www.example.com/geolocation"); | 336 GURL requesting_frame_0("http://www.example.com/geolocation"); |
| 355 GURL requesting_frame_1("http://www.example-2.com/geolocation"); | 337 GURL requesting_frame_1("http://www.example-2.com/geolocation"); |
| 356 EXPECT_EQ(CONTENT_SETTING_ASK, | 338 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 357 profile()->GetHostContentSettingsMap()->GetContentSetting( | 339 profile()->GetHostContentSettingsMap()->GetContentSetting( |
| 358 requesting_frame_0, requesting_frame_0, | 340 requesting_frame_0, requesting_frame_0, |
| 359 CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); | 341 CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 // it is the embedder. | 815 // it is the embedder. |
| 834 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 816 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
| 835 requesting_frame_0.GetOrigin(), | 817 requesting_frame_0.GetOrigin(), |
| 836 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 818 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 837 13); | 819 13); |
| 838 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 820 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
| 839 requesting_frame_0.GetOrigin(), | 821 requesting_frame_0.GetOrigin(), |
| 840 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 822 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 841 11); | 823 11); |
| 842 } | 824 } |
| OLD | NEW |