OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/content_settings/content_settings_pattern.h" | 11 #include "chrome/browser/content_settings/content_settings_pattern.h" |
12 #include "chrome/browser/content_settings/host_content_settings_map.h" | 12 #include "chrome/browser/content_settings/host_content_settings_map.h" |
13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
14 #include "chrome/browser/dom_operation_notification_details.h" | 14 #include "chrome/browser/dom_operation_notification_details.h" |
15 #include "chrome/browser/geolocation/geolocation_settings_state.h" | 15 #include "chrome/browser/geolocation/geolocation_settings_state.h" |
| 16 #include "chrome/browser/infobars/infobar_tab_helper.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 18 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
18 #include "chrome/browser/tab_contents/infobar.h" | 19 #include "chrome/browser/tab_contents/infobar.h" |
19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
22 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.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" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 ui_test_utils::WindowedNotificationObserver observer( | 325 ui_test_utils::WindowedNotificationObserver observer( |
325 content::NOTIFICATION_LOAD_STOP, | 326 content::NOTIFICATION_LOAD_STOP, |
326 Source<NavigationController>(&tab_contents_wrapper->controller())); | 327 Source<NavigationController>(&tab_contents_wrapper->controller())); |
327 if (allowed) | 328 if (allowed) |
328 infobar_->AsConfirmInfoBarDelegate()->Accept(); | 329 infobar_->AsConfirmInfoBarDelegate()->Accept(); |
329 else | 330 else |
330 infobar_->AsConfirmInfoBarDelegate()->Cancel(); | 331 infobar_->AsConfirmInfoBarDelegate()->Cancel(); |
331 observer.Wait(); | 332 observer.Wait(); |
332 } | 333 } |
333 | 334 |
334 tab_contents_wrapper->RemoveInfoBar(infobar_); | 335 tab_contents_wrapper->infobar_tab_helper()->RemoveInfoBar(infobar_); |
335 LOG(WARNING) << "infobar response set"; | 336 LOG(WARNING) << "infobar response set"; |
336 infobar_ = NULL; | 337 infobar_ = NULL; |
337 EXPECT_GT(settings_state.state_map().size(), state_map_size); | 338 EXPECT_GT(settings_state.state_map().size(), state_map_size); |
338 GURL requesting_origin = requesting_url.GetOrigin(); | 339 GURL requesting_origin = requesting_url.GetOrigin(); |
339 EXPECT_EQ(1U, settings_state.state_map().count(requesting_origin)); | 340 EXPECT_EQ(1U, settings_state.state_map().count(requesting_origin)); |
340 ContentSetting expected_setting = | 341 ContentSetting expected_setting = |
341 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 342 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
342 EXPECT_EQ(expected_setting, | 343 EXPECT_EQ(expected_setting, |
343 settings_state.state_map().find(requesting_origin)->second); | 344 settings_state.state_map().find(requesting_origin)->second); |
344 } | 345 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 SetInfobarResponse(iframe_urls_[0], true); | 570 SetInfobarResponse(iframe_urls_[0], true); |
570 CheckGeoposition(MockLocationProvider::instance_->position_); | 571 CheckGeoposition(MockLocationProvider::instance_->position_); |
571 // Disables further prompts from this iframe. | 572 // Disables further prompts from this iframe. |
572 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); | 573 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); |
573 | 574 |
574 // Test second iframe from a different origin with a cached geoposition will | 575 // Test second iframe from a different origin with a cached geoposition will |
575 // create the infobar. | 576 // create the infobar. |
576 iframe_xpath_ = L"//iframe[@id='iframe_1']"; | 577 iframe_xpath_ = L"//iframe[@id='iframe_1']"; |
577 AddGeolocationWatch(true); | 578 AddGeolocationWatch(true); |
578 | 579 |
579 size_t num_infobars_before_cancel = | 580 InfoBarTabHelper* infobar_helper = current_browser_-> |
580 current_browser_->GetSelectedTabContentsWrapper()->infobar_count(); | 581 GetSelectedTabContentsWrapper()->infobar_tab_helper(); |
| 582 size_t num_infobars_before_cancel = infobar_helper->infobar_count(); |
581 // Change the iframe, and ensure the infobar is gone. | 583 // Change the iframe, and ensure the infobar is gone. |
582 IFrameLoader change_iframe_1(current_browser_, 1, current_url_); | 584 IFrameLoader change_iframe_1(current_browser_, 1, current_url_); |
583 size_t num_infobars_after_cancel = | 585 size_t num_infobars_after_cancel = infobar_helper->infobar_count(); |
584 current_browser_->GetSelectedTabContentsWrapper()->infobar_count(); | |
585 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); | 586 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); |
586 } | 587 } |
587 | 588 |
588 // Disabled, http://crbug.com/66959. | 589 // Disabled, http://crbug.com/66959. |
589 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_InvalidUrlRequest) { | 590 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_InvalidUrlRequest) { |
590 // Tests that an invalid URL (e.g. from a popup window) is rejected | 591 // Tests that an invalid URL (e.g. from a popup window) is rejected |
591 // correctly. Also acts as a regression test for http://crbug.com/40478 | 592 // correctly. Also acts as a regression test for http://crbug.com/40478 |
592 html_for_tests_ = "files/geolocation/invalid_request_url.html"; | 593 html_for_tests_ = "files/geolocation/invalid_request_url.html"; |
593 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); | 594 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
594 TabContents* original_tab = current_browser_->GetSelectedTabContents(); | 595 TabContents* original_tab = current_browser_->GetSelectedTabContents(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 "window.domAutomationController.setAutomationId(0);" | 667 "window.domAutomationController.setAutomationId(0);" |
667 "window.domAutomationController.send(window.close());"; | 668 "window.domAutomationController.send(window.close());"; |
668 bool result = | 669 bool result = |
669 ui_test_utils::ExecuteJavaScript( | 670 ui_test_utils::ExecuteJavaScript( |
670 current_browser_->GetSelectedTabContents()->render_view_host(), | 671 current_browser_->GetSelectedTabContents()->render_view_host(), |
671 L"", UTF8ToWide(script)); | 672 L"", UTF8ToWide(script)); |
672 EXPECT_EQ(result, true); | 673 EXPECT_EQ(result, true); |
673 } | 674 } |
674 | 675 |
675 } // namespace | 676 } // namespace |
OLD | NEW |