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/ui/ash/launcher/multi_profile_browser_status_monitor.h" | 5 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h" |
6 | 6 |
7 #include "ash/public/cpp/shelf_item.h" | 7 #include "ash/public/cpp/shelf_item.h" |
8 #include "ash/public/cpp/window_properties.h" | 8 #include "ash/public/cpp/window_properties.h" |
| 9 #include "base/stl_util.h" |
9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
12 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 13 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
15 #include "chrome/browser/ui/browser_tabstrip.h" | 16 #include "chrome/browser/ui/browser_tabstrip.h" |
16 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
17 #include "chrome/browser/ui/settings_window_manager.h" | 18 #include "chrome/browser/ui/settings_window_manager.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 87 } |
87 } | 88 } |
88 | 89 |
89 // Update the browser state since some of the removals / adds above might have | 90 // Update the browser state since some of the removals / adds above might have |
90 // had an impact on the browser item. | 91 // had an impact on the browser item. |
91 UpdateBrowserItemState(); | 92 UpdateBrowserItemState(); |
92 } | 93 } |
93 | 94 |
94 void MultiProfileBrowserStatusMonitor::AddV1AppToShelf(Browser* browser) { | 95 void MultiProfileBrowserStatusMonitor::AddV1AppToShelf(Browser* browser) { |
95 DCHECK(browser->is_type_popup() && browser->is_app()); | 96 DCHECK(browser->is_type_popup() && browser->is_app()); |
96 DCHECK(std::find(app_list_.begin(), app_list_.end(), browser) == | 97 DCHECK(!base::ContainsValue(app_list_, browser)); |
97 app_list_.end()); | |
98 app_list_.push_back(browser); | 98 app_list_.push_back(browser); |
99 if (multi_user_util::IsProfileFromActiveUser(browser->profile())) { | 99 if (multi_user_util::IsProfileFromActiveUser(browser->profile())) { |
100 BrowserStatusMonitor::AddV1AppToShelf(browser); | 100 BrowserStatusMonitor::AddV1AppToShelf(browser); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 void MultiProfileBrowserStatusMonitor::RemoveV1AppFromShelf(Browser* browser) { | 104 void MultiProfileBrowserStatusMonitor::RemoveV1AppFromShelf(Browser* browser) { |
105 DCHECK(browser->is_type_popup() && browser->is_app()); | 105 DCHECK(browser->is_type_popup() && browser->is_app()); |
106 AppList::iterator it = std::find(app_list_.begin(), app_list_.end(), browser); | 106 AppList::iterator it = std::find(app_list_.begin(), app_list_.end(), browser); |
107 DCHECK(it != app_list_.end()); | 107 DCHECK(it != app_list_.end()); |
(...skipping 15 matching lines...) Expand all Loading... |
123 | 123 |
124 void MultiProfileBrowserStatusMonitor::DisconnectV1AppFromLauncher( | 124 void MultiProfileBrowserStatusMonitor::DisconnectV1AppFromLauncher( |
125 Browser* browser) { | 125 Browser* browser) { |
126 // Removing a V1 app from the launcher requires to remove the content and | 126 // Removing a V1 app from the launcher requires to remove the content and |
127 // the launcher item. | 127 // the launcher item. |
128 launcher_controller_->UpdateAppState( | 128 launcher_controller_->UpdateAppState( |
129 browser->tab_strip_model()->GetActiveWebContents(), | 129 browser->tab_strip_model()->GetActiveWebContents(), |
130 ChromeLauncherController::APP_STATE_REMOVED); | 130 ChromeLauncherController::APP_STATE_REMOVED); |
131 BrowserStatusMonitor::RemoveV1AppFromShelf(browser); | 131 BrowserStatusMonitor::RemoveV1AppFromShelf(browser); |
132 } | 132 } |
OLD | NEW |