Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5295)

Unified Diff: chrome/browser/extensions/api/web_navigation/web_navigation_api.cc

Issue 1400823003: Creates BrowserTabStripTracker to consolidate common code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review feedback and git cl format Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
index 2e8522fb0e484f0f6572bcc9d02a8bc66339bad1..6597f0efa99cbb815f0874b0217a7be994406543 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
@@ -74,7 +74,7 @@ WebNavigationEventRouter::PendingWebContents::PendingWebContents(
WebNavigationEventRouter::PendingWebContents::~PendingWebContents() {}
WebNavigationEventRouter::WebNavigationEventRouter(Profile* profile)
- : profile_(profile) {
+ : profile_(profile), browser_tab_strip_tracker_(this, this, nullptr) {
CHECK(registrar_.IsEmpty());
registrar_.Add(this,
chrome::NOTIFICATION_RETARGETING,
@@ -86,27 +86,15 @@ WebNavigationEventRouter::WebNavigationEventRouter(Profile* profile)
content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::NotificationService::AllSources());
- BrowserList::AddObserver(this);
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- OnBrowserAdded(*it);
+ browser_tab_strip_tracker_.Init(
+ BrowserTabStripTracker::InitWith::ALL_BROWERS);
}
WebNavigationEventRouter::~WebNavigationEventRouter() {
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- OnBrowserRemoved(*it);
- BrowserList::RemoveObserver(this);
}
-void WebNavigationEventRouter::OnBrowserAdded(Browser* browser) {
- if (!profile_->IsSameProfile(browser->profile()))
- return;
- browser->tab_strip_model()->AddObserver(this);
-}
-
-void WebNavigationEventRouter::OnBrowserRemoved(Browser* browser) {
- if (!profile_->IsSameProfile(browser->profile()))
- return;
- browser->tab_strip_model()->RemoveObserver(this);
+bool WebNavigationEventRouter::ShouldTrackBrowser(Browser* browser) {
+ return profile_->IsSameProfile(browser->profile());
}
void WebNavigationEventRouter::TabReplacedAt(
« no previous file with comments | « chrome/browser/extensions/api/web_navigation/web_navigation_api.h ('k') | chrome/browser/memory/tab_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698