| 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> |
| 6 |
| 5 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 6 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 7 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 8 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/content_settings/content_settings_pattern.h" |
| 12 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 10 #include "chrome/browser/dom_operation_notification_details.h" | 14 #include "chrome/browser/dom_operation_notification_details.h" |
| 11 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | |
| 12 #include "chrome/browser/geolocation/geolocation_settings_state.h" | 15 #include "chrome/browser/geolocation/geolocation_settings_state.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 17 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 15 #include "chrome/browser/tab_contents/infobar.h" | 18 #include "chrome/browser/tab_contents/infobar.h" |
| 16 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 423 } |
| 421 | 424 |
| 422 // http://crbug.com/44589. Hangs on Mac, crashes on Windows | 425 // http://crbug.com/44589. Hangs on Mac, crashes on Windows |
| 423 #if defined(OS_MACOSX) || defined(OS_WIN) | 426 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 424 #define MAYBE_NoInfobarForDeniedOrigin DISABLED_NoInfobarForDeniedOrigin | 427 #define MAYBE_NoInfobarForDeniedOrigin DISABLED_NoInfobarForDeniedOrigin |
| 425 #else | 428 #else |
| 426 #define MAYBE_NoInfobarForDeniedOrigin NoInfobarForDeniedOrigin | 429 #define MAYBE_NoInfobarForDeniedOrigin NoInfobarForDeniedOrigin |
| 427 #endif | 430 #endif |
| 428 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_NoInfobarForDeniedOrigin) { | 431 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_NoInfobarForDeniedOrigin) { |
| 429 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); | 432 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
| 430 current_browser_->profile()->GetGeolocationContentSettingsMap()-> | 433 current_browser_->profile()->GetHostContentSettingsMap()-> |
| 431 SetContentSetting(current_url_, current_url_, CONTENT_SETTING_BLOCK); | 434 SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(current_url_), |
| 435 ContentSettingsPattern::FromURLNoWildcard(current_url_), |
| 436 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 437 std::string(), |
| 438 CONTENT_SETTING_BLOCK); |
| 432 AddGeolocationWatch(false); | 439 AddGeolocationWatch(false); |
| 433 // Checks we have an error for this denied origin. | 440 // Checks we have an error for this denied origin. |
| 434 CheckStringValueFromJavascript("1", "geoGetLastError()"); | 441 CheckStringValueFromJavascript("1", "geoGetLastError()"); |
| 435 // Checks infobar will not be created a second tab. | 442 // Checks infobar will not be created a second tab. |
| 436 ASSERT_TRUE(Initialize(INITIALIZATION_NEWTAB)); | 443 ASSERT_TRUE(Initialize(INITIALIZATION_NEWTAB)); |
| 437 AddGeolocationWatch(false); | 444 AddGeolocationWatch(false); |
| 438 CheckStringValueFromJavascript("1", "geoGetLastError()"); | 445 CheckStringValueFromJavascript("1", "geoGetLastError()"); |
| 439 } | 446 } |
| 440 | 447 |
| 441 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForAllowedOrigin) { | 448 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForAllowedOrigin) { |
| 442 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); | 449 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
| 443 current_browser_->profile()->GetGeolocationContentSettingsMap()-> | 450 current_browser_->profile()->GetHostContentSettingsMap()-> |
| 444 SetContentSetting(current_url_, current_url_, CONTENT_SETTING_ALLOW); | 451 SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(current_url_), |
| 452 ContentSettingsPattern::FromURLNoWildcard(current_url_), |
| 453 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 454 std::string(), |
| 455 CONTENT_SETTING_ALLOW); |
| 445 // Checks no infobar will be created and there's no error callback. | 456 // Checks no infobar will be created and there's no error callback. |
| 446 AddGeolocationWatch(false); | 457 AddGeolocationWatch(false); |
| 447 CheckGeoposition(MockLocationProvider::instance_->position_); | 458 CheckGeoposition(MockLocationProvider::instance_->position_); |
| 448 } | 459 } |
| 449 | 460 |
| 450 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForOffTheRecord) { | 461 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForOffTheRecord) { |
| 451 // First, check infobar will be created for regular profile | 462 // First, check infobar will be created for regular profile |
| 452 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); | 463 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); |
| 453 AddGeolocationWatch(true); | 464 AddGeolocationWatch(true); |
| 454 // Response will be persisted | 465 // Response will be persisted |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 "window.domAutomationController.setAutomationId(0);" | 660 "window.domAutomationController.setAutomationId(0);" |
| 650 "window.domAutomationController.send(window.close());"; | 661 "window.domAutomationController.send(window.close());"; |
| 651 bool result = | 662 bool result = |
| 652 ui_test_utils::ExecuteJavaScript( | 663 ui_test_utils::ExecuteJavaScript( |
| 653 current_browser_->GetSelectedTabContents()->render_view_host(), | 664 current_browser_->GetSelectedTabContents()->render_view_host(), |
| 654 L"", UTF8ToWide(script)); | 665 L"", UTF8ToWide(script)); |
| 655 EXPECT_EQ(result, true); | 666 EXPECT_EQ(result, true); |
| 656 } | 667 } |
| 657 | 668 |
| 658 } // namespace | 669 } // namespace |
| OLD | NEW |