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/shelf/shelf_util.h" |
7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
10 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 11 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/browser/ui/browser_tabstrip.h" | 14 #include "chrome/browser/ui/browser_tabstrip.h" |
14 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/settings_window_manager.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "grit/ash_resources.h" |
16 | 19 |
17 MultiProfileBrowserStatusMonitor::MultiProfileBrowserStatusMonitor( | 20 MultiProfileBrowserStatusMonitor::MultiProfileBrowserStatusMonitor( |
18 ChromeLauncherController* launcher_controller) | 21 ChromeLauncherController* launcher_controller) |
19 : BrowserStatusMonitor(launcher_controller), | 22 : BrowserStatusMonitor(launcher_controller), |
20 launcher_controller_(launcher_controller) { | 23 launcher_controller_(launcher_controller) { |
21 } | 24 } |
22 | 25 |
23 MultiProfileBrowserStatusMonitor::~MultiProfileBrowserStatusMonitor() { | 26 MultiProfileBrowserStatusMonitor::~MultiProfileBrowserStatusMonitor() { |
24 } | 27 } |
25 | 28 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { | 68 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { |
66 launcher_controller_->UpdateAppState( | 69 launcher_controller_->UpdateAppState( |
67 browser->tab_strip_model()->GetWebContentsAt(i), | 70 browser->tab_strip_model()->GetWebContentsAt(i), |
68 browser->window()->IsActive() && i == active_index ? | 71 browser->window()->IsActive() && i == active_index ? |
69 ChromeLauncherController::APP_STATE_WINDOW_ACTIVE : | 72 ChromeLauncherController::APP_STATE_WINDOW_ACTIVE : |
70 ChromeLauncherController::APP_STATE_INACTIVE); | 73 ChromeLauncherController::APP_STATE_INACTIVE); |
71 } | 74 } |
72 } | 75 } |
73 } | 76 } |
74 | 77 |
| 78 // Remove settings window icons not associated with this profile and create |
| 79 // icons for windows associated with the current profile. |
| 80 for (BrowserList::const_iterator it = browser_list->begin(); |
| 81 it != browser_list->end(); ++it) { |
| 82 Browser* browser = *it; |
| 83 if (!chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser( |
| 84 browser)) { |
| 85 continue; |
| 86 } |
| 87 if (multi_user_util::IsProfileFromActiveUser(browser->profile())) { |
| 88 ash::SetShelfItemDetailsForDialogWindow( |
| 89 browser->window()->GetNativeWindow(), |
| 90 IDR_ASH_SHELF_ICON_SETTINGS); |
| 91 } else { |
| 92 ash::ClearShelfItemDetailsForWindow(browser->window()->GetNativeWindow()); |
| 93 } |
| 94 } |
| 95 |
75 // Update the browser state since some of the removals / adds above might have | 96 // Update the browser state since some of the removals / adds above might have |
76 // had an impact on the browser item. | 97 // had an impact on the browser item. |
77 UpdateBrowserItemState(); | 98 UpdateBrowserItemState(); |
78 } | 99 } |
79 | 100 |
80 void MultiProfileBrowserStatusMonitor::AddV1AppToShelf(Browser* browser) { | 101 void MultiProfileBrowserStatusMonitor::AddV1AppToShelf(Browser* browser) { |
81 DCHECK(browser->is_type_popup() && browser->is_app()); | 102 DCHECK(browser->is_type_popup() && browser->is_app()); |
82 DCHECK(std::find(app_list_.begin(), app_list_.end(), browser) == | 103 DCHECK(std::find(app_list_.begin(), app_list_.end(), browser) == |
83 app_list_.end()); | 104 app_list_.end()); |
84 app_list_.push_back(browser); | 105 app_list_.push_back(browser); |
(...skipping 24 matching lines...) Expand all Loading... |
109 | 130 |
110 void MultiProfileBrowserStatusMonitor::DisconnectV1AppFromLauncher( | 131 void MultiProfileBrowserStatusMonitor::DisconnectV1AppFromLauncher( |
111 Browser* browser) { | 132 Browser* browser) { |
112 // Removing a V1 app from the launcher requires to remove the content and | 133 // Removing a V1 app from the launcher requires to remove the content and |
113 // the launcher item. | 134 // the launcher item. |
114 launcher_controller_->UpdateAppState( | 135 launcher_controller_->UpdateAppState( |
115 browser->tab_strip_model()->GetActiveWebContents(), | 136 browser->tab_strip_model()->GetActiveWebContents(), |
116 ChromeLauncherController::APP_STATE_REMOVED); | 137 ChromeLauncherController::APP_STATE_REMOVED); |
117 BrowserStatusMonitor::RemoveV1AppFromShelf(browser); | 138 BrowserStatusMonitor::RemoveV1AppFromShelf(browser); |
118 } | 139 } |
OLD | NEW |