Chromium Code Reviews| 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..1307c22798c5cde22f10f66f92aff421bcae9d91 100644 |
| --- a/chrome/browser/devtools/global_confirm_info_bar.cc |
| +++ b/chrome/browser/devtools/global_confirm_info_bar.cc |
| @@ -160,36 +160,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 +189,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 (proxies_.find(infobar_service) != proxies_.end()) |
|
sky
2016/09/20 20:00:46
optional: ContainsKey(proxies_, infobar_service);
Patrick Monette
2016/09/20 20:11:54
Done.
|
| + 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); |
| +} |