| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/content_settings/content_settings_usages_state.h" | 12 #include "chrome/browser/content_settings/content_settings_usages_state.h" |
| 13 #include "chrome/browser/content_settings/host_content_settings_map.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 15 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 15 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 16 #include "chrome/browser/infobars/infobar.h" | 16 #include "chrome/browser/infobars/infobar.h" |
| 17 #include "chrome/browser/infobars/infobar_manager.h" |
| 17 #include "chrome/browser/infobars/infobar_service.h" | 18 #include "chrome/browser/infobars/infobar_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_commands.h" | 21 #include "chrome/browser/ui/browser_commands.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/content_settings_pattern.h" | 24 #include "chrome/common/content_settings_pattern.h" |
| 24 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
| 25 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
| 26 #include "content/public/browser/dom_operation_notification_details.h" | 27 #include "content/public/browser/dom_operation_notification_details.h" |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 content::WindowedNotificationObserver observer( | 407 content::WindowedNotificationObserver observer( |
| 407 content::NOTIFICATION_LOAD_STOP, | 408 content::NOTIFICATION_LOAD_STOP, |
| 408 content::Source<NavigationController>(&web_contents->GetController())); | 409 content::Source<NavigationController>(&web_contents->GetController())); |
| 409 if (allowed) | 410 if (allowed) |
| 410 infobar_->delegate()->AsConfirmInfoBarDelegate()->Accept(); | 411 infobar_->delegate()->AsConfirmInfoBarDelegate()->Accept(); |
| 411 else | 412 else |
| 412 infobar_->delegate()->AsConfirmInfoBarDelegate()->Cancel(); | 413 infobar_->delegate()->AsConfirmInfoBarDelegate()->Cancel(); |
| 413 observer.Wait(); | 414 observer.Wait(); |
| 414 } | 415 } |
| 415 | 416 |
| 416 InfoBarService::FromWebContents(web_contents)->RemoveInfoBar(infobar_); | 417 InfoBarService::FromWebContents(web_contents) |
| 418 ->infobar_manager() |
| 419 .RemoveInfoBar(infobar_); |
| 417 LOG(WARNING) << "infobar response set"; | 420 LOG(WARNING) << "infobar response set"; |
| 418 infobar_ = NULL; | 421 infobar_ = NULL; |
| 419 EXPECT_GT(usages_state.state_map().size(), state_map_size); | 422 EXPECT_GT(usages_state.state_map().size(), state_map_size); |
| 420 GURL requesting_origin(requesting_url.GetOrigin()); | 423 GURL requesting_origin(requesting_url.GetOrigin()); |
| 421 EXPECT_EQ(1U, usages_state.state_map().count(requesting_origin)); | 424 EXPECT_EQ(1U, usages_state.state_map().count(requesting_origin)); |
| 422 ContentSetting expected_setting = | 425 ContentSetting expected_setting = |
| 423 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 426 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
| 424 EXPECT_EQ(expected_setting, | 427 EXPECT_EQ(expected_setting, |
| 425 usages_state.state_map().find(requesting_origin)->second); | 428 usages_state.state_map().find(requesting_origin)->second); |
| 426 } | 429 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 // Disables further prompts from this iframe. | 646 // Disables further prompts from this iframe. |
| 644 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); | 647 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
| 645 | 648 |
| 646 // Test second iframe from a different origin with a cached geoposition will | 649 // Test second iframe from a different origin with a cached geoposition will |
| 647 // create the infobar. | 650 // create the infobar. |
| 648 set_iframe_xpath("//iframe[@id='iframe_1']"); | 651 set_iframe_xpath("//iframe[@id='iframe_1']"); |
| 649 AddGeolocationWatch(true); | 652 AddGeolocationWatch(true); |
| 650 | 653 |
| 651 InfoBarService* infobar_service = InfoBarService::FromWebContents( | 654 InfoBarService* infobar_service = InfoBarService::FromWebContents( |
| 652 current_browser()->tab_strip_model()->GetActiveWebContents()); | 655 current_browser()->tab_strip_model()->GetActiveWebContents()); |
| 653 size_t num_infobars_before_cancel = infobar_service->infobar_count(); | 656 size_t num_infobars_before_cancel = |
| 657 infobar_service->infobar_manager().infobar_count(); |
| 654 // Change the iframe, and ensure the infobar is gone. | 658 // Change the iframe, and ensure the infobar is gone. |
| 655 IFrameLoader change_iframe_1(current_browser(), 1, current_url()); | 659 IFrameLoader change_iframe_1(current_browser(), 1, current_url()); |
| 656 size_t num_infobars_after_cancel = infobar_service->infobar_count(); | 660 size_t num_infobars_after_cancel = |
| 661 infobar_service->infobar_manager().infobar_count(); |
| 657 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); | 662 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); |
| 658 } | 663 } |
| 659 | 664 |
| 660 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, InvalidUrlRequest) { | 665 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, InvalidUrlRequest) { |
| 661 // Tests that an invalid URL (e.g. from a popup window) is rejected | 666 // Tests that an invalid URL (e.g. from a popup window) is rejected |
| 662 // correctly. Also acts as a regression test for http://crbug.com/40478 | 667 // correctly. Also acts as a regression test for http://crbug.com/40478 |
| 663 set_html_for_tests("/geolocation/invalid_request_url.html"); | 668 set_html_for_tests("/geolocation/invalid_request_url.html"); |
| 664 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); | 669 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
| 665 WebContents* original_tab = | 670 WebContents* original_tab = |
| 666 current_browser()->tab_strip_model()->GetActiveWebContents(); | 671 current_browser()->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 | 742 |
| 738 set_iframe_xpath("//iframe[@id='iframe_2']"); | 743 set_iframe_xpath("//iframe[@id='iframe_2']"); |
| 739 AddGeolocationWatch(false); | 744 AddGeolocationWatch(false); |
| 740 | 745 |
| 741 std::string script = | 746 std::string script = |
| 742 "window.domAutomationController.send(window.close());"; | 747 "window.domAutomationController.send(window.close());"; |
| 743 bool result = content::ExecuteScript( | 748 bool result = content::ExecuteScript( |
| 744 current_browser()->tab_strip_model()->GetActiveWebContents(), script); | 749 current_browser()->tab_strip_model()->GetActiveWebContents(), script); |
| 745 EXPECT_EQ(result, true); | 750 EXPECT_EQ(result, true); |
| 746 } | 751 } |
| OLD | NEW |