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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
11 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | 11 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
12 #include "chrome/browser/infobars/infobar.h" | 12 #include "chrome/browser/infobars/infobar.h" |
13 #include "chrome/browser/infobars/infobar_tab_helper.h" | 13 #include "chrome/browser/infobars/infobar_tab_helper.h" |
14 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 14 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
16 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
18 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
19 #include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h
" | 19 #include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h
" |
20 #include "content/browser/geolocation/location_arbitrator.h" | 20 #include "content/browser/geolocation/location_arbitrator.h" |
21 #include "content/browser/geolocation/location_provider.h" | 21 #include "content/browser/geolocation/location_provider.h" |
22 #include "content/browser/geolocation/mock_location_provider.h" | 22 #include "content/browser/geolocation/mock_location_provider.h" |
23 #include "content/browser/renderer_host/mock_render_process_host.h" | 23 #include "content/browser/renderer_host/mock_render_process_host.h" |
24 #include "content/browser/tab_contents/test_tab_contents.h" | 24 #include "content/browser/tab_contents/test_tab_contents.h" |
25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
26 #include "content/common/geolocation_messages.h" | 26 #include "content/common/geolocation_messages.h" |
27 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
28 #include "content/common/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
30 | 30 |
31 // ClosedDelegateTracker ------------------------------------------------------ | 31 // ClosedDelegateTracker ------------------------------------------------------ |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 // We need to track which infobars were closed. | 35 // We need to track which infobars were closed. |
36 class ClosedDelegateTracker : public content::NotificationObserver { | 36 class ClosedDelegateTracker : public content::NotificationObserver { |
37 public: | 37 public: |
38 ClosedDelegateTracker(); | 38 ClosedDelegateTracker(); |
(...skipping 11 matching lines...) Expand all Loading... |
50 bool Contains(InfoBarDelegate* delegate) const; | 50 bool Contains(InfoBarDelegate* delegate) const; |
51 void Clear(); | 51 void Clear(); |
52 | 52 |
53 private: | 53 private: |
54 content::NotificationRegistrar registrar_; | 54 content::NotificationRegistrar registrar_; |
55 std::set<InfoBarDelegate*> removed_infobar_delegates_; | 55 std::set<InfoBarDelegate*> removed_infobar_delegates_; |
56 }; | 56 }; |
57 | 57 |
58 ClosedDelegateTracker::ClosedDelegateTracker() { | 58 ClosedDelegateTracker::ClosedDelegateTracker() { |
59 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 59 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
60 NotificationService::AllSources()); | 60 content::NotificationService::AllSources()); |
61 } | 61 } |
62 | 62 |
63 ClosedDelegateTracker::~ClosedDelegateTracker() { | 63 ClosedDelegateTracker::~ClosedDelegateTracker() { |
64 } | 64 } |
65 | 65 |
66 void ClosedDelegateTracker::Observe( | 66 void ClosedDelegateTracker::Observe( |
67 int type, | 67 int type, |
68 const content::NotificationSource& source, | 68 const content::NotificationSource& source, |
69 const content::NotificationDetails& details) { | 69 const content::NotificationDetails& details) { |
70 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); | 70 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 // Ensure only one infobar is created. | 529 // Ensure only one infobar is created. |
530 ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); | 530 ASSERT_EQ(1U, infobar_tab_helper()->infobar_count()); |
531 ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> | 531 ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()-> |
532 GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 532 GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
533 ASSERT_TRUE(infobar_0); | 533 ASSERT_TRUE(infobar_0); |
534 | 534 |
535 // Delete the tab contents. | 535 // Delete the tab contents. |
536 DeleteContents(); | 536 DeleteContents(); |
537 infobar_0->InfoBarClosed(); | 537 infobar_0->InfoBarClosed(); |
538 } | 538 } |
OLD | NEW |