| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "content/public/test/test_renderer_host.h" | 48 #include "content/public/test/test_renderer_host.h" |
| 49 #include "content/public/test/test_utils.h" | 49 #include "content/public/test/test_utils.h" |
| 50 #include "content/public/test/web_contents_tester.h" | 50 #include "content/public/test/web_contents_tester.h" |
| 51 #include "testing/gtest/include/gtest/gtest.h" | 51 #include "testing/gtest/include/gtest/gtest.h" |
| 52 | 52 |
| 53 #if BUILDFLAG(ANDROID_JAVA_UI) | 53 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 54 #include "chrome/browser/android/mock_location_settings.h" | 54 #include "chrome/browser/android/mock_location_settings.h" |
| 55 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" | 55 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" |
| 56 #include "components/prefs/pref_service.h" | 56 #include "components/prefs/pref_service.h" |
| 57 #else | 57 #else |
| 58 #include "chrome/browser/permissions/permission_request_manager.h" |
| 58 #include "chrome/browser/ui/website_settings/mock_permission_bubble_factory.h" | 59 #include "chrome/browser/ui/website_settings/mock_permission_bubble_factory.h" |
| 59 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 #if defined(ENABLE_EXTENSIONS) | 62 #if defined(ENABLE_EXTENSIONS) |
| 63 #include "extensions/browser/view_type_utils.h" | 63 #include "extensions/browser/view_type_utils.h" |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 using content::MockRenderProcessHost; | 66 using content::MockRenderProcessHost; |
| 67 | 67 |
| 68 | 68 |
| 69 // ClosedInfoBarTracker ------------------------------------------------------- | 69 // ClosedInfoBarTracker ------------------------------------------------------- |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 ContentSetting content_setting); | 142 ContentSetting content_setting); |
| 143 void CheckPermissionMessageSent(int request_id, bool allowed); | 143 void CheckPermissionMessageSent(int request_id, bool allowed); |
| 144 void CheckPermissionMessageSentForTab(int tab, int request_id, bool allowed); | 144 void CheckPermissionMessageSentForTab(int tab, int request_id, bool allowed); |
| 145 void CheckPermissionMessageSentInternal(MockRenderProcessHost* process, | 145 void CheckPermissionMessageSentInternal(MockRenderProcessHost* process, |
| 146 int request_id, | 146 int request_id, |
| 147 bool allowed); | 147 bool allowed); |
| 148 void AddNewTab(const GURL& url); | 148 void AddNewTab(const GURL& url); |
| 149 void CheckTabContentsState(const GURL& requesting_frame, | 149 void CheckTabContentsState(const GURL& requesting_frame, |
| 150 ContentSetting expected_content_setting); | 150 ContentSetting expected_content_setting); |
| 151 #if !BUILDFLAG(ANDROID_JAVA_UI) | 151 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 152 void SetupBubbleManager(content::WebContents* web_contents); | 152 void SetupRequestManager(content::WebContents* web_contents); |
| 153 size_t GetBubblesQueueSize(PermissionBubbleManager* manager); | 153 size_t GetBubblesQueueSize(PermissionRequestManager* manager); |
| 154 void AcceptBubble(PermissionBubbleManager* manager); | 154 void AcceptBubble(PermissionRequestManager* manager); |
| 155 void DenyBubble(PermissionBubbleManager* manager); | 155 void DenyBubble(PermissionRequestManager* manager); |
| 156 void CloseBubble(PermissionBubbleManager* manager); | 156 void CloseBubble(PermissionRequestManager* manager); |
| 157 #endif | 157 #endif |
| 158 void BubbleManagerDocumentLoadCompleted(); | 158 void RequestManagerDocumentLoadCompleted(); |
| 159 void BubbleManagerDocumentLoadCompleted(content::WebContents* web_contents); | 159 void RequestManagerDocumentLoadCompleted(content::WebContents* web_contents); |
| 160 ContentSetting GetGeolocationContentSetting(GURL frame_0, GURL frame_1); | 160 ContentSetting GetGeolocationContentSetting(GURL frame_0, GURL frame_1); |
| 161 size_t GetNumberOfPrompts(); | 161 size_t GetNumberOfPrompts(); |
| 162 void AcceptPrompt(); | 162 void AcceptPrompt(); |
| 163 base::string16 GetPromptText(); | 163 base::string16 GetPromptText(); |
| 164 | 164 |
| 165 // owned by the browser context | 165 // owned by the browser context |
| 166 GeolocationPermissionContext* geolocation_permission_context_; | 166 GeolocationPermissionContext* geolocation_permission_context_; |
| 167 ClosedInfoBarTracker closed_infobar_tracker_; | 167 ClosedInfoBarTracker closed_infobar_tracker_; |
| 168 std::vector<std::unique_ptr<content::WebContents>> extra_tabs_; | 168 std::vector<std::unique_ptr<content::WebContents>> extra_tabs_; |
| 169 #if !BUILDFLAG(ANDROID_JAVA_UI) | 169 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 ->SendNavigate(extra_tabs_.size() + 1, entry->GetUniqueID(), true, url); | 245 ->SendNavigate(extra_tabs_.size() + 1, entry->GetUniqueID(), true, url); |
| 246 | 246 |
| 247 // Set up required helpers, and make this be as "tabby" as the code requires. | 247 // Set up required helpers, and make this be as "tabby" as the code requires. |
| 248 #if defined(ENABLE_EXTENSIONS) | 248 #if defined(ENABLE_EXTENSIONS) |
| 249 extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS); | 249 extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS); |
| 250 #endif | 250 #endif |
| 251 | 251 |
| 252 #if BUILDFLAG(ANDROID_JAVA_UI) | 252 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 253 InfoBarService::CreateForWebContents(new_tab); | 253 InfoBarService::CreateForWebContents(new_tab); |
| 254 #else | 254 #else |
| 255 SetupBubbleManager(new_tab); | 255 SetupRequestManager(new_tab); |
| 256 #endif | 256 #endif |
| 257 | 257 |
| 258 extra_tabs_.push_back(base::WrapUnique(new_tab)); | 258 extra_tabs_.push_back(base::WrapUnique(new_tab)); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void GeolocationPermissionContextTests::CheckTabContentsState( | 261 void GeolocationPermissionContextTests::CheckTabContentsState( |
| 262 const GURL& requesting_frame, | 262 const GURL& requesting_frame, |
| 263 ContentSetting expected_content_setting) { | 263 ContentSetting expected_content_setting) { |
| 264 TabSpecificContentSettings* content_settings = | 264 TabSpecificContentSettings* content_settings = |
| 265 TabSpecificContentSettings::FromWebContents(web_contents()); | 265 TabSpecificContentSettings::FromWebContents(web_contents()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 286 geolocation_permission_context_ = static_cast<GeolocationPermissionContext*>( | 286 geolocation_permission_context_ = static_cast<GeolocationPermissionContext*>( |
| 287 PermissionManager::Get(profile())->GetPermissionContext( | 287 PermissionManager::Get(profile())->GetPermissionContext( |
| 288 content::PermissionType::GEOLOCATION)); | 288 content::PermissionType::GEOLOCATION)); |
| 289 #if BUILDFLAG(ANDROID_JAVA_UI) | 289 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 290 static_cast<GeolocationPermissionContextAndroid*>( | 290 static_cast<GeolocationPermissionContextAndroid*>( |
| 291 geolocation_permission_context_) | 291 geolocation_permission_context_) |
| 292 ->SetLocationSettingsForTesting( | 292 ->SetLocationSettingsForTesting( |
| 293 std::unique_ptr<LocationSettings>(new MockLocationSettings())); | 293 std::unique_ptr<LocationSettings>(new MockLocationSettings())); |
| 294 MockLocationSettings::SetLocationStatus(true, true); | 294 MockLocationSettings::SetLocationStatus(true, true); |
| 295 #else | 295 #else |
| 296 SetupBubbleManager(web_contents()); | 296 SetupRequestManager(web_contents()); |
| 297 #endif | 297 #endif |
| 298 } | 298 } |
| 299 | 299 |
| 300 void GeolocationPermissionContextTests::TearDown() { | 300 void GeolocationPermissionContextTests::TearDown() { |
| 301 #if !BUILDFLAG(ANDROID_JAVA_UI) | 301 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 302 mock_permission_bubble_factories_.clear(); | 302 mock_permission_bubble_factories_.clear(); |
| 303 #endif | 303 #endif |
| 304 extra_tabs_.clear(); | 304 extra_tabs_.clear(); |
| 305 ChromeRenderViewHostTestHarness::TearDown(); | 305 ChromeRenderViewHostTestHarness::TearDown(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 #if !BUILDFLAG(ANDROID_JAVA_UI) | 308 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 309 void GeolocationPermissionContextTests::SetupBubbleManager( | 309 void GeolocationPermissionContextTests::SetupRequestManager( |
| 310 content::WebContents* web_contents) { | 310 content::WebContents* web_contents) { |
| 311 // Create PermissionBubbleManager. | 311 // Create PermissionRequestManager. |
| 312 PermissionBubbleManager::CreateForWebContents(web_contents); | 312 PermissionRequestManager::CreateForWebContents(web_contents); |
| 313 PermissionBubbleManager* permission_bubble_manager = | 313 PermissionRequestManager* permission_request_manager = |
| 314 PermissionBubbleManager::FromWebContents(web_contents); | 314 PermissionRequestManager::FromWebContents(web_contents); |
| 315 | 315 |
| 316 // Create a MockPermissionBubbleFactory for the PermissionBubbleManager. | 316 // Create a MockPermissionBubbleFactory for the PermissionRequestManager. |
| 317 mock_permission_bubble_factories_.push_back(base::WrapUnique( | 317 mock_permission_bubble_factories_.push_back(base::WrapUnique( |
| 318 new MockPermissionBubbleFactory(false, permission_bubble_manager))); | 318 new MockPermissionBubbleFactory(false, permission_request_manager))); |
| 319 | 319 |
| 320 // Prepare the PermissionBubbleManager to display a mock bubble. | 320 // Prepare the PermissionRequestManager to display a mock bubble. |
| 321 permission_bubble_manager->DisplayPendingRequests(); | 321 permission_request_manager->DisplayPendingRequests(); |
| 322 } | 322 } |
| 323 | 323 |
| 324 size_t GeolocationPermissionContextTests::GetBubblesQueueSize( | 324 size_t GeolocationPermissionContextTests::GetBubblesQueueSize( |
| 325 PermissionBubbleManager* manager) { | 325 PermissionRequestManager* manager) { |
| 326 return manager->requests_.size(); | 326 return manager->requests_.size(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void GeolocationPermissionContextTests::AcceptBubble( | 329 void GeolocationPermissionContextTests::AcceptBubble( |
| 330 PermissionBubbleManager* manager) { | 330 PermissionRequestManager* manager) { |
| 331 manager->Accept(); | 331 manager->Accept(); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void GeolocationPermissionContextTests::DenyBubble( | 334 void GeolocationPermissionContextTests::DenyBubble( |
| 335 PermissionBubbleManager* manager) { | 335 PermissionRequestManager* manager) { |
| 336 manager->Deny(); | 336 manager->Deny(); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void GeolocationPermissionContextTests::CloseBubble( | 339 void GeolocationPermissionContextTests::CloseBubble( |
| 340 PermissionBubbleManager* manager) { | 340 PermissionRequestManager* manager) { |
| 341 manager->Closing(); | 341 manager->Closing(); |
| 342 } | 342 } |
| 343 #endif | 343 #endif |
| 344 | 344 |
| 345 void GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted() { | 345 void GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted() { |
| 346 GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted( | 346 GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted( |
| 347 web_contents()); | 347 web_contents()); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted( | 350 void GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted( |
| 351 content::WebContents* web_contents) { | 351 content::WebContents* web_contents) { |
| 352 #if !BUILDFLAG(ANDROID_JAVA_UI) | 352 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 353 PermissionBubbleManager::FromWebContents(web_contents)-> | 353 PermissionRequestManager::FromWebContents(web_contents)-> |
| 354 DocumentOnLoadCompletedInMainFrame(); | 354 DocumentOnLoadCompletedInMainFrame(); |
| 355 #endif | 355 #endif |
| 356 } | 356 } |
| 357 | 357 |
| 358 ContentSetting GeolocationPermissionContextTests::GetGeolocationContentSetting( | 358 ContentSetting GeolocationPermissionContextTests::GetGeolocationContentSetting( |
| 359 GURL frame_0, GURL frame_1) { | 359 GURL frame_0, GURL frame_1) { |
| 360 return HostContentSettingsMapFactory::GetForProfile(profile()) | 360 return HostContentSettingsMapFactory::GetForProfile(profile()) |
| 361 ->GetContentSetting(frame_0, | 361 ->GetContentSetting(frame_0, |
| 362 frame_1, | 362 frame_1, |
| 363 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 363 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 364 std::string()); | 364 std::string()); |
| 365 } | 365 } |
| 366 | 366 |
| 367 size_t GeolocationPermissionContextTests::GetNumberOfPrompts() { | 367 size_t GeolocationPermissionContextTests::GetNumberOfPrompts() { |
| 368 #if !BUILDFLAG(ANDROID_JAVA_UI) | 368 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 369 PermissionBubbleManager* manager = | 369 PermissionRequestManager* manager = |
| 370 PermissionBubbleManager::FromWebContents(web_contents()); | 370 PermissionRequestManager::FromWebContents(web_contents()); |
| 371 return GetBubblesQueueSize(manager); | 371 return GetBubblesQueueSize(manager); |
| 372 #else | 372 #else |
| 373 return infobar_service()->infobar_count(); | 373 return infobar_service()->infobar_count(); |
| 374 #endif | 374 #endif |
| 375 } | 375 } |
| 376 | 376 |
| 377 void GeolocationPermissionContextTests::AcceptPrompt() { | 377 void GeolocationPermissionContextTests::AcceptPrompt() { |
| 378 #if !BUILDFLAG(ANDROID_JAVA_UI) | 378 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 379 PermissionBubbleManager* manager = | 379 PermissionRequestManager* manager = |
| 380 PermissionBubbleManager::FromWebContents(web_contents()); | 380 PermissionRequestManager::FromWebContents(web_contents()); |
| 381 AcceptBubble(manager); | 381 AcceptBubble(manager); |
| 382 #else | 382 #else |
| 383 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); | 383 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); |
| 384 ConfirmInfoBarDelegate* infobar_delegate = | 384 ConfirmInfoBarDelegate* infobar_delegate = |
| 385 infobar->delegate()->AsConfirmInfoBarDelegate(); | 385 infobar->delegate()->AsConfirmInfoBarDelegate(); |
| 386 infobar_delegate->Accept(); | 386 infobar_delegate->Accept(); |
| 387 #endif | 387 #endif |
| 388 } | 388 } |
| 389 | 389 |
| 390 base::string16 GeolocationPermissionContextTests::GetPromptText() { | 390 base::string16 GeolocationPermissionContextTests::GetPromptText() { |
| 391 #if !BUILDFLAG(ANDROID_JAVA_UI) | 391 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 392 PermissionBubbleManager* manager = | 392 PermissionRequestManager* manager = |
| 393 PermissionBubbleManager::FromWebContents(web_contents()); | 393 PermissionRequestManager::FromWebContents(web_contents()); |
| 394 return manager->requests_.front()->GetMessageText(); | 394 return manager->requests_.front()->GetMessageText(); |
| 395 #else | 395 #else |
| 396 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); | 396 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); |
| 397 ConfirmInfoBarDelegate* infobar_delegate = | 397 ConfirmInfoBarDelegate* infobar_delegate = |
| 398 infobar->delegate()->AsConfirmInfoBarDelegate(); | 398 infobar->delegate()->AsConfirmInfoBarDelegate(); |
| 399 return infobar_delegate->GetMessageText(); | 399 return infobar_delegate->GetMessageText(); |
| 400 #endif | 400 #endif |
| 401 } | 401 } |
| 402 | 402 |
| 403 // Tests ---------------------------------------------------------------------- | 403 // Tests ---------------------------------------------------------------------- |
| 404 | 404 |
| 405 TEST_F(GeolocationPermissionContextTests, SinglePermissionBubble) { | 405 TEST_F(GeolocationPermissionContextTests, SinglePermissionBubble) { |
| 406 GURL requesting_frame("https://www.example.com/geolocation"); | 406 GURL requesting_frame("https://www.example.com/geolocation"); |
| 407 NavigateAndCommit(requesting_frame); | 407 NavigateAndCommit(requesting_frame); |
| 408 BubbleManagerDocumentLoadCompleted(); | 408 RequestManagerDocumentLoadCompleted(); |
| 409 | 409 |
| 410 EXPECT_EQ(0U, GetNumberOfPrompts()); | 410 EXPECT_EQ(0U, GetNumberOfPrompts()); |
| 411 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); | 411 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); |
| 412 ASSERT_EQ(1U, GetNumberOfPrompts()); | 412 ASSERT_EQ(1U, GetNumberOfPrompts()); |
| 413 } | 413 } |
| 414 | 414 |
| 415 TEST_F(GeolocationPermissionContextTests, | 415 TEST_F(GeolocationPermissionContextTests, |
| 416 SinglePermissionBubbleFailsOnInsecureOrigin) { | 416 SinglePermissionBubbleFailsOnInsecureOrigin) { |
| 417 GURL requesting_frame("http://www.example.com/geolocation"); | 417 GURL requesting_frame("http://www.example.com/geolocation"); |
| 418 NavigateAndCommit(requesting_frame); | 418 NavigateAndCommit(requesting_frame); |
| 419 BubbleManagerDocumentLoadCompleted(); | 419 RequestManagerDocumentLoadCompleted(); |
| 420 | 420 |
| 421 EXPECT_EQ(0U, GetNumberOfPrompts()); | 421 EXPECT_EQ(0U, GetNumberOfPrompts()); |
| 422 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); | 422 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); |
| 423 ASSERT_EQ(0U, GetNumberOfPrompts()); | 423 ASSERT_EQ(0U, GetNumberOfPrompts()); |
| 424 } | 424 } |
| 425 | 425 |
| 426 #if BUILDFLAG(ANDROID_JAVA_UI) | 426 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 427 TEST_F(GeolocationPermissionContextTests, SinglePermissionInfobar) { | 427 TEST_F(GeolocationPermissionContextTests, SinglePermissionInfobar) { |
| 428 GURL requesting_frame("https://www.example.com/geolocation"); | 428 GURL requesting_frame("https://www.example.com/geolocation"); |
| 429 NavigateAndCommit(requesting_frame); | 429 NavigateAndCommit(requesting_frame); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 GURL requesting_frame_0("https://www.example.com/geolocation"); | 490 GURL requesting_frame_0("https://www.example.com/geolocation"); |
| 491 GURL requesting_frame_1("https://www.example-2.com/geolocation"); | 491 GURL requesting_frame_1("https://www.example-2.com/geolocation"); |
| 492 EXPECT_EQ( | 492 EXPECT_EQ( |
| 493 CONTENT_SETTING_ASK, | 493 CONTENT_SETTING_ASK, |
| 494 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_1)); | 494 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_1)); |
| 495 EXPECT_EQ( | 495 EXPECT_EQ( |
| 496 CONTENT_SETTING_ASK, | 496 CONTENT_SETTING_ASK, |
| 497 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_1)); | 497 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_1)); |
| 498 | 498 |
| 499 NavigateAndCommit(requesting_frame_0); | 499 NavigateAndCommit(requesting_frame_0); |
| 500 BubbleManagerDocumentLoadCompleted(); | 500 RequestManagerDocumentLoadCompleted(); |
| 501 | 501 |
| 502 // Check that no permission requests have happened yet. | 502 // Check that no permission requests have happened yet. |
| 503 EXPECT_EQ(0U, GetNumberOfPrompts()); | 503 EXPECT_EQ(0U, GetNumberOfPrompts()); |
| 504 | 504 |
| 505 // Request permission for two frames. | 505 // Request permission for two frames. |
| 506 RequestGeolocationPermission( | 506 RequestGeolocationPermission( |
| 507 web_contents(), RequestID(0), requesting_frame_0); | 507 web_contents(), RequestID(0), requesting_frame_0); |
| 508 RequestGeolocationPermission( | 508 RequestGeolocationPermission( |
| 509 web_contents(), RequestID(1), requesting_frame_1); | 509 web_contents(), RequestID(1), requesting_frame_1); |
| 510 // Ensure only one infobar is created. | 510 // Ensure only one infobar is created. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 526 | 526 |
| 527 // Now we should have a new infobar for the second frame. | 527 // Now we should have a new infobar for the second frame. |
| 528 ASSERT_EQ(1U, GetNumberOfPrompts()); | 528 ASSERT_EQ(1U, GetNumberOfPrompts()); |
| 529 base::string16 text_1 = GetPromptText(); | 529 base::string16 text_1 = GetPromptText(); |
| 530 | 530 |
| 531 // Check that the messages differ. | 531 // Check that the messages differ. |
| 532 EXPECT_NE(text_0, text_1); | 532 EXPECT_NE(text_0, text_1); |
| 533 | 533 |
| 534 // Cancel (block) this frame. | 534 // Cancel (block) this frame. |
| 535 #if !BUILDFLAG(ANDROID_JAVA_UI) | 535 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 536 PermissionBubbleManager* manager = | 536 PermissionRequestManager* manager = |
| 537 PermissionBubbleManager::FromWebContents(web_contents()); | 537 PermissionRequestManager::FromWebContents(web_contents()); |
| 538 DenyBubble(manager); | 538 DenyBubble(manager); |
| 539 #else | 539 #else |
| 540 infobars::InfoBar* infobar_1 = infobar_service()->infobar_at(0); | 540 infobars::InfoBar* infobar_1 = infobar_service()->infobar_at(0); |
| 541 infobar_1->delegate()->AsConfirmInfoBarDelegate()->Cancel(); | 541 infobar_1->delegate()->AsConfirmInfoBarDelegate()->Cancel(); |
| 542 #endif | 542 #endif |
| 543 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK); | 543 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK); |
| 544 CheckPermissionMessageSent(1, false); | 544 CheckPermissionMessageSent(1, false); |
| 545 | 545 |
| 546 // Ensure the persisted permissions are ok. | 546 // Ensure the persisted permissions are ok. |
| 547 EXPECT_EQ( | 547 EXPECT_EQ( |
| 548 CONTENT_SETTING_ALLOW, | 548 CONTENT_SETTING_ALLOW, |
| 549 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); | 549 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); |
| 550 EXPECT_EQ( | 550 EXPECT_EQ( |
| 551 CONTENT_SETTING_BLOCK, | 551 CONTENT_SETTING_BLOCK, |
| 552 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); | 552 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); |
| 553 } | 553 } |
| 554 | 554 |
| 555 TEST_F(GeolocationPermissionContextTests, HashIsIgnored) { | 555 TEST_F(GeolocationPermissionContextTests, HashIsIgnored) { |
| 556 GURL url_a("https://www.example.com/geolocation#a"); | 556 GURL url_a("https://www.example.com/geolocation#a"); |
| 557 GURL url_b("https://www.example.com/geolocation#b"); | 557 GURL url_b("https://www.example.com/geolocation#b"); |
| 558 | 558 |
| 559 // Navigate to the first url. | 559 // Navigate to the first url. |
| 560 NavigateAndCommit(url_a); | 560 NavigateAndCommit(url_a); |
| 561 BubbleManagerDocumentLoadCompleted(); | 561 RequestManagerDocumentLoadCompleted(); |
| 562 | 562 |
| 563 // Check permission is requested. | 563 // Check permission is requested. |
| 564 ASSERT_EQ(0U, GetNumberOfPrompts()); | 564 ASSERT_EQ(0U, GetNumberOfPrompts()); |
| 565 RequestGeolocationPermission(web_contents(), RequestID(0), url_a); | 565 RequestGeolocationPermission(web_contents(), RequestID(0), url_a); |
| 566 ASSERT_EQ(1U, GetNumberOfPrompts()); | 566 ASSERT_EQ(1U, GetNumberOfPrompts()); |
| 567 | 567 |
| 568 // Change the hash, we'll still be on the same page. | 568 // Change the hash, we'll still be on the same page. |
| 569 NavigateAndCommit(url_b); | 569 NavigateAndCommit(url_b); |
| 570 BubbleManagerDocumentLoadCompleted(); | 570 RequestManagerDocumentLoadCompleted(); |
| 571 | 571 |
| 572 // Accept. | 572 // Accept. |
| 573 AcceptPrompt(); | 573 AcceptPrompt(); |
| 574 CheckTabContentsState(url_a, CONTENT_SETTING_ALLOW); | 574 CheckTabContentsState(url_a, CONTENT_SETTING_ALLOW); |
| 575 CheckTabContentsState(url_b, CONTENT_SETTING_ALLOW); | 575 CheckTabContentsState(url_b, CONTENT_SETTING_ALLOW); |
| 576 CheckPermissionMessageSent(0, true); | 576 CheckPermissionMessageSent(0, true); |
| 577 | 577 |
| 578 // Cleanup. | 578 // Cleanup. |
| 579 #if BUILDFLAG(ANDROID_JAVA_UI) | 579 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 580 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); | 580 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); |
| 581 infobar_service()->RemoveInfoBar(infobar); | 581 infobar_service()->RemoveInfoBar(infobar); |
| 582 EXPECT_EQ(1U, closed_infobar_tracker_.size()); | 582 EXPECT_EQ(1U, closed_infobar_tracker_.size()); |
| 583 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar)); | 583 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar)); |
| 584 #endif | 584 #endif |
| 585 } | 585 } |
| 586 | 586 |
| 587 // TODO(felt): The bubble is rejecting file:// permission requests. | 587 // TODO(felt): The bubble is rejecting file:// permission requests. |
| 588 // Fix and enable this test. crbug.com/444047 | 588 // Fix and enable this test. crbug.com/444047 |
| 589 #if BUILDFLAG(ANDROID_JAVA_UI) | 589 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 590 #define MAYBE_PermissionForFileScheme PermissionForFileScheme | 590 #define MAYBE_PermissionForFileScheme PermissionForFileScheme |
| 591 #else | 591 #else |
| 592 #define MAYBE_PermissionForFileScheme DISABLED_PermissionForFileScheme | 592 #define MAYBE_PermissionForFileScheme DISABLED_PermissionForFileScheme |
| 593 #endif | 593 #endif |
| 594 TEST_F(GeolocationPermissionContextTests, MAYBE_PermissionForFileScheme) { | 594 TEST_F(GeolocationPermissionContextTests, MAYBE_PermissionForFileScheme) { |
| 595 GURL requesting_frame("file://example/geolocation.html"); | 595 GURL requesting_frame("file://example/geolocation.html"); |
| 596 NavigateAndCommit(requesting_frame); | 596 NavigateAndCommit(requesting_frame); |
| 597 BubbleManagerDocumentLoadCompleted(); | 597 RequestManagerDocumentLoadCompleted(); |
| 598 | 598 |
| 599 // Check permission is requested. | 599 // Check permission is requested. |
| 600 ASSERT_EQ(0U, GetNumberOfPrompts()); | 600 ASSERT_EQ(0U, GetNumberOfPrompts()); |
| 601 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); | 601 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); |
| 602 EXPECT_EQ(1U, GetNumberOfPrompts()); | 602 EXPECT_EQ(1U, GetNumberOfPrompts()); |
| 603 | 603 |
| 604 // Accept the frame. | 604 // Accept the frame. |
| 605 AcceptPrompt(); | 605 AcceptPrompt(); |
| 606 CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); | 606 CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); |
| 607 CheckPermissionMessageSent(0, true); | 607 CheckPermissionMessageSent(0, true); |
| 608 | 608 |
| 609 // Make sure the setting is not stored. | 609 // Make sure the setting is not stored. |
| 610 EXPECT_EQ( | 610 EXPECT_EQ( |
| 611 CONTENT_SETTING_ASK, | 611 CONTENT_SETTING_ASK, |
| 612 GetGeolocationContentSetting(requesting_frame, requesting_frame)); | 612 GetGeolocationContentSetting(requesting_frame, requesting_frame)); |
| 613 } | 613 } |
| 614 | 614 |
| 615 TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { | 615 TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { |
| 616 GURL frame_0("https://www.example.com/geolocation"); | 616 GURL frame_0("https://www.example.com/geolocation"); |
| 617 GURL frame_1("https://www.example-2.com/geolocation"); | 617 GURL frame_1("https://www.example-2.com/geolocation"); |
| 618 EXPECT_EQ( | 618 EXPECT_EQ( |
| 619 CONTENT_SETTING_ASK, GetGeolocationContentSetting(frame_0, frame_0)); | 619 CONTENT_SETTING_ASK, GetGeolocationContentSetting(frame_0, frame_0)); |
| 620 EXPECT_EQ( | 620 EXPECT_EQ( |
| 621 CONTENT_SETTING_ASK, GetGeolocationContentSetting(frame_1, frame_0)); | 621 CONTENT_SETTING_ASK, GetGeolocationContentSetting(frame_1, frame_0)); |
| 622 | 622 |
| 623 NavigateAndCommit(frame_0); | 623 NavigateAndCommit(frame_0); |
| 624 BubbleManagerDocumentLoadCompleted(); | 624 RequestManagerDocumentLoadCompleted(); |
| 625 | 625 |
| 626 ASSERT_EQ(0U, GetNumberOfPrompts()); | 626 ASSERT_EQ(0U, GetNumberOfPrompts()); |
| 627 | 627 |
| 628 // Request permission for two frames. | 628 // Request permission for two frames. |
| 629 RequestGeolocationPermission(web_contents(), RequestID(0), frame_0); | 629 RequestGeolocationPermission(web_contents(), RequestID(0), frame_0); |
| 630 RequestGeolocationPermission(web_contents(), RequestID(1), frame_1); | 630 RequestGeolocationPermission(web_contents(), RequestID(1), frame_1); |
| 631 | 631 |
| 632 // Get the first permission request text. | 632 // Get the first permission request text. |
| 633 ASSERT_EQ(1U, GetNumberOfPrompts()); | 633 ASSERT_EQ(1U, GetNumberOfPrompts()); |
| 634 base::string16 text_0 = GetPromptText(); | 634 base::string16 text_0 = GetPromptText(); |
| 635 ASSERT_FALSE(text_0.empty()); | 635 ASSERT_FALSE(text_0.empty()); |
| 636 | 636 |
| 637 // Simulate the frame going away; the request should be removed. | 637 // Simulate the frame going away; the request should be removed. |
| 638 #if !BUILDFLAG(ANDROID_JAVA_UI) | 638 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 639 PermissionBubbleManager* manager = | 639 PermissionRequestManager* manager = |
| 640 PermissionBubbleManager::FromWebContents(web_contents()); | 640 PermissionRequestManager::FromWebContents(web_contents()); |
| 641 CloseBubble(manager); | 641 CloseBubble(manager); |
| 642 #else | 642 #else |
| 643 geolocation_permission_context_->CancelPermissionRequest(web_contents(), | 643 geolocation_permission_context_->CancelPermissionRequest(web_contents(), |
| 644 RequestID(0)); | 644 RequestID(0)); |
| 645 #endif | 645 #endif |
| 646 | 646 |
| 647 // Check that the next pending request is created correctly. | 647 // Check that the next pending request is created correctly. |
| 648 base::string16 text_1 = GetPromptText(); | 648 base::string16 text_1 = GetPromptText(); |
| 649 EXPECT_NE(text_0, text_1); | 649 EXPECT_NE(text_0, text_1); |
| 650 | 650 |
| 651 // Allow this frame and check that it worked. | 651 // Allow this frame and check that it worked. |
| 652 AcceptPrompt(); | 652 AcceptPrompt(); |
| 653 CheckTabContentsState(frame_1, CONTENT_SETTING_ALLOW); | 653 CheckTabContentsState(frame_1, CONTENT_SETTING_ALLOW); |
| 654 CheckPermissionMessageSent(1, true); | 654 CheckPermissionMessageSent(1, true); |
| 655 | 655 |
| 656 // Ensure the persisted permissions are ok. | 656 // Ensure the persisted permissions are ok. |
| 657 EXPECT_EQ( | 657 EXPECT_EQ( |
| 658 CONTENT_SETTING_ASK, GetGeolocationContentSetting(frame_0, frame_0)); | 658 CONTENT_SETTING_ASK, GetGeolocationContentSetting(frame_0, frame_0)); |
| 659 EXPECT_EQ( | 659 EXPECT_EQ( |
| 660 CONTENT_SETTING_ALLOW, GetGeolocationContentSetting(frame_1, frame_0)); | 660 CONTENT_SETTING_ALLOW, GetGeolocationContentSetting(frame_1, frame_0)); |
| 661 } | 661 } |
| 662 | 662 |
| 663 TEST_F(GeolocationPermissionContextTests, InvalidURL) { | 663 TEST_F(GeolocationPermissionContextTests, InvalidURL) { |
| 664 // Navigate to the first url. | 664 // Navigate to the first url. |
| 665 GURL invalid_embedder("about:blank"); | 665 GURL invalid_embedder("about:blank"); |
| 666 GURL requesting_frame; | 666 GURL requesting_frame; |
| 667 NavigateAndCommit(invalid_embedder); | 667 NavigateAndCommit(invalid_embedder); |
| 668 BubbleManagerDocumentLoadCompleted(); | 668 RequestManagerDocumentLoadCompleted(); |
| 669 | 669 |
| 670 // Nothing should be displayed. | 670 // Nothing should be displayed. |
| 671 EXPECT_EQ(0U, GetNumberOfPrompts()); | 671 EXPECT_EQ(0U, GetNumberOfPrompts()); |
| 672 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); | 672 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame); |
| 673 EXPECT_EQ(0U, GetNumberOfPrompts()); | 673 EXPECT_EQ(0U, GetNumberOfPrompts()); |
| 674 CheckPermissionMessageSent(0, false); | 674 CheckPermissionMessageSent(0, false); |
| 675 } | 675 } |
| 676 | 676 |
| 677 TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { | 677 TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { |
| 678 GURL url_a("https://www.example.com/geolocation"); | 678 GURL url_a("https://www.example.com/geolocation"); |
| 679 GURL url_b("https://www.example-2.com/geolocation"); | 679 GURL url_b("https://www.example-2.com/geolocation"); |
| 680 NavigateAndCommit(url_a); // Tab A0 | 680 NavigateAndCommit(url_a); // Tab A0 |
| 681 AddNewTab(url_b); // Tab B (extra_tabs_[0]) | 681 AddNewTab(url_b); // Tab B (extra_tabs_[0]) |
| 682 AddNewTab(url_a); // Tab A1 (extra_tabs_[1]) | 682 AddNewTab(url_a); // Tab A1 (extra_tabs_[1]) |
| 683 BubbleManagerDocumentLoadCompleted(); | 683 RequestManagerDocumentLoadCompleted(); |
| 684 BubbleManagerDocumentLoadCompleted(extra_tabs_[0].get()); | 684 RequestManagerDocumentLoadCompleted(extra_tabs_[0].get()); |
| 685 BubbleManagerDocumentLoadCompleted(extra_tabs_[1].get()); | 685 RequestManagerDocumentLoadCompleted(extra_tabs_[1].get()); |
| 686 #if !BUILDFLAG(ANDROID_JAVA_UI) | 686 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 687 PermissionBubbleManager* manager_a0 = | 687 PermissionRequestManager* manager_a0 = |
| 688 PermissionBubbleManager::FromWebContents(web_contents()); | 688 PermissionRequestManager::FromWebContents(web_contents()); |
| 689 PermissionBubbleManager* manager_b = | 689 PermissionRequestManager* manager_b = |
| 690 PermissionBubbleManager::FromWebContents(extra_tabs_[0].get()); | 690 PermissionRequestManager::FromWebContents(extra_tabs_[0].get()); |
| 691 PermissionBubbleManager* manager_a1 = | 691 PermissionRequestManager* manager_a1 = |
| 692 PermissionBubbleManager::FromWebContents(extra_tabs_[1].get()); | 692 PermissionRequestManager::FromWebContents(extra_tabs_[1].get()); |
| 693 #endif | 693 #endif |
| 694 | 694 |
| 695 // Request permission in all three tabs. | 695 // Request permission in all three tabs. |
| 696 RequestGeolocationPermission(web_contents(), RequestID(0), url_a); | 696 RequestGeolocationPermission(web_contents(), RequestID(0), url_a); |
| 697 RequestGeolocationPermission( | 697 RequestGeolocationPermission( |
| 698 extra_tabs_[0].get(), RequestIDForTab(0, 0), url_b); | 698 extra_tabs_[0].get(), RequestIDForTab(0, 0), url_b); |
| 699 RequestGeolocationPermission( | 699 RequestGeolocationPermission( |
| 700 extra_tabs_[1].get(), RequestIDForTab(1, 0), url_a); | 700 extra_tabs_[1].get(), RequestIDForTab(1, 0), url_a); |
| 701 ASSERT_EQ(1U, GetNumberOfPrompts()); // For A0. | 701 ASSERT_EQ(1U, GetNumberOfPrompts()); // For A0. |
| 702 #if !BUILDFLAG(ANDROID_JAVA_UI) | 702 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 733 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); | 733 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); |
| 734 #endif | 734 #endif |
| 735 } | 735 } |
| 736 | 736 |
| 737 TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { | 737 TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { |
| 738 GURL url_a("https://www.example.com/geolocation"); | 738 GURL url_a("https://www.example.com/geolocation"); |
| 739 GURL url_b("https://www.example-2.com/geolocation"); | 739 GURL url_b("https://www.example-2.com/geolocation"); |
| 740 NavigateAndCommit(url_a); // Tab A0. | 740 NavigateAndCommit(url_a); // Tab A0. |
| 741 AddNewTab(url_a); // Tab A1. | 741 AddNewTab(url_a); // Tab A1. |
| 742 #if !BUILDFLAG(ANDROID_JAVA_UI) | 742 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 743 BubbleManagerDocumentLoadCompleted(); | 743 RequestManagerDocumentLoadCompleted(); |
| 744 BubbleManagerDocumentLoadCompleted(extra_tabs_[0].get()); | 744 RequestManagerDocumentLoadCompleted(extra_tabs_[0].get()); |
| 745 PermissionBubbleManager* manager_a0 = | 745 PermissionRequestManager* manager_a0 = |
| 746 PermissionBubbleManager::FromWebContents(web_contents()); | 746 PermissionRequestManager::FromWebContents(web_contents()); |
| 747 PermissionBubbleManager* manager_a1 = | 747 PermissionRequestManager* manager_a1 = |
| 748 PermissionBubbleManager::FromWebContents(extra_tabs_[0].get()); | 748 PermissionRequestManager::FromWebContents(extra_tabs_[0].get()); |
| 749 #endif | 749 #endif |
| 750 | 750 |
| 751 // Request permission in both tabs; the extra tab will have two permission | 751 // Request permission in both tabs; the extra tab will have two permission |
| 752 // requests from two origins. | 752 // requests from two origins. |
| 753 RequestGeolocationPermission(web_contents(), RequestID(0), url_a); | 753 RequestGeolocationPermission(web_contents(), RequestID(0), url_a); |
| 754 RequestGeolocationPermission( | 754 RequestGeolocationPermission( |
| 755 extra_tabs_[0].get(), RequestIDForTab(0, 0), url_a); | 755 extra_tabs_[0].get(), RequestIDForTab(0, 0), url_a); |
| 756 RequestGeolocationPermission( | 756 RequestGeolocationPermission( |
| 757 extra_tabs_[0].get(), RequestIDForTab(0, 1), url_b); | 757 extra_tabs_[0].get(), RequestIDForTab(0, 1), url_b); |
| 758 #if !BUILDFLAG(ANDROID_JAVA_UI) | 758 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 GURL requesting_frame_0("https://www.example.com/geolocation"); | 812 GURL requesting_frame_0("https://www.example.com/geolocation"); |
| 813 GURL requesting_frame_1("https://www.example-2.com/geolocation"); | 813 GURL requesting_frame_1("https://www.example-2.com/geolocation"); |
| 814 EXPECT_EQ( | 814 EXPECT_EQ( |
| 815 CONTENT_SETTING_ASK, | 815 CONTENT_SETTING_ASK, |
| 816 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); | 816 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); |
| 817 EXPECT_EQ( | 817 EXPECT_EQ( |
| 818 CONTENT_SETTING_ASK, | 818 CONTENT_SETTING_ASK, |
| 819 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); | 819 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); |
| 820 | 820 |
| 821 NavigateAndCommit(requesting_frame_0); | 821 NavigateAndCommit(requesting_frame_0); |
| 822 BubbleManagerDocumentLoadCompleted(); | 822 RequestManagerDocumentLoadCompleted(); |
| 823 | 823 |
| 824 // Request permission for two frames. | 824 // Request permission for two frames. |
| 825 RequestGeolocationPermission( | 825 RequestGeolocationPermission( |
| 826 web_contents(), RequestID(0), requesting_frame_0); | 826 web_contents(), RequestID(0), requesting_frame_0); |
| 827 RequestGeolocationPermission( | 827 RequestGeolocationPermission( |
| 828 web_contents(), RequestID(1), requesting_frame_1); | 828 web_contents(), RequestID(1), requesting_frame_1); |
| 829 | 829 |
| 830 // Ensure only one prompt is created. | 830 // Ensure only one prompt is created. |
| 831 ASSERT_EQ(1U, GetNumberOfPrompts()); | 831 ASSERT_EQ(1U, GetNumberOfPrompts()); |
| 832 | 832 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 843 CONTENT_SETTING_ASK, | 843 CONTENT_SETTING_ASK, |
| 844 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); | 844 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); |
| 845 EXPECT_EQ( | 845 EXPECT_EQ( |
| 846 CONTENT_SETTING_ASK, | 846 CONTENT_SETTING_ASK, |
| 847 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); | 847 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); |
| 848 } | 848 } |
| 849 | 849 |
| 850 TEST_F(GeolocationPermissionContextTests, LastUsageAudited) { | 850 TEST_F(GeolocationPermissionContextTests, LastUsageAudited) { |
| 851 GURL requesting_frame("https://www.example.com/geolocation"); | 851 GURL requesting_frame("https://www.example.com/geolocation"); |
| 852 NavigateAndCommit(requesting_frame); | 852 NavigateAndCommit(requesting_frame); |
| 853 BubbleManagerDocumentLoadCompleted(); | 853 RequestManagerDocumentLoadCompleted(); |
| 854 | 854 |
| 855 base::SimpleTestClock* test_clock = new base::SimpleTestClock; | 855 base::SimpleTestClock* test_clock = new base::SimpleTestClock; |
| 856 test_clock->SetNow(base::Time::UnixEpoch() + | 856 test_clock->SetNow(base::Time::UnixEpoch() + |
| 857 base::TimeDelta::FromSeconds(10)); | 857 base::TimeDelta::FromSeconds(10)); |
| 858 | 858 |
| 859 HostContentSettingsMap* map = | 859 HostContentSettingsMap* map = |
| 860 HostContentSettingsMapFactory::GetForProfile(profile()); | 860 HostContentSettingsMapFactory::GetForProfile(profile()); |
| 861 map->SetPrefClockForTesting(std::unique_ptr<base::Clock>(test_clock)); | 861 map->SetPrefClockForTesting(std::unique_ptr<base::Clock>(test_clock)); |
| 862 | 862 |
| 863 // The permission shouldn't have been used yet. | 863 // The permission shouldn't have been used yet. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 905 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
| 906 requesting_frame_0.GetOrigin(), | 906 requesting_frame_0.GetOrigin(), |
| 907 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 907 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 908 0); | 908 0); |
| 909 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 909 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
| 910 requesting_frame_0.GetOrigin(), | 910 requesting_frame_0.GetOrigin(), |
| 911 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 911 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 912 0); | 912 0); |
| 913 | 913 |
| 914 NavigateAndCommit(requesting_frame_0); | 914 NavigateAndCommit(requesting_frame_0); |
| 915 BubbleManagerDocumentLoadCompleted(); | 915 RequestManagerDocumentLoadCompleted(); |
| 916 | 916 |
| 917 EXPECT_EQ(0U, GetNumberOfPrompts()); | 917 EXPECT_EQ(0U, GetNumberOfPrompts()); |
| 918 | 918 |
| 919 // Request permission for two frames. | 919 // Request permission for two frames. |
| 920 RequestGeolocationPermission( | 920 RequestGeolocationPermission( |
| 921 web_contents(), RequestID(0), requesting_frame_0); | 921 web_contents(), RequestID(0), requesting_frame_0); |
| 922 RequestGeolocationPermission( | 922 RequestGeolocationPermission( |
| 923 web_contents(), RequestID(1), requesting_frame_1); | 923 web_contents(), RequestID(1), requesting_frame_1); |
| 924 | 924 |
| 925 // Ensure only one infobar is created. | 925 // Ensure only one infobar is created. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 // it is the embedder. | 974 // it is the embedder. |
| 975 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 975 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
| 976 requesting_frame_0.GetOrigin(), | 976 requesting_frame_0.GetOrigin(), |
| 977 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 977 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 978 13); | 978 13); |
| 979 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 979 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
| 980 requesting_frame_0.GetOrigin(), | 980 requesting_frame_0.GetOrigin(), |
| 981 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 981 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 982 11); | 982 11); |
| 983 } | 983 } |
| OLD | NEW |