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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "content/public/browser/notification_service.h" | 44 #include "content/public/browser/notification_service.h" |
45 #include "content/public/browser/render_frame_host.h" | 45 #include "content/public/browser/render_frame_host.h" |
46 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
47 #include "content/public/test/mock_render_process_host.h" | 47 #include "content/public/test/mock_render_process_host.h" |
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 "extensions/features/features.h" | 51 #include "extensions/features/features.h" |
52 #include "testing/gtest/include/gtest/gtest.h" | 52 #include "testing/gtest/include/gtest/gtest.h" |
53 | 53 |
54 #if BUILDFLAG(ANDROID_JAVA_UI) | 54 #if defined(OS_ANDROID) |
55 #include "chrome/browser/android/mock_location_settings.h" | 55 #include "chrome/browser/android/mock_location_settings.h" |
56 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" | 56 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" |
57 #include "components/prefs/pref_service.h" | 57 #include "components/prefs/pref_service.h" |
58 #else | 58 #else |
59 #include "chrome/browser/permissions/permission_request_manager.h" | 59 #include "chrome/browser/permissions/permission_request_manager.h" |
60 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h" | 60 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h" |
61 #endif | 61 #endif |
62 | 62 |
63 #if BUILDFLAG(ENABLE_EXTENSIONS) | 63 #if BUILDFLAG(ENABLE_EXTENSIONS) |
64 #include "extensions/browser/view_type_utils.h" | 64 #include "extensions/browser/view_type_utils.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void PermissionResponse(const PermissionRequestID& id, | 143 void PermissionResponse(const PermissionRequestID& id, |
144 ContentSetting content_setting); | 144 ContentSetting content_setting); |
145 void CheckPermissionMessageSent(int request_id, bool allowed); | 145 void CheckPermissionMessageSent(int request_id, bool allowed); |
146 void CheckPermissionMessageSentForTab(int tab, int request_id, bool allowed); | 146 void CheckPermissionMessageSentForTab(int tab, int request_id, bool allowed); |
147 void CheckPermissionMessageSentInternal(MockRenderProcessHost* process, | 147 void CheckPermissionMessageSentInternal(MockRenderProcessHost* process, |
148 int request_id, | 148 int request_id, |
149 bool allowed); | 149 bool allowed); |
150 void AddNewTab(const GURL& url); | 150 void AddNewTab(const GURL& url); |
151 void CheckTabContentsState(const GURL& requesting_frame, | 151 void CheckTabContentsState(const GURL& requesting_frame, |
152 ContentSetting expected_content_setting); | 152 ContentSetting expected_content_setting); |
153 #if !BUILDFLAG(ANDROID_JAVA_UI) | 153 #if !defined(OS_ANDROID) |
154 void SetupRequestManager(content::WebContents* web_contents); | 154 void SetupRequestManager(content::WebContents* web_contents); |
155 size_t GetBubblesQueueSize(PermissionRequestManager* manager); | 155 size_t GetBubblesQueueSize(PermissionRequestManager* manager); |
156 void AcceptBubble(PermissionRequestManager* manager); | 156 void AcceptBubble(PermissionRequestManager* manager); |
157 void DenyBubble(PermissionRequestManager* manager); | 157 void DenyBubble(PermissionRequestManager* manager); |
158 void CloseBubble(PermissionRequestManager* manager); | 158 void CloseBubble(PermissionRequestManager* manager); |
159 #endif | 159 #endif |
160 void RequestManagerDocumentLoadCompleted(); | 160 void RequestManagerDocumentLoadCompleted(); |
161 void RequestManagerDocumentLoadCompleted(content::WebContents* web_contents); | 161 void RequestManagerDocumentLoadCompleted(content::WebContents* web_contents); |
162 ContentSetting GetGeolocationContentSetting(GURL frame_0, GURL frame_1); | 162 ContentSetting GetGeolocationContentSetting(GURL frame_0, GURL frame_1); |
163 size_t GetNumberOfPrompts(); | 163 size_t GetNumberOfPrompts(); |
164 void AcceptPrompt(); | 164 void AcceptPrompt(); |
165 base::string16 GetPromptText(); | 165 base::string16 GetPromptText(); |
166 | 166 |
167 // owned by the browser context | 167 // owned by the browser context |
168 GeolocationPermissionContext* geolocation_permission_context_; | 168 GeolocationPermissionContext* geolocation_permission_context_; |
169 ClosedInfoBarTracker closed_infobar_tracker_; | 169 ClosedInfoBarTracker closed_infobar_tracker_; |
170 std::vector<std::unique_ptr<content::WebContents>> extra_tabs_; | 170 std::vector<std::unique_ptr<content::WebContents>> extra_tabs_; |
171 #if !BUILDFLAG(ANDROID_JAVA_UI) | 171 #if !defined(OS_ANDROID) |
172 std::vector<std::unique_ptr<MockPermissionPromptFactory>> | 172 std::vector<std::unique_ptr<MockPermissionPromptFactory>> |
173 mock_permission_prompt_factories_; | 173 mock_permission_prompt_factories_; |
174 #endif | 174 #endif |
175 | 175 |
176 // A map between renderer child id and a pair represending the bridge id and | 176 // A map between renderer child id and a pair represending the bridge id and |
177 // whether the requested permission was allowed. | 177 // whether the requested permission was allowed. |
178 base::hash_map<int, std::pair<int, bool> > responses_; | 178 base::hash_map<int, std::pair<int, bool> > responses_; |
179 }; | 179 }; |
180 | 180 |
181 PermissionRequestID GeolocationPermissionContextTests::RequestID( | 181 PermissionRequestID GeolocationPermissionContextTests::RequestID( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 245 url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
246 content::NavigationEntry* entry = new_tab->GetController().GetPendingEntry(); | 246 content::NavigationEntry* entry = new_tab->GetController().GetPendingEntry(); |
247 content::RenderFrameHostTester::For(new_tab->GetMainFrame()) | 247 content::RenderFrameHostTester::For(new_tab->GetMainFrame()) |
248 ->SendNavigate(entry->GetUniqueID(), true, url); | 248 ->SendNavigate(entry->GetUniqueID(), true, url); |
249 | 249 |
250 // Set up required helpers, and make this be as "tabby" as the code requires. | 250 // Set up required helpers, and make this be as "tabby" as the code requires. |
251 #if BUILDFLAG(ENABLE_EXTENSIONS) | 251 #if BUILDFLAG(ENABLE_EXTENSIONS) |
252 extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS); | 252 extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS); |
253 #endif | 253 #endif |
254 | 254 |
255 #if BUILDFLAG(ANDROID_JAVA_UI) | 255 #if defined(OS_ANDROID) |
256 InfoBarService::CreateForWebContents(new_tab); | 256 InfoBarService::CreateForWebContents(new_tab); |
257 #else | 257 #else |
258 SetupRequestManager(new_tab); | 258 SetupRequestManager(new_tab); |
259 #endif | 259 #endif |
260 | 260 |
261 extra_tabs_.push_back(base::WrapUnique(new_tab)); | 261 extra_tabs_.push_back(base::WrapUnique(new_tab)); |
262 } | 262 } |
263 | 263 |
264 void GeolocationPermissionContextTests::CheckTabContentsState( | 264 void GeolocationPermissionContextTests::CheckTabContentsState( |
265 const GURL& requesting_frame, | 265 const GURL& requesting_frame, |
(...skipping 16 matching lines...) Expand all Loading... |
282 | 282 |
283 // Set up required helpers, and make this be as "tabby" as the code requires. | 283 // Set up required helpers, and make this be as "tabby" as the code requires. |
284 #if BUILDFLAG(ENABLE_EXTENSIONS) | 284 #if BUILDFLAG(ENABLE_EXTENSIONS) |
285 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS); | 285 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS); |
286 #endif | 286 #endif |
287 InfoBarService::CreateForWebContents(web_contents()); | 287 InfoBarService::CreateForWebContents(web_contents()); |
288 TabSpecificContentSettings::CreateForWebContents(web_contents()); | 288 TabSpecificContentSettings::CreateForWebContents(web_contents()); |
289 geolocation_permission_context_ = static_cast<GeolocationPermissionContext*>( | 289 geolocation_permission_context_ = static_cast<GeolocationPermissionContext*>( |
290 PermissionManager::Get(profile())->GetPermissionContext( | 290 PermissionManager::Get(profile())->GetPermissionContext( |
291 content::PermissionType::GEOLOCATION)); | 291 content::PermissionType::GEOLOCATION)); |
292 #if BUILDFLAG(ANDROID_JAVA_UI) | 292 #if defined(OS_ANDROID) |
293 static_cast<GeolocationPermissionContextAndroid*>( | 293 static_cast<GeolocationPermissionContextAndroid*>( |
294 geolocation_permission_context_) | 294 geolocation_permission_context_) |
295 ->SetLocationSettingsForTesting( | 295 ->SetLocationSettingsForTesting( |
296 std::unique_ptr<LocationSettings>(new MockLocationSettings())); | 296 std::unique_ptr<LocationSettings>(new MockLocationSettings())); |
297 MockLocationSettings::SetLocationStatus(true, true); | 297 MockLocationSettings::SetLocationStatus(true, true); |
298 #else | 298 #else |
299 SetupRequestManager(web_contents()); | 299 SetupRequestManager(web_contents()); |
300 #endif | 300 #endif |
301 } | 301 } |
302 | 302 |
303 void GeolocationPermissionContextTests::TearDown() { | 303 void GeolocationPermissionContextTests::TearDown() { |
304 #if !BUILDFLAG(ANDROID_JAVA_UI) | 304 #if !defined(OS_ANDROID) |
305 mock_permission_prompt_factories_.clear(); | 305 mock_permission_prompt_factories_.clear(); |
306 #endif | 306 #endif |
307 extra_tabs_.clear(); | 307 extra_tabs_.clear(); |
308 ChromeRenderViewHostTestHarness::TearDown(); | 308 ChromeRenderViewHostTestHarness::TearDown(); |
309 } | 309 } |
310 | 310 |
311 #if !BUILDFLAG(ANDROID_JAVA_UI) | 311 #if !defined(OS_ANDROID) |
312 void GeolocationPermissionContextTests::SetupRequestManager( | 312 void GeolocationPermissionContextTests::SetupRequestManager( |
313 content::WebContents* web_contents) { | 313 content::WebContents* web_contents) { |
314 // Create PermissionRequestManager. | 314 // Create PermissionRequestManager. |
315 PermissionRequestManager::CreateForWebContents(web_contents); | 315 PermissionRequestManager::CreateForWebContents(web_contents); |
316 PermissionRequestManager* permission_request_manager = | 316 PermissionRequestManager* permission_request_manager = |
317 PermissionRequestManager::FromWebContents(web_contents); | 317 PermissionRequestManager::FromWebContents(web_contents); |
318 | 318 |
319 // Create a MockPermissionPromptFactory for the PermissionRequestManager. | 319 // Create a MockPermissionPromptFactory for the PermissionRequestManager. |
320 mock_permission_prompt_factories_.push_back( | 320 mock_permission_prompt_factories_.push_back( |
321 base::MakeUnique<MockPermissionPromptFactory>( | 321 base::MakeUnique<MockPermissionPromptFactory>( |
(...skipping 24 matching lines...) Expand all Loading... |
346 } | 346 } |
347 #endif | 347 #endif |
348 | 348 |
349 void GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted() { | 349 void GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted() { |
350 GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted( | 350 GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted( |
351 web_contents()); | 351 web_contents()); |
352 } | 352 } |
353 | 353 |
354 void GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted( | 354 void GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted( |
355 content::WebContents* web_contents) { | 355 content::WebContents* web_contents) { |
356 #if !BUILDFLAG(ANDROID_JAVA_UI) | 356 #if !defined(OS_ANDROID) |
357 PermissionRequestManager::FromWebContents(web_contents)-> | 357 PermissionRequestManager::FromWebContents(web_contents)-> |
358 DocumentOnLoadCompletedInMainFrame(); | 358 DocumentOnLoadCompletedInMainFrame(); |
359 #endif | 359 #endif |
360 } | 360 } |
361 | 361 |
362 ContentSetting GeolocationPermissionContextTests::GetGeolocationContentSetting( | 362 ContentSetting GeolocationPermissionContextTests::GetGeolocationContentSetting( |
363 GURL frame_0, GURL frame_1) { | 363 GURL frame_0, GURL frame_1) { |
364 return HostContentSettingsMapFactory::GetForProfile(profile()) | 364 return HostContentSettingsMapFactory::GetForProfile(profile()) |
365 ->GetContentSetting(frame_0, | 365 ->GetContentSetting(frame_0, |
366 frame_1, | 366 frame_1, |
367 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 367 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
368 std::string()); | 368 std::string()); |
369 } | 369 } |
370 | 370 |
371 size_t GeolocationPermissionContextTests::GetNumberOfPrompts() { | 371 size_t GeolocationPermissionContextTests::GetNumberOfPrompts() { |
372 #if !BUILDFLAG(ANDROID_JAVA_UI) | 372 #if !defined(OS_ANDROID) |
373 PermissionRequestManager* manager = | 373 PermissionRequestManager* manager = |
374 PermissionRequestManager::FromWebContents(web_contents()); | 374 PermissionRequestManager::FromWebContents(web_contents()); |
375 return GetBubblesQueueSize(manager); | 375 return GetBubblesQueueSize(manager); |
376 #else | 376 #else |
377 return infobar_service()->infobar_count(); | 377 return infobar_service()->infobar_count(); |
378 #endif | 378 #endif |
379 } | 379 } |
380 | 380 |
381 void GeolocationPermissionContextTests::AcceptPrompt() { | 381 void GeolocationPermissionContextTests::AcceptPrompt() { |
382 #if !BUILDFLAG(ANDROID_JAVA_UI) | 382 #if !defined(OS_ANDROID) |
383 PermissionRequestManager* manager = | 383 PermissionRequestManager* manager = |
384 PermissionRequestManager::FromWebContents(web_contents()); | 384 PermissionRequestManager::FromWebContents(web_contents()); |
385 AcceptBubble(manager); | 385 AcceptBubble(manager); |
386 #else | 386 #else |
387 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); | 387 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); |
388 ConfirmInfoBarDelegate* infobar_delegate = | 388 ConfirmInfoBarDelegate* infobar_delegate = |
389 infobar->delegate()->AsConfirmInfoBarDelegate(); | 389 infobar->delegate()->AsConfirmInfoBarDelegate(); |
390 infobar_delegate->Accept(); | 390 infobar_delegate->Accept(); |
391 #endif | 391 #endif |
392 } | 392 } |
393 | 393 |
394 base::string16 GeolocationPermissionContextTests::GetPromptText() { | 394 base::string16 GeolocationPermissionContextTests::GetPromptText() { |
395 #if !BUILDFLAG(ANDROID_JAVA_UI) | 395 #if !defined(OS_ANDROID) |
396 PermissionRequestManager* manager = | 396 PermissionRequestManager* manager = |
397 PermissionRequestManager::FromWebContents(web_contents()); | 397 PermissionRequestManager::FromWebContents(web_contents()); |
398 PermissionRequest* request = manager->requests_.front(); | 398 PermissionRequest* request = manager->requests_.front(); |
399 return base::ASCIIToUTF16(request->GetOrigin().spec()) + | 399 return base::ASCIIToUTF16(request->GetOrigin().spec()) + |
400 request->GetMessageTextFragment(); | 400 request->GetMessageTextFragment(); |
401 #else | 401 #else |
402 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); | 402 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); |
403 ConfirmInfoBarDelegate* infobar_delegate = | 403 ConfirmInfoBarDelegate* infobar_delegate = |
404 infobar->delegate()->AsConfirmInfoBarDelegate(); | 404 infobar->delegate()->AsConfirmInfoBarDelegate(); |
405 return infobar_delegate->GetMessageText(); | 405 return infobar_delegate->GetMessageText(); |
(...skipping 18 matching lines...) Expand all Loading... |
424 GURL requesting_frame("http://www.example.com/geolocation"); | 424 GURL requesting_frame("http://www.example.com/geolocation"); |
425 NavigateAndCommit(requesting_frame); | 425 NavigateAndCommit(requesting_frame); |
426 RequestManagerDocumentLoadCompleted(); | 426 RequestManagerDocumentLoadCompleted(); |
427 | 427 |
428 EXPECT_EQ(0U, GetNumberOfPrompts()); | 428 EXPECT_EQ(0U, GetNumberOfPrompts()); |
429 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame, | 429 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame, |
430 true); | 430 true); |
431 ASSERT_EQ(0U, GetNumberOfPrompts()); | 431 ASSERT_EQ(0U, GetNumberOfPrompts()); |
432 } | 432 } |
433 | 433 |
434 #if BUILDFLAG(ANDROID_JAVA_UI) | 434 #if defined(OS_ANDROID) |
435 TEST_F(GeolocationPermissionContextTests, SinglePermissionInfobar) { | 435 TEST_F(GeolocationPermissionContextTests, SinglePermissionInfobar) { |
436 GURL requesting_frame("https://www.example.com/geolocation"); | 436 GURL requesting_frame("https://www.example.com/geolocation"); |
437 NavigateAndCommit(requesting_frame); | 437 NavigateAndCommit(requesting_frame); |
438 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 438 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
439 RequestGeolocationPermission( | 439 RequestGeolocationPermission( |
440 web_contents(), RequestID(0), requesting_frame, true); | 440 web_contents(), RequestID(0), requesting_frame, true); |
441 ASSERT_EQ(1U, infobar_service()->infobar_count()); | 441 ASSERT_EQ(1U, infobar_service()->infobar_count()); |
442 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); | 442 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); |
443 ConfirmInfoBarDelegate* infobar_delegate = | 443 ConfirmInfoBarDelegate* infobar_delegate = |
444 infobar->delegate()->AsConfirmInfoBarDelegate(); | 444 infobar->delegate()->AsConfirmInfoBarDelegate(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 web_contents(), RequestID(1), requesting_frame_1, true); | 522 web_contents(), RequestID(1), requesting_frame_1, true); |
523 // Ensure only one infobar is created. | 523 // Ensure only one infobar is created. |
524 ASSERT_EQ(1U, GetNumberOfPrompts()); | 524 ASSERT_EQ(1U, GetNumberOfPrompts()); |
525 base::string16 text_0 = GetPromptText(); | 525 base::string16 text_0 = GetPromptText(); |
526 | 526 |
527 // Accept the first frame. | 527 // Accept the first frame. |
528 AcceptPrompt(); | 528 AcceptPrompt(); |
529 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); | 529 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); |
530 CheckPermissionMessageSent(0, true); | 530 CheckPermissionMessageSent(0, true); |
531 | 531 |
532 #if BUILDFLAG(ANDROID_JAVA_UI) | 532 #if defined(OS_ANDROID) |
533 infobars::InfoBar* infobar_0 = infobar_service()->infobar_at(0); | 533 infobars::InfoBar* infobar_0 = infobar_service()->infobar_at(0); |
534 infobar_service()->RemoveInfoBar(infobar_0); | 534 infobar_service()->RemoveInfoBar(infobar_0); |
535 EXPECT_EQ(1U, closed_infobar_tracker_.size()); | 535 EXPECT_EQ(1U, closed_infobar_tracker_.size()); |
536 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_0)); | 536 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_0)); |
537 closed_infobar_tracker_.Clear(); | 537 closed_infobar_tracker_.Clear(); |
538 #endif | 538 #endif |
539 | 539 |
540 // Now we should have a new infobar for the second frame. | 540 // Now we should have a new infobar for the second frame. |
541 ASSERT_EQ(1U, GetNumberOfPrompts()); | 541 ASSERT_EQ(1U, GetNumberOfPrompts()); |
542 base::string16 text_1 = GetPromptText(); | 542 base::string16 text_1 = GetPromptText(); |
543 | 543 |
544 // Check that the messages differ. | 544 // Check that the messages differ. |
545 EXPECT_NE(text_0, text_1); | 545 EXPECT_NE(text_0, text_1); |
546 | 546 |
547 // Cancel (block) this frame. | 547 // Cancel (block) this frame. |
548 #if !BUILDFLAG(ANDROID_JAVA_UI) | 548 #if !defined(OS_ANDROID) |
549 PermissionRequestManager* manager = | 549 PermissionRequestManager* manager = |
550 PermissionRequestManager::FromWebContents(web_contents()); | 550 PermissionRequestManager::FromWebContents(web_contents()); |
551 DenyBubble(manager); | 551 DenyBubble(manager); |
552 #else | 552 #else |
553 infobars::InfoBar* infobar_1 = infobar_service()->infobar_at(0); | 553 infobars::InfoBar* infobar_1 = infobar_service()->infobar_at(0); |
554 infobar_1->delegate()->AsConfirmInfoBarDelegate()->Cancel(); | 554 infobar_1->delegate()->AsConfirmInfoBarDelegate()->Cancel(); |
555 #endif | 555 #endif |
556 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK); | 556 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK); |
557 CheckPermissionMessageSent(1, false); | 557 CheckPermissionMessageSent(1, false); |
558 | 558 |
559 // Ensure the persisted permissions are ok. | 559 // Ensure the persisted permissions are ok. |
560 EXPECT_EQ( | 560 EXPECT_EQ( |
561 CONTENT_SETTING_ALLOW, | 561 CONTENT_SETTING_ALLOW, |
562 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); | 562 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); |
563 EXPECT_EQ( | 563 EXPECT_EQ( |
564 CONTENT_SETTING_BLOCK, | 564 CONTENT_SETTING_BLOCK, |
565 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); | 565 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); |
566 } | 566 } |
567 | 567 |
568 TEST_F(GeolocationPermissionContextTests, HashIsIgnored) { | 568 TEST_F(GeolocationPermissionContextTests, HashIsIgnored) { |
569 GURL url_a("https://www.example.com/geolocation#a"); | 569 GURL url_a("https://www.example.com/geolocation#a"); |
570 GURL url_b("https://www.example.com/geolocation#b"); | 570 GURL url_b("https://www.example.com/geolocation#b"); |
571 | 571 |
572 // Navigate to the first url. | 572 // Navigate to the first url. |
573 NavigateAndCommit(url_a); | 573 NavigateAndCommit(url_a); |
574 RequestManagerDocumentLoadCompleted(); | 574 RequestManagerDocumentLoadCompleted(); |
575 | 575 |
576 // Check permission is requested. | 576 // Check permission is requested. |
577 ASSERT_EQ(0U, GetNumberOfPrompts()); | 577 ASSERT_EQ(0U, GetNumberOfPrompts()); |
578 #if BUILDFLAG(ANDROID_JAVA_UI) | 578 #if defined(OS_ANDROID) |
579 const bool user_gesture = false; | 579 const bool user_gesture = false; |
580 #else | 580 #else |
581 const bool user_gesture = true; | 581 const bool user_gesture = true; |
582 #endif | 582 #endif |
583 RequestGeolocationPermission(web_contents(), RequestID(0), url_a, | 583 RequestGeolocationPermission(web_contents(), RequestID(0), url_a, |
584 user_gesture); | 584 user_gesture); |
585 ASSERT_EQ(1U, GetNumberOfPrompts()); | 585 ASSERT_EQ(1U, GetNumberOfPrompts()); |
586 | 586 |
587 // Change the hash, we'll still be on the same page. | 587 // Change the hash, we'll still be on the same page. |
588 NavigateAndCommit(url_b); | 588 NavigateAndCommit(url_b); |
589 RequestManagerDocumentLoadCompleted(); | 589 RequestManagerDocumentLoadCompleted(); |
590 | 590 |
591 // Accept. | 591 // Accept. |
592 AcceptPrompt(); | 592 AcceptPrompt(); |
593 CheckTabContentsState(url_a, CONTENT_SETTING_ALLOW); | 593 CheckTabContentsState(url_a, CONTENT_SETTING_ALLOW); |
594 CheckTabContentsState(url_b, CONTENT_SETTING_ALLOW); | 594 CheckTabContentsState(url_b, CONTENT_SETTING_ALLOW); |
595 CheckPermissionMessageSent(0, true); | 595 CheckPermissionMessageSent(0, true); |
596 | 596 |
597 // Cleanup. | 597 // Cleanup. |
598 #if BUILDFLAG(ANDROID_JAVA_UI) | 598 #if defined(OS_ANDROID) |
599 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); | 599 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); |
600 infobar_service()->RemoveInfoBar(infobar); | 600 infobar_service()->RemoveInfoBar(infobar); |
601 EXPECT_EQ(1U, closed_infobar_tracker_.size()); | 601 EXPECT_EQ(1U, closed_infobar_tracker_.size()); |
602 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar)); | 602 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar)); |
603 #endif | 603 #endif |
604 } | 604 } |
605 | 605 |
606 // TODO(felt): The bubble is rejecting file:// permission requests. | 606 // TODO(felt): The bubble is rejecting file:// permission requests. |
607 // Fix and enable this test. crbug.com/444047 | 607 // Fix and enable this test. crbug.com/444047 |
608 #if BUILDFLAG(ANDROID_JAVA_UI) | 608 #if defined(OS_ANDROID) |
609 #define MAYBE_PermissionForFileScheme PermissionForFileScheme | 609 #define MAYBE_PermissionForFileScheme PermissionForFileScheme |
610 #else | 610 #else |
611 #define MAYBE_PermissionForFileScheme DISABLED_PermissionForFileScheme | 611 #define MAYBE_PermissionForFileScheme DISABLED_PermissionForFileScheme |
612 #endif | 612 #endif |
613 TEST_F(GeolocationPermissionContextTests, MAYBE_PermissionForFileScheme) { | 613 TEST_F(GeolocationPermissionContextTests, MAYBE_PermissionForFileScheme) { |
614 GURL requesting_frame("file://example/geolocation.html"); | 614 GURL requesting_frame("file://example/geolocation.html"); |
615 NavigateAndCommit(requesting_frame); | 615 NavigateAndCommit(requesting_frame); |
616 RequestManagerDocumentLoadCompleted(); | 616 RequestManagerDocumentLoadCompleted(); |
617 | 617 |
618 // Check permission is requested. | 618 // Check permission is requested. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 web_contents(), RequestID(0), frame_0, true); | 650 web_contents(), RequestID(0), frame_0, true); |
651 RequestGeolocationPermission( | 651 RequestGeolocationPermission( |
652 web_contents(), RequestID(1), frame_1, true); | 652 web_contents(), RequestID(1), frame_1, true); |
653 | 653 |
654 // Get the first permission request text. | 654 // Get the first permission request text. |
655 ASSERT_EQ(1U, GetNumberOfPrompts()); | 655 ASSERT_EQ(1U, GetNumberOfPrompts()); |
656 base::string16 text_0 = GetPromptText(); | 656 base::string16 text_0 = GetPromptText(); |
657 ASSERT_FALSE(text_0.empty()); | 657 ASSERT_FALSE(text_0.empty()); |
658 | 658 |
659 // Simulate the frame going away; the request should be removed. | 659 // Simulate the frame going away; the request should be removed. |
660 #if !BUILDFLAG(ANDROID_JAVA_UI) | 660 #if !defined(OS_ANDROID) |
661 PermissionRequestManager* manager = | 661 PermissionRequestManager* manager = |
662 PermissionRequestManager::FromWebContents(web_contents()); | 662 PermissionRequestManager::FromWebContents(web_contents()); |
663 CloseBubble(manager); | 663 CloseBubble(manager); |
664 #else | 664 #else |
665 geolocation_permission_context_->CancelPermissionRequest(web_contents(), | 665 geolocation_permission_context_->CancelPermissionRequest(web_contents(), |
666 RequestID(0)); | 666 RequestID(0)); |
667 #endif | 667 #endif |
668 | 668 |
669 // Check that the next pending request is created correctly. | 669 // Check that the next pending request is created correctly. |
670 base::string16 text_1 = GetPromptText(); | 670 base::string16 text_1 = GetPromptText(); |
(...skipping 28 matching lines...) Expand all Loading... |
699 | 699 |
700 TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { | 700 TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { |
701 GURL url_a("https://www.example.com/geolocation"); | 701 GURL url_a("https://www.example.com/geolocation"); |
702 GURL url_b("https://www.example-2.com/geolocation"); | 702 GURL url_b("https://www.example-2.com/geolocation"); |
703 NavigateAndCommit(url_a); // Tab A0 | 703 NavigateAndCommit(url_a); // Tab A0 |
704 AddNewTab(url_b); // Tab B (extra_tabs_[0]) | 704 AddNewTab(url_b); // Tab B (extra_tabs_[0]) |
705 AddNewTab(url_a); // Tab A1 (extra_tabs_[1]) | 705 AddNewTab(url_a); // Tab A1 (extra_tabs_[1]) |
706 RequestManagerDocumentLoadCompleted(); | 706 RequestManagerDocumentLoadCompleted(); |
707 RequestManagerDocumentLoadCompleted(extra_tabs_[0].get()); | 707 RequestManagerDocumentLoadCompleted(extra_tabs_[0].get()); |
708 RequestManagerDocumentLoadCompleted(extra_tabs_[1].get()); | 708 RequestManagerDocumentLoadCompleted(extra_tabs_[1].get()); |
709 #if !BUILDFLAG(ANDROID_JAVA_UI) | 709 #if !defined(OS_ANDROID) |
710 PermissionRequestManager* manager_a0 = | 710 PermissionRequestManager* manager_a0 = |
711 PermissionRequestManager::FromWebContents(web_contents()); | 711 PermissionRequestManager::FromWebContents(web_contents()); |
712 PermissionRequestManager* manager_b = | 712 PermissionRequestManager* manager_b = |
713 PermissionRequestManager::FromWebContents(extra_tabs_[0].get()); | 713 PermissionRequestManager::FromWebContents(extra_tabs_[0].get()); |
714 PermissionRequestManager* manager_a1 = | 714 PermissionRequestManager* manager_a1 = |
715 PermissionRequestManager::FromWebContents(extra_tabs_[1].get()); | 715 PermissionRequestManager::FromWebContents(extra_tabs_[1].get()); |
716 #endif | 716 #endif |
717 | 717 |
718 // Request permission in all three tabs. | 718 // Request permission in all three tabs. |
719 RequestGeolocationPermission( | 719 RequestGeolocationPermission( |
720 web_contents(), RequestID(0), url_a, true); | 720 web_contents(), RequestID(0), url_a, true); |
721 RequestGeolocationPermission( | 721 RequestGeolocationPermission( |
722 extra_tabs_[0].get(), RequestIDForTab(0, 0), url_b, true); | 722 extra_tabs_[0].get(), RequestIDForTab(0, 0), url_b, true); |
723 RequestGeolocationPermission( | 723 RequestGeolocationPermission( |
724 extra_tabs_[1].get(), RequestIDForTab(1, 0), url_a, true); | 724 extra_tabs_[1].get(), RequestIDForTab(1, 0), url_a, true); |
725 ASSERT_EQ(1U, GetNumberOfPrompts()); // For A0. | 725 ASSERT_EQ(1U, GetNumberOfPrompts()); // For A0. |
726 #if !BUILDFLAG(ANDROID_JAVA_UI) | 726 #if !defined(OS_ANDROID) |
727 ASSERT_EQ(1U, GetBubblesQueueSize(manager_b)); | 727 ASSERT_EQ(1U, GetBubblesQueueSize(manager_b)); |
728 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); | 728 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); |
729 #else | 729 #else |
730 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); | 730 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); |
731 ASSERT_EQ(1U, infobar_service_for_tab(1)->infobar_count()); | 731 ASSERT_EQ(1U, infobar_service_for_tab(1)->infobar_count()); |
732 #endif | 732 #endif |
733 | 733 |
734 // Accept the permission in tab A0. | 734 // Accept the permission in tab A0. |
735 #if !BUILDFLAG(ANDROID_JAVA_UI) | 735 #if !defined(OS_ANDROID) |
736 AcceptBubble(manager_a0); | 736 AcceptBubble(manager_a0); |
737 #else | 737 #else |
738 infobars::InfoBar* infobar_a0 = infobar_service()->infobar_at(0); | 738 infobars::InfoBar* infobar_a0 = infobar_service()->infobar_at(0); |
739 ConfirmInfoBarDelegate* infobar_delegate_a0 = | 739 ConfirmInfoBarDelegate* infobar_delegate_a0 = |
740 infobar_a0->delegate()->AsConfirmInfoBarDelegate(); | 740 infobar_a0->delegate()->AsConfirmInfoBarDelegate(); |
741 ASSERT_TRUE(infobar_delegate_a0); | 741 ASSERT_TRUE(infobar_delegate_a0); |
742 infobar_delegate_a0->Accept(); | 742 infobar_delegate_a0->Accept(); |
743 infobar_service()->RemoveInfoBar(infobar_a0); | 743 infobar_service()->RemoveInfoBar(infobar_a0); |
744 EXPECT_EQ(2U, closed_infobar_tracker_.size()); | 744 EXPECT_EQ(2U, closed_infobar_tracker_.size()); |
745 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a0)); | 745 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a0)); |
746 #endif | 746 #endif |
747 CheckPermissionMessageSent(0, true); | 747 CheckPermissionMessageSent(0, true); |
748 // Because they're the same origin, this will cause tab A1's infobar to | 748 // Because they're the same origin, this will cause tab A1's infobar to |
749 // disappear. It does not cause the bubble to disappear: crbug.com/443013. | 749 // disappear. It does not cause the bubble to disappear: crbug.com/443013. |
750 // TODO(felt): Update this test when the bubble's behavior is changed. | 750 // TODO(felt): Update this test when the bubble's behavior is changed. |
751 // Either way, tab B should still have a pending permission request. | 751 // Either way, tab B should still have a pending permission request. |
752 #if !BUILDFLAG(ANDROID_JAVA_UI) | 752 #if !defined(OS_ANDROID) |
753 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); | 753 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); |
754 ASSERT_EQ(1U, GetBubblesQueueSize(manager_b)); | 754 ASSERT_EQ(1U, GetBubblesQueueSize(manager_b)); |
755 #else | 755 #else |
756 CheckPermissionMessageSentForTab(1, 0, true); | 756 CheckPermissionMessageSentForTab(1, 0, true); |
757 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); | 757 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); |
758 #endif | 758 #endif |
759 } | 759 } |
760 | 760 |
761 TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { | 761 TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { |
762 GURL url_a("https://www.example.com/geolocation"); | 762 GURL url_a("https://www.example.com/geolocation"); |
763 GURL url_b("https://www.example-2.com/geolocation"); | 763 GURL url_b("https://www.example-2.com/geolocation"); |
764 NavigateAndCommit(url_a); // Tab A0. | 764 NavigateAndCommit(url_a); // Tab A0. |
765 AddNewTab(url_a); // Tab A1. | 765 AddNewTab(url_a); // Tab A1. |
766 #if !BUILDFLAG(ANDROID_JAVA_UI) | 766 #if !defined(OS_ANDROID) |
767 RequestManagerDocumentLoadCompleted(); | 767 RequestManagerDocumentLoadCompleted(); |
768 RequestManagerDocumentLoadCompleted(extra_tabs_[0].get()); | 768 RequestManagerDocumentLoadCompleted(extra_tabs_[0].get()); |
769 PermissionRequestManager* manager_a0 = | 769 PermissionRequestManager* manager_a0 = |
770 PermissionRequestManager::FromWebContents(web_contents()); | 770 PermissionRequestManager::FromWebContents(web_contents()); |
771 PermissionRequestManager* manager_a1 = | 771 PermissionRequestManager* manager_a1 = |
772 PermissionRequestManager::FromWebContents(extra_tabs_[0].get()); | 772 PermissionRequestManager::FromWebContents(extra_tabs_[0].get()); |
773 #endif | 773 #endif |
774 | 774 |
775 // Request permission in both tabs; the extra tab will have two permission | 775 // Request permission in both tabs; the extra tab will have two permission |
776 // requests from two origins. | 776 // requests from two origins. |
777 RequestGeolocationPermission( | 777 RequestGeolocationPermission( |
778 web_contents(), RequestID(0), url_a, true); | 778 web_contents(), RequestID(0), url_a, true); |
779 RequestGeolocationPermission( | 779 RequestGeolocationPermission( |
780 extra_tabs_[0].get(), RequestIDForTab(0, 0), url_a, true); | 780 extra_tabs_[0].get(), RequestIDForTab(0, 0), url_a, true); |
781 RequestGeolocationPermission( | 781 RequestGeolocationPermission( |
782 extra_tabs_[0].get(), RequestIDForTab(0, 1), url_b, true); | 782 extra_tabs_[0].get(), RequestIDForTab(0, 1), url_b, true); |
783 #if !BUILDFLAG(ANDROID_JAVA_UI) | 783 #if !defined(OS_ANDROID) |
784 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a0)); | 784 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a0)); |
785 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); | 785 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); |
786 #else | 786 #else |
787 ASSERT_EQ(1U, infobar_service()->infobar_count()); | 787 ASSERT_EQ(1U, infobar_service()->infobar_count()); |
788 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); | 788 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); |
789 #endif | 789 #endif |
790 | 790 |
791 // Accept the first request in tab A1. | 791 // Accept the first request in tab A1. |
792 #if !BUILDFLAG(ANDROID_JAVA_UI) | 792 #if !defined(OS_ANDROID) |
793 AcceptBubble(manager_a1); | 793 AcceptBubble(manager_a1); |
794 #else | 794 #else |
795 infobars::InfoBar* infobar_a1 = infobar_service_for_tab(0)->infobar_at(0); | 795 infobars::InfoBar* infobar_a1 = infobar_service_for_tab(0)->infobar_at(0); |
796 ConfirmInfoBarDelegate* infobar_delegate_a1 = | 796 ConfirmInfoBarDelegate* infobar_delegate_a1 = |
797 infobar_a1->delegate()->AsConfirmInfoBarDelegate(); | 797 infobar_a1->delegate()->AsConfirmInfoBarDelegate(); |
798 ASSERT_TRUE(infobar_delegate_a1); | 798 ASSERT_TRUE(infobar_delegate_a1); |
799 infobar_delegate_a1->Accept(); | 799 infobar_delegate_a1->Accept(); |
800 infobar_service_for_tab(0)->RemoveInfoBar(infobar_a1); | 800 infobar_service_for_tab(0)->RemoveInfoBar(infobar_a1); |
801 EXPECT_EQ(2U, closed_infobar_tracker_.size()); | 801 EXPECT_EQ(2U, closed_infobar_tracker_.size()); |
802 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a1)); | 802 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a1)); |
803 #endif | 803 #endif |
804 CheckPermissionMessageSentForTab(0, 0, true); | 804 CheckPermissionMessageSentForTab(0, 0, true); |
805 | 805 |
806 // Because they're the same origin, this will cause tab A0's infobar to | 806 // Because they're the same origin, this will cause tab A0's infobar to |
807 // disappear. It does not cause the bubble to disappear: crbug.com/443013. | 807 // disappear. It does not cause the bubble to disappear: crbug.com/443013. |
808 // TODO(felt): Update this test when the bubble's behavior is changed. | 808 // TODO(felt): Update this test when the bubble's behavior is changed. |
809 #if !BUILDFLAG(ANDROID_JAVA_UI) | 809 #if !defined(OS_ANDROID) |
810 EXPECT_EQ(1U, GetBubblesQueueSize(manager_a0)); | 810 EXPECT_EQ(1U, GetBubblesQueueSize(manager_a0)); |
811 #else | 811 #else |
812 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 812 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
813 CheckPermissionMessageSent(0, true); | 813 CheckPermissionMessageSent(0, true); |
814 #endif | 814 #endif |
815 | 815 |
816 // The second request should now be visible in tab A1. | 816 // The second request should now be visible in tab A1. |
817 #if !BUILDFLAG(ANDROID_JAVA_UI) | 817 #if !defined(OS_ANDROID) |
818 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); | 818 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); |
819 #else | 819 #else |
820 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); | 820 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); |
821 #endif | 821 #endif |
822 | 822 |
823 // Accept the second request and check that it's gone. | 823 // Accept the second request and check that it's gone. |
824 #if !BUILDFLAG(ANDROID_JAVA_UI) | 824 #if !defined(OS_ANDROID) |
825 AcceptBubble(manager_a1); | 825 AcceptBubble(manager_a1); |
826 EXPECT_EQ(0U, GetBubblesQueueSize(manager_a1)); | 826 EXPECT_EQ(0U, GetBubblesQueueSize(manager_a1)); |
827 #else | 827 #else |
828 infobars::InfoBar* infobar_1 = infobar_service_for_tab(0)->infobar_at(0); | 828 infobars::InfoBar* infobar_1 = infobar_service_for_tab(0)->infobar_at(0); |
829 ConfirmInfoBarDelegate* infobar_delegate_1 = | 829 ConfirmInfoBarDelegate* infobar_delegate_1 = |
830 infobar_1->delegate()->AsConfirmInfoBarDelegate(); | 830 infobar_1->delegate()->AsConfirmInfoBarDelegate(); |
831 ASSERT_TRUE(infobar_delegate_1); | 831 ASSERT_TRUE(infobar_delegate_1); |
832 infobar_delegate_1->Accept(); | 832 infobar_delegate_1->Accept(); |
833 #endif | 833 #endif |
834 } | 834 } |
(...skipping 14 matching lines...) Expand all Loading... |
849 // Request permission for two frames. | 849 // Request permission for two frames. |
850 RequestGeolocationPermission( | 850 RequestGeolocationPermission( |
851 web_contents(), RequestID(0), requesting_frame_0, false); | 851 web_contents(), RequestID(0), requesting_frame_0, false); |
852 RequestGeolocationPermission( | 852 RequestGeolocationPermission( |
853 web_contents(), RequestID(1), requesting_frame_1, false); | 853 web_contents(), RequestID(1), requesting_frame_1, false); |
854 | 854 |
855 // Ensure only one prompt is created. | 855 // Ensure only one prompt is created. |
856 ASSERT_EQ(1U, GetNumberOfPrompts()); | 856 ASSERT_EQ(1U, GetNumberOfPrompts()); |
857 | 857 |
858 // Delete the tab contents. | 858 // Delete the tab contents. |
859 #if BUILDFLAG(ANDROID_JAVA_UI) | 859 #if defined(OS_ANDROID) |
860 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); | 860 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); |
861 DeleteContents(); | 861 DeleteContents(); |
862 ASSERT_EQ(1U, closed_infobar_tracker_.size()); | 862 ASSERT_EQ(1U, closed_infobar_tracker_.size()); |
863 ASSERT_TRUE(closed_infobar_tracker_.Contains(infobar)); | 863 ASSERT_TRUE(closed_infobar_tracker_.Contains(infobar)); |
864 #endif | 864 #endif |
865 | 865 |
866 // The content settings should not have changed. | 866 // The content settings should not have changed. |
867 EXPECT_EQ( | 867 EXPECT_EQ( |
868 CONTENT_SETTING_ASK, | 868 CONTENT_SETTING_ASK, |
869 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); | 869 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 RequestGeolocationPermission( | 947 RequestGeolocationPermission( |
948 web_contents(), RequestID(0), requesting_frame_0, false); | 948 web_contents(), RequestID(0), requesting_frame_0, false); |
949 RequestGeolocationPermission( | 949 RequestGeolocationPermission( |
950 web_contents(), RequestID(1), requesting_frame_1, false); | 950 web_contents(), RequestID(1), requesting_frame_1, false); |
951 | 951 |
952 // Ensure only one infobar is created. | 952 // Ensure only one infobar is created. |
953 ASSERT_EQ(1U, GetNumberOfPrompts()); | 953 ASSERT_EQ(1U, GetNumberOfPrompts()); |
954 | 954 |
955 // Accept the first frame. | 955 // Accept the first frame. |
956 AcceptPrompt(); | 956 AcceptPrompt(); |
957 #if BUILDFLAG(ANDROID_JAVA_UI) | 957 #if defined(OS_ANDROID) |
958 infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); | 958 infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); |
959 #endif | 959 #endif |
960 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); | 960 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); |
961 CheckPermissionMessageSent(0, true); | 961 CheckPermissionMessageSent(0, true); |
962 | 962 |
963 // Verify that accepting the first didn't accept because it's embedded | 963 // Verify that accepting the first didn't accept because it's embedded |
964 // in the other. | 964 // in the other. |
965 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 965 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
966 requesting_frame_0.GetOrigin(), | 966 requesting_frame_0.GetOrigin(), |
967 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 967 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
968 10); | 968 10); |
969 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 969 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
970 requesting_frame_0.GetOrigin(), | 970 requesting_frame_0.GetOrigin(), |
971 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 971 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
972 0); | 972 0); |
973 | 973 |
974 ASSERT_EQ(1U, GetNumberOfPrompts()); | 974 ASSERT_EQ(1U, GetNumberOfPrompts()); |
975 | 975 |
976 test_clock->Advance(base::TimeDelta::FromSeconds(1)); | 976 test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
977 | 977 |
978 // Allow the second frame. | 978 // Allow the second frame. |
979 AcceptPrompt(); | 979 AcceptPrompt(); |
980 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW); | 980 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW); |
981 CheckPermissionMessageSent(1, true); | 981 CheckPermissionMessageSent(1, true); |
982 #if BUILDFLAG(ANDROID_JAVA_UI) | 982 #if defined(OS_ANDROID) |
983 infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); | 983 infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); |
984 #endif | 984 #endif |
985 | 985 |
986 // Verify that the times are different. | 986 // Verify that the times are different. |
987 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 987 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
988 requesting_frame_0.GetOrigin(), | 988 requesting_frame_0.GetOrigin(), |
989 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 989 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
990 10); | 990 10); |
991 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 991 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
992 requesting_frame_0.GetOrigin(), | 992 requesting_frame_0.GetOrigin(), |
993 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 993 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
994 11); | 994 11); |
995 | 995 |
996 test_clock->Advance(base::TimeDelta::FromSeconds(2)); | 996 test_clock->Advance(base::TimeDelta::FromSeconds(2)); |
997 RequestGeolocationPermission( | 997 RequestGeolocationPermission( |
998 web_contents(), RequestID(0), requesting_frame_0, false); | 998 web_contents(), RequestID(0), requesting_frame_0, false); |
999 | 999 |
1000 // Verify that requesting permission in one frame doesn't update other where | 1000 // Verify that requesting permission in one frame doesn't update other where |
1001 // it is the embedder. | 1001 // it is the embedder. |
1002 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 1002 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
1003 requesting_frame_0.GetOrigin(), | 1003 requesting_frame_0.GetOrigin(), |
1004 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 1004 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
1005 13); | 1005 13); |
1006 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 1006 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
1007 requesting_frame_0.GetOrigin(), | 1007 requesting_frame_0.GetOrigin(), |
1008 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 1008 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
1009 11); | 1009 11); |
1010 } | 1010 } |
OLD | NEW |