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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.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/geolocation/chrome_geolocation_permission_context.h" | 14 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
15 #include "chrome/browser/infobars/infobar.h" | 15 #include "chrome/browser/infobars/infobar.h" |
16 #include "chrome/browser/infobars/infobar_tab_helper.h" | 16 #include "chrome/browser/infobars/infobar_tab_helper.h" |
17 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 17 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
19 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
20 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
22 #include "content/browser/tab_contents/test_tab_contents.h" | |
23 #include "content/public/browser/navigation_details.h" | 22 #include "content/public/browser/navigation_details.h" |
24 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
25 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/web_contents.h" |
26 #include "content/test/mock_geolocation.h" | 26 #include "content/test/mock_geolocation.h" |
27 #include "content/test/mock_render_process_host.h" | 27 #include "content/test/mock_render_process_host.h" |
28 #include "content/test/test_browser_thread.h" | 28 #include "content/test/test_browser_thread.h" |
29 #include "content/test/test_renderer_host.h" | 29 #include "content/test/test_renderer_host.h" |
| 30 #include "content/test/web_contents_tester.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
31 | 32 |
32 using content::BrowserThread; | 33 using content::BrowserThread; |
33 using content::MockRenderProcessHost; | 34 using content::MockRenderProcessHost; |
34 using content::RenderViewHostTester; | 35 using content::RenderViewHostTester; |
35 using content::WebContents; | 36 using content::WebContents; |
| 37 using content::WebContentsTester; |
36 | 38 |
37 // ClosedDelegateTracker ------------------------------------------------------ | 39 // ClosedDelegateTracker ------------------------------------------------------ |
38 | 40 |
39 namespace { | 41 namespace { |
40 | 42 |
41 // We need to track which infobars were closed. | 43 // We need to track which infobars were closed. |
42 class ClosedDelegateTracker : public content::NotificationObserver { | 44 class ClosedDelegateTracker : public content::NotificationObserver { |
43 public: | 45 public: |
44 ClosedDelegateTracker(); | 46 ClosedDelegateTracker(); |
45 virtual ~ClosedDelegateTracker(); | 47 virtual ~ClosedDelegateTracker(); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 process_id(), render_id(), bridge_id(), requesting_frame_1); | 585 process_id(), render_id(), bridge_id(), requesting_frame_1); |
584 // Ensure the infobar is created. | 586 // Ensure the infobar is created. |
585 ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); | 587 ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); |
586 InfoBarDelegate* infobar_0 = infobar_tab_helper()->GetInfoBarDelegateAt(0); | 588 InfoBarDelegate* infobar_0 = infobar_tab_helper()->GetInfoBarDelegateAt(0); |
587 ASSERT_TRUE(infobar_0); | 589 ASSERT_TRUE(infobar_0); |
588 // Ensure the infobar is not yet expired. | 590 // Ensure the infobar is not yet expired. |
589 content::LoadCommittedDetails details; | 591 content::LoadCommittedDetails details; |
590 details.entry = contents()->GetController().GetLastCommittedEntry(); | 592 details.entry = contents()->GetController().GetLastCommittedEntry(); |
591 ASSERT_FALSE(infobar_0->ShouldExpire(details)); | 593 ASSERT_FALSE(infobar_0->ShouldExpire(details)); |
592 // Commit the "GoBack()" above, and ensure the infobar is now expired. | 594 // Commit the "GoBack()" above, and ensure the infobar is now expired. |
593 contents()->CommitPendingNavigation(); | 595 WebContentsTester::For(contents())->CommitPendingNavigation(); |
594 details.entry = contents()->GetController().GetLastCommittedEntry(); | 596 details.entry = contents()->GetController().GetLastCommittedEntry(); |
595 ASSERT_TRUE(infobar_0->ShouldExpire(details)); | 597 ASSERT_TRUE(infobar_0->ShouldExpire(details)); |
596 | 598 |
597 // Delete the tab contents. | 599 // Delete the tab contents. |
598 DeleteContents(); | 600 DeleteContents(); |
599 infobar_0->InfoBarClosed(); | 601 infobar_0->InfoBarClosed(); |
600 } | 602 } |
OLD | NEW |