Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: chrome/browser/geolocation/geolocation_permission_context_unittest.cc

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
37 #include "content/public/browser/notification_registrar.h" 37 #include "content/public/browser/notification_registrar.h"
38 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
39 #include "content/public/browser/render_frame_host.h" 39 #include "content/public/browser/render_frame_host.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 #include "content/public/test/mock_render_process_host.h" 41 #include "content/public/test/mock_render_process_host.h"
42 #include "content/public/test/test_renderer_host.h" 42 #include "content/public/test/test_renderer_host.h"
43 #include "content/public/test/test_utils.h" 43 #include "content/public/test/test_utils.h"
44 #include "content/public/test/web_contents_tester.h" 44 #include "content/public/test/web_contents_tester.h"
45 #include "testing/gtest/include/gtest/gtest.h" 45 #include "testing/gtest/include/gtest/gtest.h"
46 46
47 #if defined(OS_ANDROID) 47 #if defined(ANDROID_JAVA_UI)
48 #include "base/prefs/pref_service.h" 48 #include "base/prefs/pref_service.h"
49 #include "chrome/browser/android/mock_location_settings.h" 49 #include "chrome/browser/android/mock_location_settings.h"
50 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" 50 #include "chrome/browser/geolocation/geolocation_permission_context_android.h"
51 #else 51 #else
52 #include "chrome/browser/ui/website_settings/mock_permission_bubble_view.h" 52 #include "chrome/browser/ui/website_settings/mock_permission_bubble_view.h"
53 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 53 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
54 #endif 54 #endif
55 55
56 #if defined(ENABLE_EXTENSIONS) 56 #if defined(ENABLE_EXTENSIONS)
57 #include "extensions/browser/view_type_utils.h" 57 #include "extensions/browser/view_type_utils.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 void PermissionResponse(const PermissionRequestID& id, 136 void PermissionResponse(const PermissionRequestID& id,
137 ContentSetting content_setting); 137 ContentSetting content_setting);
138 void CheckPermissionMessageSent(int request_id, bool allowed); 138 void CheckPermissionMessageSent(int request_id, bool allowed);
139 void CheckPermissionMessageSentForTab(int tab, int request_id, bool allowed); 139 void CheckPermissionMessageSentForTab(int tab, int request_id, bool allowed);
140 void CheckPermissionMessageSentInternal(MockRenderProcessHost* process, 140 void CheckPermissionMessageSentInternal(MockRenderProcessHost* process,
141 int request_id, 141 int request_id,
142 bool allowed); 142 bool allowed);
143 void AddNewTab(const GURL& url); 143 void AddNewTab(const GURL& url);
144 void CheckTabContentsState(const GURL& requesting_frame, 144 void CheckTabContentsState(const GURL& requesting_frame,
145 ContentSetting expected_content_setting); 145 ContentSetting expected_content_setting);
146 #if !defined(OS_ANDROID) 146 #if !defined(ANDROID_JAVA_UI)
147 size_t GetBubblesQueueSize(PermissionBubbleManager* manager); 147 size_t GetBubblesQueueSize(PermissionBubbleManager* manager);
148 void AcceptBubble(PermissionBubbleManager* manager); 148 void AcceptBubble(PermissionBubbleManager* manager);
149 void DenyBubble(PermissionBubbleManager* manager); 149 void DenyBubble(PermissionBubbleManager* manager);
150 void CloseBubble(PermissionBubbleManager* manager); 150 void CloseBubble(PermissionBubbleManager* manager);
151 #endif 151 #endif
152 void BubbleManagerDocumentLoadCompleted(); 152 void BubbleManagerDocumentLoadCompleted();
153 void BubbleManagerDocumentLoadCompleted(content::WebContents* web_contents); 153 void BubbleManagerDocumentLoadCompleted(content::WebContents* web_contents);
154 ContentSetting GetGeolocationContentSetting(GURL frame_0, GURL frame_1); 154 ContentSetting GetGeolocationContentSetting(GURL frame_0, GURL frame_1);
155 size_t GetNumberOfPrompts(); 155 size_t GetNumberOfPrompts();
156 void AcceptPrompt(); 156 void AcceptPrompt();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 new_tab->GetController().LoadURL( 232 new_tab->GetController().LoadURL(
233 url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 233 url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
234 content::NavigationEntry* entry = new_tab->GetController().GetPendingEntry(); 234 content::NavigationEntry* entry = new_tab->GetController().GetPendingEntry();
235 content::RenderFrameHostTester::For(new_tab->GetMainFrame()) 235 content::RenderFrameHostTester::For(new_tab->GetMainFrame())
236 ->SendNavigate(extra_tabs_.size() + 1, entry->GetUniqueID(), true, url); 236 ->SendNavigate(extra_tabs_.size() + 1, entry->GetUniqueID(), true, url);
237 237
238 // Set up required helpers, and make this be as "tabby" as the code requires. 238 // Set up required helpers, and make this be as "tabby" as the code requires.
239 #if defined(ENABLE_EXTENSIONS) 239 #if defined(ENABLE_EXTENSIONS)
240 extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS); 240 extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS);
241 #endif 241 #endif
242 #if defined(OS_ANDROID) 242 #if defined(ANDROID_JAVA_UI)
243 InfoBarService::CreateForWebContents(new_tab); 243 InfoBarService::CreateForWebContents(new_tab);
244 #else 244 #else
245 PermissionBubbleManager::CreateForWebContents(new_tab); 245 PermissionBubbleManager::CreateForWebContents(new_tab);
246 PermissionBubbleManager* permission_bubble_manager = 246 PermissionBubbleManager* permission_bubble_manager =
247 PermissionBubbleManager::FromWebContents(new_tab); 247 PermissionBubbleManager::FromWebContents(new_tab);
248 MockPermissionBubbleView::SetFactory(permission_bubble_manager, false); 248 MockPermissionBubbleView::SetFactory(permission_bubble_manager, false);
249 permission_bubble_manager->DisplayPendingRequests(); 249 permission_bubble_manager->DisplayPendingRequests();
250 #endif 250 #endif
251 251
252 extra_tabs_.push_back(new_tab); 252 extra_tabs_.push_back(new_tab);
(...skipping 19 matching lines...) Expand all
272 ChromeRenderViewHostTestHarness::SetUp(); 272 ChromeRenderViewHostTestHarness::SetUp();
273 273
274 // Set up required helpers, and make this be as "tabby" as the code requires. 274 // Set up required helpers, and make this be as "tabby" as the code requires.
275 #if defined(ENABLE_EXTENSIONS) 275 #if defined(ENABLE_EXTENSIONS)
276 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS); 276 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS);
277 #endif 277 #endif
278 InfoBarService::CreateForWebContents(web_contents()); 278 InfoBarService::CreateForWebContents(web_contents());
279 TabSpecificContentSettings::CreateForWebContents(web_contents()); 279 TabSpecificContentSettings::CreateForWebContents(web_contents());
280 geolocation_permission_context_ = 280 geolocation_permission_context_ =
281 GeolocationPermissionContextFactory::GetForProfile(profile()); 281 GeolocationPermissionContextFactory::GetForProfile(profile());
282 #if defined(OS_ANDROID) 282 #if defined(ANDROID_JAVA_UI)
283 static_cast<GeolocationPermissionContextAndroid*>( 283 static_cast<GeolocationPermissionContextAndroid*>(
284 geolocation_permission_context_) 284 geolocation_permission_context_)
285 ->SetLocationSettingsForTesting( 285 ->SetLocationSettingsForTesting(
286 scoped_ptr<LocationSettings>(new MockLocationSettings())); 286 scoped_ptr<LocationSettings>(new MockLocationSettings()));
287 MockLocationSettings::SetLocationStatus(true, true); 287 MockLocationSettings::SetLocationStatus(true, true);
288 #else 288 #else
289 PermissionBubbleManager::CreateForWebContents(web_contents()); 289 PermissionBubbleManager::CreateForWebContents(web_contents());
290 PermissionBubbleManager* permission_bubble_manager = 290 PermissionBubbleManager* permission_bubble_manager =
291 PermissionBubbleManager::FromWebContents(web_contents()); 291 PermissionBubbleManager::FromWebContents(web_contents());
292 MockPermissionBubbleView::SetFactory(permission_bubble_manager, false); 292 MockPermissionBubbleView::SetFactory(permission_bubble_manager, false);
293 permission_bubble_manager->DisplayPendingRequests(); 293 permission_bubble_manager->DisplayPendingRequests();
294 #endif 294 #endif
295 } 295 }
296 296
297 void GeolocationPermissionContextTests::TearDown() { 297 void GeolocationPermissionContextTests::TearDown() {
298 extra_tabs_.clear(); 298 extra_tabs_.clear();
299 ChromeRenderViewHostTestHarness::TearDown(); 299 ChromeRenderViewHostTestHarness::TearDown();
300 } 300 }
301 301
302 #if !defined(OS_ANDROID) 302 #if !defined(ANDROID_JAVA_UI)
303 size_t GeolocationPermissionContextTests::GetBubblesQueueSize( 303 size_t GeolocationPermissionContextTests::GetBubblesQueueSize(
304 PermissionBubbleManager* manager) { 304 PermissionBubbleManager* manager) {
305 return manager->requests_.size(); 305 return manager->requests_.size();
306 } 306 }
307 307
308 void GeolocationPermissionContextTests::AcceptBubble( 308 void GeolocationPermissionContextTests::AcceptBubble(
309 PermissionBubbleManager* manager) { 309 PermissionBubbleManager* manager) {
310 manager->Accept(); 310 manager->Accept();
311 } 311 }
312 312
313 void GeolocationPermissionContextTests::DenyBubble( 313 void GeolocationPermissionContextTests::DenyBubble(
314 PermissionBubbleManager* manager) { 314 PermissionBubbleManager* manager) {
315 manager->Deny(); 315 manager->Deny();
316 } 316 }
317 317
318 void GeolocationPermissionContextTests::CloseBubble( 318 void GeolocationPermissionContextTests::CloseBubble(
319 PermissionBubbleManager* manager) { 319 PermissionBubbleManager* manager) {
320 manager->Closing(); 320 manager->Closing();
321 } 321 }
322 #endif 322 #endif
323 323
324 void GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted() { 324 void GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted() {
325 GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted( 325 GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted(
326 web_contents()); 326 web_contents());
327 } 327 }
328 328
329 void GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted( 329 void GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted(
330 content::WebContents* web_contents) { 330 content::WebContents* web_contents) {
331 #if !defined(OS_ANDROID) 331 #if !defined(ANDROID_JAVA_UI)
332 PermissionBubbleManager::FromWebContents(web_contents)-> 332 PermissionBubbleManager::FromWebContents(web_contents)->
333 DocumentOnLoadCompletedInMainFrame(); 333 DocumentOnLoadCompletedInMainFrame();
334 #endif 334 #endif
335 } 335 }
336 336
337 ContentSetting GeolocationPermissionContextTests::GetGeolocationContentSetting( 337 ContentSetting GeolocationPermissionContextTests::GetGeolocationContentSetting(
338 GURL frame_0, GURL frame_1) { 338 GURL frame_0, GURL frame_1) {
339 return HostContentSettingsMapFactory::GetForProfile(profile()) 339 return HostContentSettingsMapFactory::GetForProfile(profile())
340 ->GetContentSetting(frame_0, 340 ->GetContentSetting(frame_0,
341 frame_1, 341 frame_1,
342 CONTENT_SETTINGS_TYPE_GEOLOCATION, 342 CONTENT_SETTINGS_TYPE_GEOLOCATION,
343 std::string()); 343 std::string());
344 } 344 }
345 345
346 size_t GeolocationPermissionContextTests::GetNumberOfPrompts() { 346 size_t GeolocationPermissionContextTests::GetNumberOfPrompts() {
347 #if !defined(OS_ANDROID) 347 #if !defined(ANDROID_JAVA_UI)
348 PermissionBubbleManager* manager = 348 PermissionBubbleManager* manager =
349 PermissionBubbleManager::FromWebContents(web_contents()); 349 PermissionBubbleManager::FromWebContents(web_contents());
350 return GetBubblesQueueSize(manager); 350 return GetBubblesQueueSize(manager);
351 #else 351 #else
352 return infobar_service()->infobar_count(); 352 return infobar_service()->infobar_count();
353 #endif 353 #endif
354 } 354 }
355 355
356 void GeolocationPermissionContextTests::AcceptPrompt() { 356 void GeolocationPermissionContextTests::AcceptPrompt() {
357 #if !defined(OS_ANDROID) 357 #if !defined(ANDROID_JAVA_UI)
358 PermissionBubbleManager* manager = 358 PermissionBubbleManager* manager =
359 PermissionBubbleManager::FromWebContents(web_contents()); 359 PermissionBubbleManager::FromWebContents(web_contents());
360 AcceptBubble(manager); 360 AcceptBubble(manager);
361 #else 361 #else
362 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); 362 infobars::InfoBar* infobar = infobar_service()->infobar_at(0);
363 ConfirmInfoBarDelegate* infobar_delegate = 363 ConfirmInfoBarDelegate* infobar_delegate =
364 infobar->delegate()->AsConfirmInfoBarDelegate(); 364 infobar->delegate()->AsConfirmInfoBarDelegate();
365 infobar_delegate->Accept(); 365 infobar_delegate->Accept();
366 #endif 366 #endif
367 } 367 }
368 368
369 base::string16 GeolocationPermissionContextTests::GetPromptText() { 369 base::string16 GeolocationPermissionContextTests::GetPromptText() {
370 #if !defined(OS_ANDROID) 370 #if !defined(ANDROID_JAVA_UI)
371 PermissionBubbleManager* manager = 371 PermissionBubbleManager* manager =
372 PermissionBubbleManager::FromWebContents(web_contents()); 372 PermissionBubbleManager::FromWebContents(web_contents());
373 return manager->requests_.front()->GetMessageText(); 373 return manager->requests_.front()->GetMessageText();
374 #else 374 #else
375 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); 375 infobars::InfoBar* infobar = infobar_service()->infobar_at(0);
376 ConfirmInfoBarDelegate* infobar_delegate = 376 ConfirmInfoBarDelegate* infobar_delegate =
377 infobar->delegate()->AsConfirmInfoBarDelegate(); 377 infobar->delegate()->AsConfirmInfoBarDelegate();
378 return infobar_delegate->GetMessageText(); 378 return infobar_delegate->GetMessageText();
379 #endif 379 #endif
380 } 380 }
381 381
382 // Tests ---------------------------------------------------------------------- 382 // Tests ----------------------------------------------------------------------
383 383
384 TEST_F(GeolocationPermissionContextTests, SinglePermissionBubble) { 384 TEST_F(GeolocationPermissionContextTests, SinglePermissionBubble) {
385 GURL requesting_frame("http://www.example.com/geolocation"); 385 GURL requesting_frame("http://www.example.com/geolocation");
386 NavigateAndCommit(requesting_frame); 386 NavigateAndCommit(requesting_frame);
387 BubbleManagerDocumentLoadCompleted(); 387 BubbleManagerDocumentLoadCompleted();
388 388
389 EXPECT_EQ(0U, GetNumberOfPrompts()); 389 EXPECT_EQ(0U, GetNumberOfPrompts());
390 RequestGeolocationPermission( 390 RequestGeolocationPermission(
391 web_contents(), RequestID(0), requesting_frame, true); 391 web_contents(), RequestID(0), requesting_frame, true);
392 ASSERT_EQ(1U, GetNumberOfPrompts()); 392 ASSERT_EQ(1U, GetNumberOfPrompts());
393 } 393 }
394 394
395 #if defined(OS_ANDROID) 395 #if defined(ANDROID_JAVA_UI)
396 TEST_F(GeolocationPermissionContextTests, SinglePermissionInfobar) { 396 TEST_F(GeolocationPermissionContextTests, SinglePermissionInfobar) {
397 GURL requesting_frame("http://www.example.com/geolocation"); 397 GURL requesting_frame("http://www.example.com/geolocation");
398 NavigateAndCommit(requesting_frame); 398 NavigateAndCommit(requesting_frame);
399 EXPECT_EQ(0U, infobar_service()->infobar_count()); 399 EXPECT_EQ(0U, infobar_service()->infobar_count());
400 RequestGeolocationPermission( 400 RequestGeolocationPermission(
401 web_contents(), RequestID(0), requesting_frame, true); 401 web_contents(), RequestID(0), requesting_frame, true);
402 ASSERT_EQ(1U, infobar_service()->infobar_count()); 402 ASSERT_EQ(1U, infobar_service()->infobar_count());
403 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); 403 infobars::InfoBar* infobar = infobar_service()->infobar_at(0);
404 ConfirmInfoBarDelegate* infobar_delegate = 404 ConfirmInfoBarDelegate* infobar_delegate =
405 infobar->delegate()->AsConfirmInfoBarDelegate(); 405 infobar->delegate()->AsConfirmInfoBarDelegate();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 web_contents(), RequestID(1), requesting_frame_1, true); 483 web_contents(), RequestID(1), requesting_frame_1, true);
484 // Ensure only one infobar is created. 484 // Ensure only one infobar is created.
485 ASSERT_EQ(1U, GetNumberOfPrompts()); 485 ASSERT_EQ(1U, GetNumberOfPrompts());
486 base::string16 text_0 = GetPromptText(); 486 base::string16 text_0 = GetPromptText();
487 487
488 // Accept the first frame. 488 // Accept the first frame.
489 AcceptPrompt(); 489 AcceptPrompt();
490 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); 490 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW);
491 CheckPermissionMessageSent(0, true); 491 CheckPermissionMessageSent(0, true);
492 492
493 #if defined(OS_ANDROID) 493 #if defined(ANDROID_JAVA_UI)
494 infobars::InfoBar* infobar_0 = infobar_service()->infobar_at(0); 494 infobars::InfoBar* infobar_0 = infobar_service()->infobar_at(0);
495 infobar_service()->RemoveInfoBar(infobar_0); 495 infobar_service()->RemoveInfoBar(infobar_0);
496 EXPECT_EQ(1U, closed_infobar_tracker_.size()); 496 EXPECT_EQ(1U, closed_infobar_tracker_.size());
497 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_0)); 497 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_0));
498 closed_infobar_tracker_.Clear(); 498 closed_infobar_tracker_.Clear();
499 #endif 499 #endif
500 500
501 // Now we should have a new infobar for the second frame. 501 // Now we should have a new infobar for the second frame.
502 ASSERT_EQ(1U, GetNumberOfPrompts()); 502 ASSERT_EQ(1U, GetNumberOfPrompts());
503 base::string16 text_1 = GetPromptText(); 503 base::string16 text_1 = GetPromptText();
504 504
505 // Check that the messages differ. 505 // Check that the messages differ.
506 EXPECT_NE(text_0, text_1); 506 EXPECT_NE(text_0, text_1);
507 507
508 // Cancel (block) this frame. 508 // Cancel (block) this frame.
509 #if !defined(OS_ANDROID) 509 #if !defined(ANDROID_JAVA_UI)
510 PermissionBubbleManager* manager = 510 PermissionBubbleManager* manager =
511 PermissionBubbleManager::FromWebContents(web_contents()); 511 PermissionBubbleManager::FromWebContents(web_contents());
512 DenyBubble(manager); 512 DenyBubble(manager);
513 #else 513 #else
514 infobars::InfoBar* infobar_1 = infobar_service()->infobar_at(0); 514 infobars::InfoBar* infobar_1 = infobar_service()->infobar_at(0);
515 infobar_1->delegate()->AsConfirmInfoBarDelegate()->Cancel(); 515 infobar_1->delegate()->AsConfirmInfoBarDelegate()->Cancel();
516 #endif 516 #endif
517 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK); 517 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK);
518 CheckPermissionMessageSent(1, false); 518 CheckPermissionMessageSent(1, false);
519 519
520 // Ensure the persisted permissions are ok. 520 // Ensure the persisted permissions are ok.
521 EXPECT_EQ( 521 EXPECT_EQ(
522 CONTENT_SETTING_ALLOW, 522 CONTENT_SETTING_ALLOW,
523 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); 523 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0));
524 EXPECT_EQ( 524 EXPECT_EQ(
525 CONTENT_SETTING_BLOCK, 525 CONTENT_SETTING_BLOCK,
526 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); 526 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0));
527 } 527 }
528 528
529 TEST_F(GeolocationPermissionContextTests, HashIsIgnored) { 529 TEST_F(GeolocationPermissionContextTests, HashIsIgnored) {
530 GURL url_a("http://www.example.com/geolocation#a"); 530 GURL url_a("http://www.example.com/geolocation#a");
531 GURL url_b("http://www.example.com/geolocation#b"); 531 GURL url_b("http://www.example.com/geolocation#b");
532 532
533 // Navigate to the first url. 533 // Navigate to the first url.
534 NavigateAndCommit(url_a); 534 NavigateAndCommit(url_a);
535 BubbleManagerDocumentLoadCompleted(); 535 BubbleManagerDocumentLoadCompleted();
536 536
537 // Check permission is requested. 537 // Check permission is requested.
538 ASSERT_EQ(0U, GetNumberOfPrompts()); 538 ASSERT_EQ(0U, GetNumberOfPrompts());
539 #if defined(OS_ANDROID) 539 #if defined(ANDROID_JAVA_UI)
540 const bool user_gesture = false; 540 const bool user_gesture = false;
541 #else 541 #else
542 const bool user_gesture = true; 542 const bool user_gesture = true;
543 #endif 543 #endif
544 RequestGeolocationPermission(web_contents(), RequestID(0), url_a, 544 RequestGeolocationPermission(web_contents(), RequestID(0), url_a,
545 user_gesture); 545 user_gesture);
546 ASSERT_EQ(1U, GetNumberOfPrompts()); 546 ASSERT_EQ(1U, GetNumberOfPrompts());
547 547
548 // Change the hash, we'll still be on the same page. 548 // Change the hash, we'll still be on the same page.
549 NavigateAndCommit(url_b); 549 NavigateAndCommit(url_b);
550 BubbleManagerDocumentLoadCompleted(); 550 BubbleManagerDocumentLoadCompleted();
551 551
552 // Accept. 552 // Accept.
553 AcceptPrompt(); 553 AcceptPrompt();
554 CheckTabContentsState(url_a, CONTENT_SETTING_ALLOW); 554 CheckTabContentsState(url_a, CONTENT_SETTING_ALLOW);
555 CheckTabContentsState(url_b, CONTENT_SETTING_ALLOW); 555 CheckTabContentsState(url_b, CONTENT_SETTING_ALLOW);
556 CheckPermissionMessageSent(0, true); 556 CheckPermissionMessageSent(0, true);
557 557
558 // Cleanup. 558 // Cleanup.
559 #if defined(OS_ANDROID) 559 #if defined(ANDROID_JAVA_UI)
560 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); 560 infobars::InfoBar* infobar = infobar_service()->infobar_at(0);
561 infobar_service()->RemoveInfoBar(infobar); 561 infobar_service()->RemoveInfoBar(infobar);
562 EXPECT_EQ(1U, closed_infobar_tracker_.size()); 562 EXPECT_EQ(1U, closed_infobar_tracker_.size());
563 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar)); 563 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar));
564 #endif 564 #endif
565 } 565 }
566 566
567 // TODO(felt): The bubble is rejecting file:// permission requests. 567 // TODO(felt): The bubble is rejecting file:// permission requests.
568 // Fix and enable this test. crbug.com/444047 568 // Fix and enable this test. crbug.com/444047
569 #if defined(OS_ANDROID) 569 #if defined(ANDROID_JAVA_UI)
570 #define MAYBE_PermissionForFileScheme PermissionForFileScheme 570 #define MAYBE_PermissionForFileScheme PermissionForFileScheme
571 #else 571 #else
572 #define MAYBE_PermissionForFileScheme DISABLED_PermissionForFileScheme 572 #define MAYBE_PermissionForFileScheme DISABLED_PermissionForFileScheme
573 #endif 573 #endif
574 TEST_F(GeolocationPermissionContextTests, MAYBE_PermissionForFileScheme) { 574 TEST_F(GeolocationPermissionContextTests, MAYBE_PermissionForFileScheme) {
575 GURL requesting_frame("file://example/geolocation.html"); 575 GURL requesting_frame("file://example/geolocation.html");
576 NavigateAndCommit(requesting_frame); 576 NavigateAndCommit(requesting_frame);
577 BubbleManagerDocumentLoadCompleted(); 577 BubbleManagerDocumentLoadCompleted();
578 578
579 // Check permission is requested. 579 // Check permission is requested.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 web_contents(), RequestID(0), frame_0, true); 611 web_contents(), RequestID(0), frame_0, true);
612 RequestGeolocationPermission( 612 RequestGeolocationPermission(
613 web_contents(), RequestID(1), frame_1, true); 613 web_contents(), RequestID(1), frame_1, true);
614 614
615 // Get the first permission request text. 615 // Get the first permission request text.
616 ASSERT_EQ(1U, GetNumberOfPrompts()); 616 ASSERT_EQ(1U, GetNumberOfPrompts());
617 base::string16 text_0 = GetPromptText(); 617 base::string16 text_0 = GetPromptText();
618 ASSERT_FALSE(text_0.empty()); 618 ASSERT_FALSE(text_0.empty());
619 619
620 // Simulate the frame going away; the request should be removed. 620 // Simulate the frame going away; the request should be removed.
621 #if !defined(OS_ANDROID) 621 #if !defined(ANDROID_JAVA_UI)
622 PermissionBubbleManager* manager = 622 PermissionBubbleManager* manager =
623 PermissionBubbleManager::FromWebContents(web_contents()); 623 PermissionBubbleManager::FromWebContents(web_contents());
624 CloseBubble(manager); 624 CloseBubble(manager);
625 #else 625 #else
626 geolocation_permission_context_->CancelPermissionRequest(web_contents(), 626 geolocation_permission_context_->CancelPermissionRequest(web_contents(),
627 RequestID(0)); 627 RequestID(0));
628 #endif 628 #endif
629 629
630 // Check that the next pending request is created correctly. 630 // Check that the next pending request is created correctly.
631 base::string16 text_1 = GetPromptText(); 631 base::string16 text_1 = GetPromptText();
(...skipping 28 matching lines...) Expand all
660 660
661 TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { 661 TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
662 GURL url_a("http://www.example.com/geolocation"); 662 GURL url_a("http://www.example.com/geolocation");
663 GURL url_b("http://www.example-2.com/geolocation"); 663 GURL url_b("http://www.example-2.com/geolocation");
664 NavigateAndCommit(url_a); // Tab A0 664 NavigateAndCommit(url_a); // Tab A0
665 AddNewTab(url_b); // Tab B (extra_tabs_[0]) 665 AddNewTab(url_b); // Tab B (extra_tabs_[0])
666 AddNewTab(url_a); // Tab A1 (extra_tabs_[1]) 666 AddNewTab(url_a); // Tab A1 (extra_tabs_[1])
667 BubbleManagerDocumentLoadCompleted(); 667 BubbleManagerDocumentLoadCompleted();
668 BubbleManagerDocumentLoadCompleted(extra_tabs_[0]); 668 BubbleManagerDocumentLoadCompleted(extra_tabs_[0]);
669 BubbleManagerDocumentLoadCompleted(extra_tabs_[1]); 669 BubbleManagerDocumentLoadCompleted(extra_tabs_[1]);
670 #if !defined(OS_ANDROID) 670 #if !defined(ANDROID_JAVA_UI)
671 PermissionBubbleManager* manager_a0 = 671 PermissionBubbleManager* manager_a0 =
672 PermissionBubbleManager::FromWebContents(web_contents()); 672 PermissionBubbleManager::FromWebContents(web_contents());
673 PermissionBubbleManager* manager_b = 673 PermissionBubbleManager* manager_b =
674 PermissionBubbleManager::FromWebContents(extra_tabs_[0]); 674 PermissionBubbleManager::FromWebContents(extra_tabs_[0]);
675 PermissionBubbleManager* manager_a1 = 675 PermissionBubbleManager* manager_a1 =
676 PermissionBubbleManager::FromWebContents(extra_tabs_[1]); 676 PermissionBubbleManager::FromWebContents(extra_tabs_[1]);
677 #endif 677 #endif
678 678
679 // Request permission in all three tabs. 679 // Request permission in all three tabs.
680 RequestGeolocationPermission( 680 RequestGeolocationPermission(
681 web_contents(), RequestID(0), url_a, true); 681 web_contents(), RequestID(0), url_a, true);
682 RequestGeolocationPermission( 682 RequestGeolocationPermission(
683 extra_tabs_[0], RequestIDForTab(0, 0), url_b, true); 683 extra_tabs_[0], RequestIDForTab(0, 0), url_b, true);
684 RequestGeolocationPermission( 684 RequestGeolocationPermission(
685 extra_tabs_[1], RequestIDForTab(1, 0), url_a, true); 685 extra_tabs_[1], RequestIDForTab(1, 0), url_a, true);
686 ASSERT_EQ(1U, GetNumberOfPrompts()); // For A0. 686 ASSERT_EQ(1U, GetNumberOfPrompts()); // For A0.
687 #if !defined(OS_ANDROID) 687 #if !defined(ANDROID_JAVA_UI)
688 ASSERT_EQ(1U, GetBubblesQueueSize(manager_b)); 688 ASSERT_EQ(1U, GetBubblesQueueSize(manager_b));
689 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); 689 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1));
690 #else 690 #else
691 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); 691 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count());
692 ASSERT_EQ(1U, infobar_service_for_tab(1)->infobar_count()); 692 ASSERT_EQ(1U, infobar_service_for_tab(1)->infobar_count());
693 #endif 693 #endif
694 694
695 // Accept the permission in tab A0. 695 // Accept the permission in tab A0.
696 #if !defined(OS_ANDROID) 696 #if !defined(ANDROID_JAVA_UI)
697 AcceptBubble(manager_a0); 697 AcceptBubble(manager_a0);
698 #else 698 #else
699 infobars::InfoBar* infobar_a0 = infobar_service()->infobar_at(0); 699 infobars::InfoBar* infobar_a0 = infobar_service()->infobar_at(0);
700 ConfirmInfoBarDelegate* infobar_delegate_a0 = 700 ConfirmInfoBarDelegate* infobar_delegate_a0 =
701 infobar_a0->delegate()->AsConfirmInfoBarDelegate(); 701 infobar_a0->delegate()->AsConfirmInfoBarDelegate();
702 ASSERT_TRUE(infobar_delegate_a0); 702 ASSERT_TRUE(infobar_delegate_a0);
703 infobar_delegate_a0->Accept(); 703 infobar_delegate_a0->Accept();
704 infobar_service()->RemoveInfoBar(infobar_a0); 704 infobar_service()->RemoveInfoBar(infobar_a0);
705 EXPECT_EQ(2U, closed_infobar_tracker_.size()); 705 EXPECT_EQ(2U, closed_infobar_tracker_.size());
706 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a0)); 706 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a0));
707 #endif 707 #endif
708 CheckPermissionMessageSent(0, true); 708 CheckPermissionMessageSent(0, true);
709 // Because they're the same origin, this will cause tab A1's infobar to 709 // Because they're the same origin, this will cause tab A1's infobar to
710 // disappear. It does not cause the bubble to disappear: crbug.com/443013. 710 // disappear. It does not cause the bubble to disappear: crbug.com/443013.
711 // TODO(felt): Update this test when the bubble's behavior is changed. 711 // TODO(felt): Update this test when the bubble's behavior is changed.
712 // Either way, tab B should still have a pending permission request. 712 // Either way, tab B should still have a pending permission request.
713 #if !defined(OS_ANDROID) 713 #if !defined(ANDROID_JAVA_UI)
714 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); 714 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1));
715 ASSERT_EQ(1U, GetBubblesQueueSize(manager_b)); 715 ASSERT_EQ(1U, GetBubblesQueueSize(manager_b));
716 #else 716 #else
717 CheckPermissionMessageSentForTab(1, 0, true); 717 CheckPermissionMessageSentForTab(1, 0, true);
718 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); 718 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count());
719 #endif 719 #endif
720 } 720 }
721 721
722 TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { 722 TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
723 GURL url_a("http://www.example.com/geolocation"); 723 GURL url_a("http://www.example.com/geolocation");
724 GURL url_b("http://www.example-2.com/geolocation"); 724 GURL url_b("http://www.example-2.com/geolocation");
725 NavigateAndCommit(url_a); // Tab A0. 725 NavigateAndCommit(url_a); // Tab A0.
726 AddNewTab(url_a); // Tab A1. 726 AddNewTab(url_a); // Tab A1.
727 #if !defined(OS_ANDROID) 727 #if !defined(ANDROID_JAVA_UI)
728 BubbleManagerDocumentLoadCompleted(); 728 BubbleManagerDocumentLoadCompleted();
729 BubbleManagerDocumentLoadCompleted(extra_tabs_[0]); 729 BubbleManagerDocumentLoadCompleted(extra_tabs_[0]);
730 PermissionBubbleManager* manager_a0 = 730 PermissionBubbleManager* manager_a0 =
731 PermissionBubbleManager::FromWebContents(web_contents()); 731 PermissionBubbleManager::FromWebContents(web_contents());
732 PermissionBubbleManager* manager_a1 = 732 PermissionBubbleManager* manager_a1 =
733 PermissionBubbleManager::FromWebContents(extra_tabs_[0]); 733 PermissionBubbleManager::FromWebContents(extra_tabs_[0]);
734 #endif 734 #endif
735 735
736 // Request permission in both tabs; the extra tab will have two permission 736 // Request permission in both tabs; the extra tab will have two permission
737 // requests from two origins. 737 // requests from two origins.
738 RequestGeolocationPermission( 738 RequestGeolocationPermission(
739 web_contents(), RequestID(0), url_a, true); 739 web_contents(), RequestID(0), url_a, true);
740 RequestGeolocationPermission( 740 RequestGeolocationPermission(
741 extra_tabs_[0], RequestIDForTab(0, 0), url_a, true); 741 extra_tabs_[0], RequestIDForTab(0, 0), url_a, true);
742 RequestGeolocationPermission( 742 RequestGeolocationPermission(
743 extra_tabs_[0], RequestIDForTab(0, 1), url_b, true); 743 extra_tabs_[0], RequestIDForTab(0, 1), url_b, true);
744 #if !defined(OS_ANDROID) 744 #if !defined(ANDROID_JAVA_UI)
745 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a0)); 745 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a0));
746 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); 746 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1));
747 #else 747 #else
748 ASSERT_EQ(1U, infobar_service()->infobar_count()); 748 ASSERT_EQ(1U, infobar_service()->infobar_count());
749 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); 749 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count());
750 #endif 750 #endif
751 751
752 // Accept the first request in tab A1. 752 // Accept the first request in tab A1.
753 #if !defined(OS_ANDROID) 753 #if !defined(ANDROID_JAVA_UI)
754 AcceptBubble(manager_a1); 754 AcceptBubble(manager_a1);
755 #else 755 #else
756 infobars::InfoBar* infobar_a1 = infobar_service_for_tab(0)->infobar_at(0); 756 infobars::InfoBar* infobar_a1 = infobar_service_for_tab(0)->infobar_at(0);
757 ConfirmInfoBarDelegate* infobar_delegate_a1 = 757 ConfirmInfoBarDelegate* infobar_delegate_a1 =
758 infobar_a1->delegate()->AsConfirmInfoBarDelegate(); 758 infobar_a1->delegate()->AsConfirmInfoBarDelegate();
759 ASSERT_TRUE(infobar_delegate_a1); 759 ASSERT_TRUE(infobar_delegate_a1);
760 infobar_delegate_a1->Accept(); 760 infobar_delegate_a1->Accept();
761 infobar_service_for_tab(0)->RemoveInfoBar(infobar_a1); 761 infobar_service_for_tab(0)->RemoveInfoBar(infobar_a1);
762 EXPECT_EQ(2U, closed_infobar_tracker_.size()); 762 EXPECT_EQ(2U, closed_infobar_tracker_.size());
763 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a1)); 763 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a1));
764 #endif 764 #endif
765 CheckPermissionMessageSentForTab(0, 0, true); 765 CheckPermissionMessageSentForTab(0, 0, true);
766 766
767 // Because they're the same origin, this will cause tab A0's infobar to 767 // Because they're the same origin, this will cause tab A0's infobar to
768 // disappear. It does not cause the bubble to disappear: crbug.com/443013. 768 // disappear. It does not cause the bubble to disappear: crbug.com/443013.
769 // TODO(felt): Update this test when the bubble's behavior is changed. 769 // TODO(felt): Update this test when the bubble's behavior is changed.
770 #if !defined(OS_ANDROID) 770 #if !defined(ANDROID_JAVA_UI)
771 EXPECT_EQ(1U, GetBubblesQueueSize(manager_a0)); 771 EXPECT_EQ(1U, GetBubblesQueueSize(manager_a0));
772 #else 772 #else
773 EXPECT_EQ(0U, infobar_service()->infobar_count()); 773 EXPECT_EQ(0U, infobar_service()->infobar_count());
774 CheckPermissionMessageSent(0, true); 774 CheckPermissionMessageSent(0, true);
775 #endif 775 #endif
776 776
777 // The second request should now be visible in tab A1. 777 // The second request should now be visible in tab A1.
778 #if !defined(OS_ANDROID) 778 #if !defined(ANDROID_JAVA_UI)
779 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); 779 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1));
780 #else 780 #else
781 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); 781 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count());
782 #endif 782 #endif
783 783
784 // Accept the second request and check that it's gone. 784 // Accept the second request and check that it's gone.
785 #if !defined(OS_ANDROID) 785 #if !defined(ANDROID_JAVA_UI)
786 AcceptBubble(manager_a1); 786 AcceptBubble(manager_a1);
787 EXPECT_EQ(0U, GetBubblesQueueSize(manager_a1)); 787 EXPECT_EQ(0U, GetBubblesQueueSize(manager_a1));
788 #else 788 #else
789 infobars::InfoBar* infobar_1 = infobar_service_for_tab(0)->infobar_at(0); 789 infobars::InfoBar* infobar_1 = infobar_service_for_tab(0)->infobar_at(0);
790 ConfirmInfoBarDelegate* infobar_delegate_1 = 790 ConfirmInfoBarDelegate* infobar_delegate_1 =
791 infobar_1->delegate()->AsConfirmInfoBarDelegate(); 791 infobar_1->delegate()->AsConfirmInfoBarDelegate();
792 ASSERT_TRUE(infobar_delegate_1); 792 ASSERT_TRUE(infobar_delegate_1);
793 infobar_delegate_1->Accept(); 793 infobar_delegate_1->Accept();
794 #endif 794 #endif
795 } 795 }
(...skipping 14 matching lines...) Expand all
810 // Request permission for two frames. 810 // Request permission for two frames.
811 RequestGeolocationPermission( 811 RequestGeolocationPermission(
812 web_contents(), RequestID(0), requesting_frame_0, false); 812 web_contents(), RequestID(0), requesting_frame_0, false);
813 RequestGeolocationPermission( 813 RequestGeolocationPermission(
814 web_contents(), RequestID(1), requesting_frame_1, false); 814 web_contents(), RequestID(1), requesting_frame_1, false);
815 815
816 // Ensure only one prompt is created. 816 // Ensure only one prompt is created.
817 ASSERT_EQ(1U, GetNumberOfPrompts()); 817 ASSERT_EQ(1U, GetNumberOfPrompts());
818 818
819 // Delete the tab contents. 819 // Delete the tab contents.
820 #if defined(OS_ANDROID) 820 #if defined(ANDROID_JAVA_UI)
821 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); 821 infobars::InfoBar* infobar = infobar_service()->infobar_at(0);
822 DeleteContents(); 822 DeleteContents();
823 ASSERT_EQ(1U, closed_infobar_tracker_.size()); 823 ASSERT_EQ(1U, closed_infobar_tracker_.size());
824 ASSERT_TRUE(closed_infobar_tracker_.Contains(infobar)); 824 ASSERT_TRUE(closed_infobar_tracker_.Contains(infobar));
825 #endif 825 #endif
826 826
827 // The content settings should not have changed. 827 // The content settings should not have changed.
828 EXPECT_EQ( 828 EXPECT_EQ(
829 CONTENT_SETTING_ASK, 829 CONTENT_SETTING_ASK,
830 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); 830 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 RequestGeolocationPermission( 908 RequestGeolocationPermission(
909 web_contents(), RequestID(0), requesting_frame_0, false); 909 web_contents(), RequestID(0), requesting_frame_0, false);
910 RequestGeolocationPermission( 910 RequestGeolocationPermission(
911 web_contents(), RequestID(1), requesting_frame_1, false); 911 web_contents(), RequestID(1), requesting_frame_1, false);
912 912
913 // Ensure only one infobar is created. 913 // Ensure only one infobar is created.
914 ASSERT_EQ(1U, GetNumberOfPrompts()); 914 ASSERT_EQ(1U, GetNumberOfPrompts());
915 915
916 // Accept the first frame. 916 // Accept the first frame.
917 AcceptPrompt(); 917 AcceptPrompt();
918 #if defined(OS_ANDROID) 918 #if defined(ANDROID_JAVA_UI)
919 infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); 919 infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0));
920 #endif 920 #endif
921 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); 921 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW);
922 CheckPermissionMessageSent(0, true); 922 CheckPermissionMessageSent(0, true);
923 923
924 // Verify that accepting the first didn't accept because it's embedded 924 // Verify that accepting the first didn't accept because it's embedded
925 // in the other. 925 // in the other.
926 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), 926 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(),
927 requesting_frame_0.GetOrigin(), 927 requesting_frame_0.GetOrigin(),
928 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 928 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
929 10); 929 10);
930 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), 930 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(),
931 requesting_frame_0.GetOrigin(), 931 requesting_frame_0.GetOrigin(),
932 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 932 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
933 0); 933 0);
934 934
935 ASSERT_EQ(1U, GetNumberOfPrompts()); 935 ASSERT_EQ(1U, GetNumberOfPrompts());
936 936
937 test_clock->Advance(base::TimeDelta::FromSeconds(1)); 937 test_clock->Advance(base::TimeDelta::FromSeconds(1));
938 938
939 // Allow the second frame. 939 // Allow the second frame.
940 AcceptPrompt(); 940 AcceptPrompt();
941 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW); 941 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW);
942 CheckPermissionMessageSent(1, true); 942 CheckPermissionMessageSent(1, true);
943 #if defined(OS_ANDROID) 943 #if defined(ANDROID_JAVA_UI)
944 infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); 944 infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0));
945 #endif 945 #endif
946 946
947 // Verify that the times are different. 947 // Verify that the times are different.
948 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), 948 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(),
949 requesting_frame_0.GetOrigin(), 949 requesting_frame_0.GetOrigin(),
950 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 950 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
951 10); 951 10);
952 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), 952 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(),
953 requesting_frame_0.GetOrigin(), 953 requesting_frame_0.GetOrigin(),
954 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 954 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
955 11); 955 11);
956 956
957 test_clock->Advance(base::TimeDelta::FromSeconds(2)); 957 test_clock->Advance(base::TimeDelta::FromSeconds(2));
958 RequestGeolocationPermission( 958 RequestGeolocationPermission(
959 web_contents(), RequestID(0), requesting_frame_0, false); 959 web_contents(), RequestID(0), requesting_frame_0, false);
960 960
961 // Verify that requesting permission in one frame doesn't update other where 961 // Verify that requesting permission in one frame doesn't update other where
962 // it is the embedder. 962 // it is the embedder.
963 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), 963 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(),
964 requesting_frame_0.GetOrigin(), 964 requesting_frame_0.GetOrigin(),
965 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 965 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
966 13); 966 13);
967 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), 967 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(),
968 requesting_frame_0.GetOrigin(), 968 requesting_frame_0.GetOrigin(),
969 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 969 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
970 11); 970 11);
971 } 971 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698