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/extensions/api/web_navigation/web_navigation_api_consta
nts.h" | 10 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta
nts.h" |
11 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper
s.h" | 11 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper
s.h" |
12 #include "chrome/browser/extensions/event_router.h" | 12 #include "chrome/browser/extensions/event_router.h" |
13 #include "chrome/browser/extensions/extension_system.h" | 13 #include "chrome/browser/extensions/extension_system.h" |
14 #include "chrome/browser/extensions/extension_tab_util.h" | 14 #include "chrome/browser/extensions/extension_tab_util.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/tab_contents/retargeting_details.h" | 16 #include "chrome/browser/tab_contents/retargeting_details.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_iterator.h" |
18 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
19 #include "chrome/browser/view_type_utils.h" | 20 #include "chrome/browser/view_type_utils.h" |
20 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
21 #include "chrome/common/extensions/api/web_navigation.h" | 22 #include "chrome/common/extensions/api/web_navigation.h" |
22 #include "content/public/browser/navigation_details.h" | 23 #include "content/public/browser/navigation_details.h" |
23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
25 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/resource_request_details.h" | 28 #include "content/public/browser/resource_request_details.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 chrome::NOTIFICATION_RETARGETING, | 81 chrome::NOTIFICATION_RETARGETING, |
81 content::NotificationService::AllSources()); | 82 content::NotificationService::AllSources()); |
82 registrar_.Add(this, | 83 registrar_.Add(this, |
83 chrome::NOTIFICATION_TAB_ADDED, | 84 chrome::NOTIFICATION_TAB_ADDED, |
84 content::NotificationService::AllSources()); | 85 content::NotificationService::AllSources()); |
85 registrar_.Add(this, | 86 registrar_.Add(this, |
86 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 87 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
87 content::NotificationService::AllSources()); | 88 content::NotificationService::AllSources()); |
88 | 89 |
89 BrowserList::AddObserver(this); | 90 BrowserList::AddObserver(this); |
90 for (BrowserList::const_iterator iter = BrowserList::begin(); | 91 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
91 iter != BrowserList::end(); ++iter) { | 92 OnBrowserAdded(*it); |
92 OnBrowserAdded(*iter); | |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 WebNavigationEventRouter::~WebNavigationEventRouter() { | 96 WebNavigationEventRouter::~WebNavigationEventRouter() { |
97 BrowserList::RemoveObserver(this); | 97 BrowserList::RemoveObserver(this); |
98 } | 98 } |
99 | 99 |
100 void WebNavigationEventRouter::OnBrowserAdded(Browser* browser) { | 100 void WebNavigationEventRouter::OnBrowserAdded(Browser* browser) { |
101 if (!profile_->IsSameProfile(browser->profile())) | 101 if (!profile_->IsSameProfile(browser->profile())) |
102 return; | 102 return; |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 return &g_factory.Get(); | 829 return &g_factory.Get(); |
830 } | 830 } |
831 | 831 |
832 void WebNavigationAPI::OnListenerAdded( | 832 void WebNavigationAPI::OnListenerAdded( |
833 const extensions::EventListenerInfo& details) { | 833 const extensions::EventListenerInfo& details) { |
834 web_navigation_event_router_.reset(new WebNavigationEventRouter(profile_)); | 834 web_navigation_event_router_.reset(new WebNavigationEventRouter(profile_)); |
835 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 835 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
836 } | 836 } |
837 | 837 |
838 } // namespace extensions | 838 } // namespace extensions |
OLD | NEW |