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

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

Issue 228293004: InfoBarService inherits from InfoBarManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: format Created 6 years, 8 months 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 | Annotate | Revision Log
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 <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"
18 #include "chrome/browser/infobars/infobar_service.h" 17 #include "chrome/browser/infobars/infobar_service.h"
19 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_commands.h" 20 #include "chrome/browser/ui/browser_commands.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
24 #include "chrome/common/content_settings_pattern.h" 23 #include "chrome/common/content_settings_pattern.h"
25 #include "chrome/test/base/in_process_browser_test.h" 24 #include "chrome/test/base/in_process_browser_test.h"
26 #include "chrome/test/base/ui_test_utils.h" 25 #include "chrome/test/base/ui_test_utils.h"
27 #include "content/public/browser/dom_operation_notification_details.h" 26 #include "content/public/browser/dom_operation_notification_details.h"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 content::WindowedNotificationObserver observer( 413 content::WindowedNotificationObserver observer(
415 content::NOTIFICATION_LOAD_STOP, 414 content::NOTIFICATION_LOAD_STOP,
416 content::Source<NavigationController>(&web_contents->GetController())); 415 content::Source<NavigationController>(&web_contents->GetController()));
417 if (allowed) 416 if (allowed)
418 infobar_->delegate()->AsConfirmInfoBarDelegate()->Accept(); 417 infobar_->delegate()->AsConfirmInfoBarDelegate()->Accept();
419 else 418 else
420 infobar_->delegate()->AsConfirmInfoBarDelegate()->Cancel(); 419 infobar_->delegate()->AsConfirmInfoBarDelegate()->Cancel();
421 observer.Wait(); 420 observer.Wait();
422 } 421 }
423 422
424 InfoBarManager* infobar_manager = 423 InfoBarService* infobar_service =
425 InfoBarService::FromWebContents(web_contents)->infobar_manager(); 424 InfoBarService::FromWebContents(web_contents);
426 infobar_manager->RemoveInfoBar(infobar_); 425 infobar_service->RemoveInfoBar(infobar_);
427 LOG(WARNING) << "infobar response set"; 426 LOG(WARNING) << "infobar response set";
428 infobar_ = NULL; 427 infobar_ = NULL;
429 EXPECT_GT(usages_state.state_map().size(), state_map_size); 428 EXPECT_GT(usages_state.state_map().size(), state_map_size);
430 GURL requesting_origin(requesting_url.GetOrigin()); 429 GURL requesting_origin(requesting_url.GetOrigin());
431 EXPECT_EQ(1U, usages_state.state_map().count(requesting_origin)); 430 EXPECT_EQ(1U, usages_state.state_map().count(requesting_origin));
432 ContentSetting expected_setting = 431 ContentSetting expected_setting =
433 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 432 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
434 EXPECT_EQ(expected_setting, 433 EXPECT_EQ(expected_setting,
435 usages_state.state_map().find(requesting_origin)->second); 434 usages_state.state_map().find(requesting_origin)->second);
436 } 435 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 // Disables further prompts from this iframe. 663 // Disables further prompts from this iframe.
665 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); 664 CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)");
666 665
667 // Test second iframe from a different origin with a cached geoposition will 666 // Test second iframe from a different origin with a cached geoposition will
668 // create the infobar. 667 // create the infobar.
669 SetFrameHost("iframe_1"); 668 SetFrameHost("iframe_1");
670 AddGeolocationWatch(true); 669 AddGeolocationWatch(true);
671 670
672 InfoBarService* infobar_service = InfoBarService::FromWebContents( 671 InfoBarService* infobar_service = InfoBarService::FromWebContents(
673 current_browser()->tab_strip_model()->GetActiveWebContents()); 672 current_browser()->tab_strip_model()->GetActiveWebContents());
674 InfoBarManager* infobar_manager = infobar_service->infobar_manager(); 673 size_t num_infobars_before_cancel = infobar_service->infobar_count();
675 size_t num_infobars_before_cancel = infobar_manager->infobar_count();
676 // Change the iframe, and ensure the infobar is gone. 674 // Change the iframe, and ensure the infobar is gone.
677 IFrameLoader change_iframe_1(current_browser(), 1, current_url()); 675 IFrameLoader change_iframe_1(current_browser(), 1, current_url());
678 size_t num_infobars_after_cancel = infobar_manager->infobar_count(); 676 size_t num_infobars_after_cancel = infobar_service->infobar_count();
679 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1); 677 EXPECT_EQ(num_infobars_before_cancel, num_infobars_after_cancel + 1);
680 } 678 }
681 679
682 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, InvalidUrlRequest) { 680 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, InvalidUrlRequest) {
683 // Tests that an invalid URL (e.g. from a popup window) is rejected 681 // Tests that an invalid URL (e.g. from a popup window) is rejected
684 // correctly. Also acts as a regression test for http://crbug.com/40478 682 // correctly. Also acts as a regression test for http://crbug.com/40478
685 set_html_for_tests("/geolocation/invalid_request_url.html"); 683 set_html_for_tests("/geolocation/invalid_request_url.html");
686 ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); 684 ASSERT_TRUE(Initialize(INITIALIZATION_NONE));
687 685
688 SetFrameHost(""); 686 SetFrameHost("");
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 762
765 SetFrameHost("iframe_2"); 763 SetFrameHost("iframe_2");
766 AddGeolocationWatch(false); 764 AddGeolocationWatch(false);
767 765
768 std::string script = 766 std::string script =
769 "window.domAutomationController.send(window.close());"; 767 "window.domAutomationController.send(window.close());";
770 bool result = content::ExecuteScript( 768 bool result = content::ExecuteScript(
771 current_browser()->tab_strip_model()->GetActiveWebContents(), script); 769 current_browser()->tab_strip_model()->GetActiveWebContents(), script);
772 EXPECT_EQ(result, true); 770 EXPECT_EQ(result, true);
773 } 771 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698