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/chrome_launcher_controller_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void ChromeLauncherControllerUserSwitchObserver::AddUser(Profile* profile) { | 182 void ChromeLauncherControllerUserSwitchObserver::AddUser(Profile* profile) { |
183 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == | 183 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == |
184 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) | 184 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) |
185 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); | 185 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); |
186 controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile()); | 186 controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile()); |
187 } | 187 } |
188 | 188 |
189 ChromeLauncherControllerImpl::ChromeLauncherControllerImpl( | 189 ChromeLauncherControllerImpl::ChromeLauncherControllerImpl( |
190 Profile* profile, | 190 Profile* profile, |
191 ash::ShelfModel* model) | 191 ash::ShelfModel* model) |
192 : model_(model), profile_(profile) { | 192 : model_(model), profile_(profile), weak_ptr_factory_(this) { |
193 DCHECK(model_); | 193 DCHECK(model_); |
194 if (!profile_) { | 194 if (!profile_) { |
195 // If no profile was passed, we take the currently active profile and use it | 195 // If no profile was passed, we take the currently active profile and use it |
196 // as the owner of the current desktop. | 196 // as the owner of the current desktop. |
197 // Use the original profile as on chromeos we may get a temporary off the | 197 // Use the original profile as on chromeos we may get a temporary off the |
198 // record profile, unless in guest session (where off the record profile is | 198 // record profile, unless in guest session (where off the record profile is |
199 // the right one). | 199 // the right one). |
200 profile_ = ProfileManager::GetActiveUserProfile(); | 200 profile_ = ProfileManager::GetActiveUserProfile(); |
201 if (!profile_->IsGuestSession() && !profile_->IsSystemProfile()) | 201 if (!profile_->IsGuestSession() && !profile_->IsSystemProfile()) |
202 profile_ = profile_->GetOriginalProfile(); | 202 profile_ = profile_->GetOriginalProfile(); |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 } | 1184 } |
1185 | 1185 |
1186 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { | 1186 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { |
1187 UpdateAppLaunchersFromPref(); | 1187 UpdateAppLaunchersFromPref(); |
1188 } | 1188 } |
1189 | 1189 |
1190 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { | 1190 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { |
1191 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1191 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1192 FROM_HERE, | 1192 FROM_HERE, |
1193 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, | 1193 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, |
1194 base::Unretained(this))); | 1194 weak_ptr_factory_.GetWeakPtr())); |
1195 } | 1195 } |
1196 | 1196 |
1197 void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { | 1197 void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { |
1198 // There are various functions which will trigger a |SyncPinPosition| call | 1198 // There are various functions which will trigger a |SyncPinPosition| call |
1199 // like a direct call to |DoPinAppWithID|, or an indirect call to the menu | 1199 // like a direct call to |DoPinAppWithID|, or an indirect call to the menu |
1200 // model which will use weights to re-arrange the icons to new positions. | 1200 // model which will use weights to re-arrange the icons to new positions. |
1201 // Since this function is meant to synchronize the "is state" with the | 1201 // Since this function is meant to synchronize the "is state" with the |
1202 // "sync state", it makes no sense to store any changes by this function back | 1202 // "sync state", it makes no sense to store any changes by this function back |
1203 // into the pref state. Therefore we tell |persistPinnedState| to ignore any | 1203 // into the pref state. Therefore we tell |persistPinnedState| to ignore any |
1204 // invocations while we are running. | 1204 // invocations while we are running. |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 if (index == -1) | 1693 if (index == -1) |
1694 continue; | 1694 continue; |
1695 ash::ShelfItem item = model_->items()[index]; | 1695 ash::ShelfItem item = model_->items()[index]; |
1696 item.image = image; | 1696 item.image = image; |
1697 if (arc_deferred_launcher_) | 1697 if (arc_deferred_launcher_) |
1698 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1698 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
1699 model_->Set(index, item); | 1699 model_->Set(index, item); |
1700 // It's possible we're waiting on more than one item, so don't break. | 1700 // It's possible we're waiting on more than one item, so don't break. |
1701 } | 1701 } |
1702 } | 1702 } |
OLD | NEW |