Chromium Code Reviews| Index: chrome/browser/ui/ash/launcher/browser_status_monitor.cc |
| diff --git a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc |
| index 4b7d06bf0940463cdeacea7fdc76d440398c972e..02f11e316b800b5dbbddd3659a6882e96d532137 100644 |
| --- a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc |
| +++ b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc |
| @@ -259,8 +259,9 @@ void BrowserStatusMonitor::AddV1AppToShelf(Browser* browser) { |
| std::string app_id = |
| web_app::GetExtensionIdFromApplicationName(browser->app_name()); |
| if (!app_id.empty()) { |
| + if (!IsV1AppInShelfWithAppId(app_id)) |
| + launcher_controller_->SetV1AppStatus(app_id, ash::STATUS_RUNNING); |
| browser_to_app_id_map_[browser] = app_id; |
| - launcher_controller_->LockV1AppWithID(app_id); |
|
James Cook
2017/03/31 01:07:41
Like I mentioned on IM, I'm a little concerned in
msw
2017/03/31 03:27:14
This matches the existing behavior. Any popup brow
|
| } |
| } |
| @@ -268,9 +269,12 @@ void BrowserStatusMonitor::RemoveV1AppFromShelf(Browser* browser) { |
| DCHECK(browser->is_type_popup() && browser->is_app()); |
| DCHECK(initialized_); |
| - if (browser_to_app_id_map_.find(browser) != browser_to_app_id_map_.end()) { |
| - launcher_controller_->UnlockV1AppWithID(browser_to_app_id_map_[browser]); |
| - browser_to_app_id_map_.erase(browser); |
| + auto iter = browser_to_app_id_map_.find(browser); |
| + if (iter != browser_to_app_id_map_.end()) { |
| + std::string app_id = iter->second; |
| + browser_to_app_id_map_.erase(iter); |
| + if (!IsV1AppInShelfWithAppId(app_id)) |
| + launcher_controller_->SetV1AppStatus(app_id, ash::STATUS_CLOSED); |
| } |
| } |
| @@ -278,6 +282,14 @@ bool BrowserStatusMonitor::IsV1AppInShelf(Browser* browser) { |
| return browser_to_app_id_map_.find(browser) != browser_to_app_id_map_.end(); |
| } |
| +bool BrowserStatusMonitor::IsV1AppInShelfWithAppId(std::string app_id) { |
| + for (const auto& iter : browser_to_app_id_map_) { |
|
James Cook
2017/03/31 01:07:41
optional: stl_util.h base::ContainsValue()
msw
2017/03/31 03:27:14
Unfortunately I'm looking for a map *value* matchi
|
| + if (iter.second == app_id) |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| void BrowserStatusMonitor::AddWebContentsObserver( |
| content::WebContents* contents) { |
| if (webcontents_to_observer_map_.find(contents) == |