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 // Implements the Chrome Extensions WebNavigation API. | 5 // Implements the Chrome Extensions WebNavigation API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 chrome::NOTIFICATION_RETARGETING, | 84 chrome::NOTIFICATION_RETARGETING, |
85 content::NotificationService::AllSources()); | 85 content::NotificationService::AllSources()); |
86 registrar_.Add(this, | 86 registrar_.Add(this, |
87 chrome::NOTIFICATION_TAB_ADDED, | 87 chrome::NOTIFICATION_TAB_ADDED, |
88 content::NotificationService::AllSources()); | 88 content::NotificationService::AllSources()); |
89 registrar_.Add(this, | 89 registrar_.Add(this, |
90 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 90 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
91 content::NotificationService::AllSources()); | 91 content::NotificationService::AllSources()); |
92 | 92 |
93 BrowserList::AddObserver(this); | 93 BrowserList::AddObserver(this); |
94 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 94 for (chrome::BrowserIterator it; !it.done(); it.Next()) |
95 OnBrowserAdded(*it); | 95 OnBrowserAdded(*it); |
96 } | |
97 } | 96 } |
98 | 97 |
99 WebNavigationEventRouter::~WebNavigationEventRouter() { | 98 WebNavigationEventRouter::~WebNavigationEventRouter() { |
| 99 for (chrome::BrowserIterator it; !it.done(); it.Next()) |
| 100 OnBrowserRemoved(*it); |
100 BrowserList::RemoveObserver(this); | 101 BrowserList::RemoveObserver(this); |
101 } | 102 } |
102 | 103 |
103 void WebNavigationEventRouter::OnBrowserAdded(Browser* browser) { | 104 void WebNavigationEventRouter::OnBrowserAdded(Browser* browser) { |
104 if (!profile_->IsSameProfile(browser->profile())) | 105 if (!profile_->IsSameProfile(browser->profile())) |
105 return; | 106 return; |
106 browser->tab_strip_model()->AddObserver(this); | 107 browser->tab_strip_model()->AddObserver(this); |
107 } | 108 } |
108 | 109 |
109 void WebNavigationEventRouter::OnBrowserRemoved(Browser* browser) { | 110 void WebNavigationEventRouter::OnBrowserRemoved(Browser* browser) { |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 } | 858 } |
858 | 859 |
859 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { | 860 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { |
860 web_navigation_event_router_.reset(new WebNavigationEventRouter(profile_)); | 861 web_navigation_event_router_.reset(new WebNavigationEventRouter(profile_)); |
861 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 862 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
862 } | 863 } |
863 | 864 |
864 #endif // OS_ANDROID | 865 #endif // OS_ANDROID |
865 | 866 |
866 } // namespace extensions | 867 } // namespace extensions |
OLD | NEW |