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 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 } | 1173 } |
1174 | 1174 |
1175 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { | 1175 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { |
1176 UpdateAppLaunchersFromPref(); | 1176 UpdateAppLaunchersFromPref(); |
1177 } | 1177 } |
1178 | 1178 |
1179 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { | 1179 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { |
1180 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1180 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1181 FROM_HERE, | 1181 FROM_HERE, |
1182 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, | 1182 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, |
1183 base::Unretained(this))); | 1183 weak_ptr_factory_.GetWeakPtr())); |
1184 } | 1184 } |
1185 | 1185 |
1186 void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { | 1186 void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { |
1187 // There are various functions which will trigger a |SyncPinPosition| call | 1187 // There are various functions which will trigger a |SyncPinPosition| call |
1188 // like a direct call to |DoPinAppWithID|, or an indirect call to the menu | 1188 // like a direct call to |DoPinAppWithID|, or an indirect call to the menu |
1189 // model which will use weights to re-arrange the icons to new positions. | 1189 // model which will use weights to re-arrange the icons to new positions. |
1190 // Since this function is meant to synchronize the "is state" with the | 1190 // Since this function is meant to synchronize the "is state" with the |
1191 // "sync state", it makes no sense to store any changes by this function back | 1191 // "sync state", it makes no sense to store any changes by this function back |
1192 // into the pref state. Therefore we tell |persistPinnedState| to ignore any | 1192 // into the pref state. Therefore we tell |persistPinnedState| to ignore any |
1193 // invocations while we are running. | 1193 // invocations while we are running. |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 if (index == -1) | 1682 if (index == -1) |
1683 continue; | 1683 continue; |
1684 ash::ShelfItem item = model_->items()[index]; | 1684 ash::ShelfItem item = model_->items()[index]; |
1685 item.image = image; | 1685 item.image = image; |
1686 if (arc_deferred_launcher_) | 1686 if (arc_deferred_launcher_) |
1687 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1687 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
1688 model_->Set(index, item); | 1688 model_->Set(index, item); |
1689 // It's possible we're waiting on more than one item, so don't break. | 1689 // It's possible we're waiting on more than one item, so don't break. |
1690 } | 1690 } |
1691 } | 1691 } |
OLD | NEW |