| 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/common/shelf/shelf_item_types.h" | 7 #include "ash/common/shelf/shelf_item_types.h" |
| 8 #include "ash/common/wm_window.h" | 8 #include "ash/common/wm_window.h" |
| 9 #include "ash/common/wm_window_property.h" | 9 #include "ash/public/cpp/window_properties.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 13 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 13 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
| 16 #include "chrome/browser/ui/browser_tabstrip.h" | 16 #include "chrome/browser/ui/browser_tabstrip.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/settings_window_manager.h" | 18 #include "chrome/browser/ui/settings_window_manager.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "ui/aura/window.h" |
| 20 | 21 |
| 21 MultiProfileBrowserStatusMonitor::MultiProfileBrowserStatusMonitor( | 22 MultiProfileBrowserStatusMonitor::MultiProfileBrowserStatusMonitor( |
| 22 ChromeLauncherController* launcher_controller) | 23 ChromeLauncherController* launcher_controller) |
| 23 : BrowserStatusMonitor(launcher_controller), | 24 : BrowserStatusMonitor(launcher_controller), |
| 24 launcher_controller_(launcher_controller) { | 25 launcher_controller_(launcher_controller) { |
| 25 } | 26 } |
| 26 | 27 |
| 27 MultiProfileBrowserStatusMonitor::~MultiProfileBrowserStatusMonitor() { | 28 MultiProfileBrowserStatusMonitor::~MultiProfileBrowserStatusMonitor() { |
| 28 } | 29 } |
| 29 | 30 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 71 } |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 74 // Hide settings window shelf items not associated with this profile and | 75 // Hide settings window shelf items not associated with this profile and |
| 75 // restore items for windows associated with the current profile. | 76 // restore items for windows associated with the current profile. |
| 76 for (Browser* browser : *browser_list) { | 77 for (Browser* browser : *browser_list) { |
| 77 if (chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser( | 78 if (chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser( |
| 78 browser)) { | 79 browser)) { |
| 79 aura::Window* aura_window = browser->window()->GetNativeWindow(); | 80 aura::Window* aura_window = browser->window()->GetNativeWindow(); |
| 80 ash::WmWindow::Get(aura_window) | 81 aura_window->SetProperty( |
| 81 ->SetIntProperty( | 82 ash::kShelfItemTypeKey, |
| 82 ash::WmWindowProperty::SHELF_ITEM_TYPE, | 83 static_cast<int32_t>( |
| 83 multi_user_util::IsProfileFromActiveUser(browser->profile()) | 84 multi_user_util::IsProfileFromActiveUser(browser->profile()) |
| 84 ? ash::TYPE_DIALOG | 85 ? ash::TYPE_DIALOG |
| 85 : ash::TYPE_UNDEFINED); | 86 : ash::TYPE_UNDEFINED)); |
| 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()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 123 | 124 |
| 124 void MultiProfileBrowserStatusMonitor::DisconnectV1AppFromLauncher( | 125 void MultiProfileBrowserStatusMonitor::DisconnectV1AppFromLauncher( |
| 125 Browser* browser) { | 126 Browser* browser) { |
| 126 // Removing a V1 app from the launcher requires to remove the content and | 127 // Removing a V1 app from the launcher requires to remove the content and |
| 127 // the launcher item. | 128 // the launcher item. |
| 128 launcher_controller_->UpdateAppState( | 129 launcher_controller_->UpdateAppState( |
| 129 browser->tab_strip_model()->GetActiveWebContents(), | 130 browser->tab_strip_model()->GetActiveWebContents(), |
| 130 ChromeLauncherController::APP_STATE_REMOVED); | 131 ChromeLauncherController::APP_STATE_REMOVED); |
| 131 BrowserStatusMonitor::RemoveV1AppFromShelf(browser); | 132 BrowserStatusMonitor::RemoveV1AppFromShelf(browser); |
| 132 } | 133 } |
| OLD | NEW |