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 | 6 |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
9 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | 9 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
10 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 10 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
11 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 11 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
12 #include "chrome/browser/tab_contents/infobar.h" | 12 #include "chrome/browser/tab_contents/infobar.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
14 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
15 #include "chrome/test/testing_profile.h" | 15 #include "chrome/test/testing_profile.h" |
16 #include "content/browser/browser_thread.h" | 16 #include "content/browser/browser_thread.h" |
17 #include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h
" | 17 #include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h
" |
18 #include "content/browser/geolocation/location_arbitrator.h" | 18 #include "content/browser/geolocation/location_arbitrator.h" |
19 #include "content/browser/geolocation/location_provider.h" | 19 #include "content/browser/geolocation/location_provider.h" |
20 #include "content/browser/geolocation/mock_location_provider.h" | 20 #include "content/browser/geolocation/mock_location_provider.h" |
21 #include "content/browser/renderer_host/mock_render_process_host.h" | 21 #include "content/browser/renderer_host/mock_render_process_host.h" |
22 #include "content/browser/tab_contents/test_tab_contents.h" | 22 #include "content/browser/tab_contents/test_tab_contents.h" |
| 23 #include "chrome/common/chrome_notification_types.h" |
23 #include "content/common/geolocation_messages.h" | 24 #include "content/common/geolocation_messages.h" |
24 #include "content/common/notification_registrar.h" | 25 #include "content/common/notification_registrar.h" |
25 #include "content/common/notification_service.h" | 26 #include "content/common/notification_service.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 | 28 |
28 // ClosedDelegateTracker ------------------------------------------------------ | 29 // ClosedDelegateTracker ------------------------------------------------------ |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 // We need to track which infobars were closed. | 33 // We need to track which infobars were closed. |
33 class ClosedDelegateTracker : public NotificationObserver { | 34 class ClosedDelegateTracker : public NotificationObserver { |
34 public: | 35 public: |
35 ClosedDelegateTracker(); | 36 ClosedDelegateTracker(); |
36 virtual ~ClosedDelegateTracker(); | 37 virtual ~ClosedDelegateTracker(); |
37 | 38 |
38 // NotificationObserver: | 39 // NotificationObserver: |
39 virtual void Observe(NotificationType type, | 40 virtual void Observe(int type, |
40 const NotificationSource& source, | 41 const NotificationSource& source, |
41 const NotificationDetails& details); | 42 const NotificationDetails& details); |
42 | 43 |
43 size_t size() const { | 44 size_t size() const { |
44 return removed_infobar_delegates_.size(); | 45 return removed_infobar_delegates_.size(); |
45 } | 46 } |
46 | 47 |
47 bool Contains(InfoBarDelegate* delegate) const; | 48 bool Contains(InfoBarDelegate* delegate) const; |
48 void Clear(); | 49 void Clear(); |
49 | 50 |
50 private: | 51 private: |
51 NotificationRegistrar registrar_; | 52 NotificationRegistrar registrar_; |
52 std::set<InfoBarDelegate*> removed_infobar_delegates_; | 53 std::set<InfoBarDelegate*> removed_infobar_delegates_; |
53 }; | 54 }; |
54 | 55 |
55 ClosedDelegateTracker::ClosedDelegateTracker() { | 56 ClosedDelegateTracker::ClosedDelegateTracker() { |
56 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, | 57 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
57 NotificationService::AllSources()); | 58 NotificationService::AllSources()); |
58 } | 59 } |
59 | 60 |
60 ClosedDelegateTracker::~ClosedDelegateTracker() { | 61 ClosedDelegateTracker::~ClosedDelegateTracker() { |
61 } | 62 } |
62 | 63 |
63 void ClosedDelegateTracker::Observe(NotificationType type, | 64 void ClosedDelegateTracker::Observe(int type, |
64 const NotificationSource& source, | 65 const NotificationSource& source, |
65 const NotificationDetails& details) { | 66 const NotificationDetails& details) { |
66 DCHECK(type.value == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED); | 67 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); |
67 removed_infobar_delegates_.insert( | 68 removed_infobar_delegates_.insert( |
68 Details<InfoBarRemovedDetails>(details)->first); | 69 Details<InfoBarRemovedDetails>(details)->first); |
69 } | 70 } |
70 | 71 |
71 bool ClosedDelegateTracker::Contains(InfoBarDelegate* delegate) const { | 72 bool ClosedDelegateTracker::Contains(InfoBarDelegate* delegate) const { |
72 return removed_infobar_delegates_.count(delegate) != 0; | 73 return removed_infobar_delegates_.count(delegate) != 0; |
73 } | 74 } |
74 | 75 |
75 void ClosedDelegateTracker::Clear() { | 76 void ClosedDelegateTracker::Clear() { |
76 removed_infobar_delegates_.clear(); | 77 removed_infobar_delegates_.clear(); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 // Ensure only one infobar is created. | 486 // Ensure only one infobar is created. |
486 ASSERT_EQ(1U, contents_wrapper()->infobar_count()); | 487 ASSERT_EQ(1U, contents_wrapper()->infobar_count()); |
487 ConfirmInfoBarDelegate* infobar_0 = | 488 ConfirmInfoBarDelegate* infobar_0 = |
488 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 489 contents_wrapper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
489 ASSERT_TRUE(infobar_0); | 490 ASSERT_TRUE(infobar_0); |
490 | 491 |
491 // Delete the tab contents. | 492 // Delete the tab contents. |
492 DeleteContents(); | 493 DeleteContents(); |
493 infobar_0->InfoBarClosed(); | 494 infobar_0->InfoBarClosed(); |
494 } | 495 } |
OLD | NEW |