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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 content::WindowedNotificationObserver observer( | 414 content::WindowedNotificationObserver observer( |
414 content::NOTIFICATION_LOAD_STOP, | 415 content::NOTIFICATION_LOAD_STOP, |
415 content::Source<NavigationController>(&web_contents->GetController())); | 416 content::Source<NavigationController>(&web_contents->GetController())); |
416 if (allowed) | 417 if (allowed) |
417 infobar_->delegate()->AsConfirmInfoBarDelegate()->Accept(); | 418 infobar_->delegate()->AsConfirmInfoBarDelegate()->Accept(); |
418 else | 419 else |
419 infobar_->delegate()->AsConfirmInfoBarDelegate()->Cancel(); | 420 infobar_->delegate()->AsConfirmInfoBarDelegate()->Cancel(); |
420 observer.Wait(); | 421 observer.Wait(); |
421 } | 422 } |
422 | 423 |
423 InfoBarService::FromWebContents(web_contents)->RemoveInfoBar(infobar_); | 424 InfoBarManager* infobar_manager = |
| 425 InfoBarService::FromWebContents(web_contents)->infobar_manager(); |
| 426 infobar_manager->RemoveInfoBar(infobar_); |
424 LOG(WARNING) << "infobar response set"; | 427 LOG(WARNING) << "infobar response set"; |
425 infobar_ = NULL; | 428 infobar_ = NULL; |
426 EXPECT_GT(usages_state.state_map().size(), state_map_size); | 429 EXPECT_GT(usages_state.state_map().size(), state_map_size); |
427 GURL requesting_origin(requesting_url.GetOrigin()); | 430 GURL requesting_origin(requesting_url.GetOrigin()); |
428 EXPECT_EQ(1U, usages_state.state_map().count(requesting_origin)); | 431 EXPECT_EQ(1U, usages_state.state_map().count(requesting_origin)); |
429 ContentSetting expected_setting = | 432 ContentSetting expected_setting = |
430 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 433 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
431 EXPECT_EQ(expected_setting, | 434 EXPECT_EQ(expected_setting, |
432 usages_state.state_map().find(requesting_origin)->second); | 435 usages_state.state_map().find(requesting_origin)->second); |
433 } | 436 } |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 // Disables further prompts from this iframe. | 664 // Disables further prompts from this iframe. |
662 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); | 665 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
663 | 666 |
664 // Test second iframe from a different origin with a cached geoposition will | 667 // Test second iframe from a different origin with a cached geoposition will |
665 // create the infobar. | 668 // create the infobar. |
666 SetFrameHost("iframe_1"); | 669 SetFrameHost("iframe_1"); |
667 AddGeolocationWatch(true); | 670 AddGeolocationWatch(true); |
668 | 671 |
669 InfoBarService* infobar_service = InfoBarService::FromWebContents( | 672 InfoBarService* infobar_service = InfoBarService::FromWebContents( |
670 current_browser()->tab_strip_model()->GetActiveWebContents()); | 673 current_browser()->tab_strip_model()->GetActiveWebContents()); |
671 size_t num_infobars_before_cancel = infobar_service->infobar_count(); | 674 InfoBarManager* infobar_manager = infobar_service->infobar_manager(); |
| 675 size_t num_infobars_before_cancel = infobar_manager->infobar_count(); |
672 // Change the iframe, and ensure the infobar is gone. | 676 // Change the iframe, and ensure the infobar is gone. |
673 IFrameLoader change_iframe_1(current_browser(), 1, current_url()); | 677 IFrameLoader change_iframe_1(current_browser(), 1, current_url()); |
674 size_t num_infobars_after_cancel = infobar_service->infobar_count(); | 678 size_t num_infobars_after_cancel = infobar_manager->infobar_count(); |
675 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); | 679 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); |
676 } | 680 } |
677 | 681 |
678 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, InvalidUrlRequest) { | 682 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, InvalidUrlRequest) { |
679 // Tests that an invalid URL (e.g. from a popup window) is rejected | 683 // Tests that an invalid URL (e.g. from a popup window) is rejected |
680 // correctly. Also acts as a regression test for http://crbug.com/40478 | 684 // correctly. Also acts as a regression test for http://crbug.com/40478 |
681 set_html_for_tests("/geolocation/invalid_request_url.html"); | 685 set_html_for_tests("/geolocation/invalid_request_url.html"); |
682 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); | 686 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
683 | 687 |
684 SetFrameHost(""); | 688 SetFrameHost(""); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 | 764 |
761 SetFrameHost("iframe_2"); | 765 SetFrameHost("iframe_2"); |
762 AddGeolocationWatch(false); | 766 AddGeolocationWatch(false); |
763 | 767 |
764 std::string script = | 768 std::string script = |
765 "window.domAutomationController.send(window.close());"; | 769 "window.domAutomationController.send(window.close());"; |
766 bool result = content::ExecuteScript( | 770 bool result = content::ExecuteScript( |
767 current_browser()->tab_strip_model()->GetActiveWebContents(), script); | 771 current_browser()->tab_strip_model()->GetActiveWebContents(), script); |
768 EXPECT_EQ(result, true); | 772 EXPECT_EQ(result, true); |
769 } | 773 } |
OLD | NEW |