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

Unified Diff: chrome/browser/devtools/global_confirm_info_bar.cc

Issue 2354673004: Add TabStripModel as a parameter of some functions in TabStripModelObserver (Closed)
Patch Set: Last nits Created 4 years, 3 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/devtools/global_confirm_info_bar.cc
diff --git a/chrome/browser/devtools/global_confirm_info_bar.cc b/chrome/browser/devtools/global_confirm_info_bar.cc
index d25d08e904df81587d5684aa37fd39ff9b4816e0..8ef6809dfc55336ea0a3253f9f0e52a9a0a21300 100644
--- a/chrome/browser/devtools/global_confirm_info_bar.cc
+++ b/chrome/browser/devtools/global_confirm_info_bar.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/macros.h"
+#include "base/stl_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "components/infobars/core/infobar.h"
@@ -160,36 +161,17 @@ GlobalConfirmInfoBar::~GlobalConfirmInfoBar() {
}
}
-void GlobalConfirmInfoBar::TabInsertedAt(content::WebContents* web_contents,
+void GlobalConfirmInfoBar::TabInsertedAt(TabStripModel* tab_strip_model,
+ content::WebContents* web_contents,
int index,
bool foreground) {
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents);
- // WebContents from the tab strip must have the infobar service.
- DCHECK(infobar_service);
- if (proxies_.find(infobar_service) != proxies_.end())
- return;
-
- std::unique_ptr<GlobalConfirmInfoBar::DelegateProxy> proxy(
- new GlobalConfirmInfoBar::DelegateProxy(weak_factory_.GetWeakPtr()));
- GlobalConfirmInfoBar::DelegateProxy* proxy_ptr = proxy.get();
- infobars::InfoBar* added_bar = infobar_service->AddInfoBar(
- infobar_service->CreateConfirmInfoBar(std::move(proxy)));
-
- proxy_ptr->info_bar_ = added_bar;
- DCHECK(added_bar);
- proxies_[infobar_service] = proxy_ptr;
- infobar_service->AddObserver(this);
+ MaybeAddInfoBar(web_contents);
}
void GlobalConfirmInfoBar::TabChangedAt(content::WebContents* web_contents,
int index,
TabChangeType change_type) {
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents);
- auto it = proxies_.find(infobar_service);
- if (it == proxies_.end())
- TabInsertedAt(web_contents, index, false);
+ MaybeAddInfoBar(web_contents);
}
void GlobalConfirmInfoBar::OnInfoBarRemoved(infobars::InfoBar* info_bar,
@@ -208,3 +190,23 @@ void GlobalConfirmInfoBar::OnManagerShuttingDown(
manager->RemoveObserver(this);
proxies_.erase(manager);
}
+
+void GlobalConfirmInfoBar::MaybeAddInfoBar(content::WebContents* web_contents) {
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(web_contents);
+ // WebContents from the tab strip must have the infobar service.
+ DCHECK(infobar_service);
+ if (ContainsKey(proxies_, infobar_service))
+ return;
+
+ std::unique_ptr<GlobalConfirmInfoBar::DelegateProxy> proxy(
+ new GlobalConfirmInfoBar::DelegateProxy(weak_factory_.GetWeakPtr()));
+ GlobalConfirmInfoBar::DelegateProxy* proxy_ptr = proxy.get();
+ infobars::InfoBar* added_bar = infobar_service->AddInfoBar(
+ infobar_service->CreateConfirmInfoBar(std::move(proxy)));
+
+ proxy_ptr->info_bar_ = added_bar;
+ DCHECK(added_bar);
+ proxies_[infobar_service] = proxy_ptr;
+ infobar_service->AddObserver(this);
+}
« no previous file with comments | « chrome/browser/devtools/global_confirm_info_bar.h ('k') | chrome/browser/extensions/api/tabs/tabs_event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698