| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/api/tabs/tabs_event_router.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_event_router.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 BrowserList::AddObserver(this); | 123 BrowserList::AddObserver(this); |
| 124 | 124 |
| 125 // Init() can happen after the browser is running, so catch up with any | 125 // Init() can happen after the browser is running, so catch up with any |
| 126 // windows that already exist. | 126 // windows that already exist. |
| 127 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 127 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
| 128 RegisterForBrowserNotifications(*it); | 128 RegisterForBrowserNotifications(*it); |
| 129 | 129 |
| 130 // Also catch up our internal bookkeeping of tab entries. | 130 // Also catch up our internal bookkeeping of tab entries. |
| 131 Browser* browser = *it; | 131 Browser* browser = *it; |
| 132 if (browser->tab_strip_model()) { | 132 if (ExtensionTabUtil::BrowserSupportsTabs(browser)) { |
| 133 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { | 133 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { |
| 134 WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(i); | 134 WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(i); |
| 135 int tab_id = ExtensionTabUtil::GetTabId(contents); | 135 int tab_id = ExtensionTabUtil::GetTabId(contents); |
| 136 tab_entries_[tab_id] = make_linked_ptr(new TabEntry(contents)); | 136 tab_entries_[tab_id] = make_linked_ptr(new TabEntry(contents)); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 TabsEventRouter::~TabsEventRouter() { | 142 TabsEventRouter::~TabsEventRouter() { |
| 143 BrowserList::RemoveObserver(this); | 143 BrowserList::RemoveObserver(this); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void TabsEventRouter::OnBrowserAdded(Browser* browser) { | 146 void TabsEventRouter::OnBrowserAdded(Browser* browser) { |
| 147 RegisterForBrowserNotifications(browser); | 147 RegisterForBrowserNotifications(browser); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void TabsEventRouter::RegisterForBrowserNotifications(Browser* browser) { | 150 void TabsEventRouter::RegisterForBrowserNotifications(Browser* browser) { |
| 151 if (!profile_->IsSameProfile(browser->profile())) | 151 if (!profile_->IsSameProfile(browser->profile()) || |
| 152 !ExtensionTabUtil::BrowserSupportsTabs(browser)) |
| 152 return; | 153 return; |
| 153 // Start listening to TabStripModel events for this browser. | 154 // Start listening to TabStripModel events for this browser. |
| 154 TabStripModel* tab_strip = browser->tab_strip_model(); | 155 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 155 tab_strip->AddObserver(this); | 156 tab_strip->AddObserver(this); |
| 156 | 157 |
| 157 for (int i = 0; i < tab_strip->count(); ++i) { | 158 for (int i = 0; i < tab_strip->count(); ++i) { |
| 158 RegisterForTabNotifications(tab_strip->GetWebContentsAt(i)); | 159 RegisterForTabNotifications(tab_strip->GetWebContentsAt(i)); |
| 159 } | 160 } |
| 160 } | 161 } |
| 161 | 162 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 void TabsEventRouter::OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, | 608 void TabsEventRouter::OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, |
| 608 bool icon_url_changed) { | 609 bool icon_url_changed) { |
| 609 if (icon_url_changed) { | 610 if (icon_url_changed) { |
| 610 favicon::ContentFaviconDriver* content_favicon_driver = | 611 favicon::ContentFaviconDriver* content_favicon_driver = |
| 611 static_cast<favicon::ContentFaviconDriver*>(favicon_driver); | 612 static_cast<favicon::ContentFaviconDriver*>(favicon_driver); |
| 612 FaviconUrlUpdated(content_favicon_driver->web_contents()); | 613 FaviconUrlUpdated(content_favicon_driver->web_contents()); |
| 613 } | 614 } |
| 614 } | 615 } |
| 615 | 616 |
| 616 } // namespace extensions | 617 } // namespace extensions |
| OLD | NEW |