Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc

Issue 2281743002: arc: Add support of default and OEM apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void ChromeLauncherControllerUserSwitchObserver::AddUser(Profile* profile) { 183 void ChromeLauncherControllerUserSwitchObserver::AddUser(Profile* profile) {
184 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == 184 if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
185 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) 185 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED)
186 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); 186 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile);
187 controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile()); 187 controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile());
188 } 188 }
189 189
190 ChromeLauncherControllerImpl::ChromeLauncherControllerImpl( 190 ChromeLauncherControllerImpl::ChromeLauncherControllerImpl(
191 Profile* profile, 191 Profile* profile,
192 ash::ShelfModel* model) 192 ash::ShelfModel* model)
193 : model_(model), profile_(profile) { 193 : model_(model), profile_(profile), weak_ptr_factory_(this) {
194 DCHECK(model_); 194 DCHECK(model_);
195 if (!profile_) { 195 if (!profile_) {
196 // If no profile was passed, we take the currently active profile and use it 196 // If no profile was passed, we take the currently active profile and use it
197 // as the owner of the current desktop. 197 // as the owner of the current desktop.
198 // Use the original profile as on chromeos we may get a temporary off the 198 // Use the original profile as on chromeos we may get a temporary off the
199 // record profile, unless in guest session (where off the record profile is 199 // record profile, unless in guest session (where off the record profile is
200 // the right one). 200 // the right one).
201 profile_ = ProfileManager::GetActiveUserProfile(); 201 profile_ = ProfileManager::GetActiveUserProfile();
202 if (!profile_->IsGuestSession() && !profile_->IsSystemProfile()) 202 if (!profile_->IsGuestSession() && !profile_->IsSystemProfile())
203 profile_ = profile_->GetOriginalProfile(); 203 profile_ = profile_->GetOriginalProfile();
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 if (arc::ArcAuthService::IsAllowedForProfile(profile_)) { 1517 if (arc::ArcAuthService::IsAllowedForProfile(profile_)) {
1518 std::unique_ptr<AppIconLoader> arc_app_icon_loader(new ArcAppIconLoader( 1518 std::unique_ptr<AppIconLoader> arc_app_icon_loader(new ArcAppIconLoader(
1519 profile_, extension_misc::EXTENSION_ICON_SMALL, this)); 1519 profile_, extension_misc::EXTENSION_ICON_SMALL, this));
1520 app_icon_loaders_.push_back(std::move(arc_app_icon_loader)); 1520 app_icon_loaders_.push_back(std::move(arc_app_icon_loader));
1521 } 1521 }
1522 1522
1523 pref_change_registrar_.Init(profile_->GetPrefs()); 1523 pref_change_registrar_.Init(profile_->GetPrefs());
1524 pref_change_registrar_.Add( 1524 pref_change_registrar_.Add(
1525 prefs::kPolicyPinnedLauncherApps, 1525 prefs::kPolicyPinnedLauncherApps,
1526 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, 1526 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref,
1527 base::Unretained(this))); 1527 weak_ptr_factory_.GetWeakPtr()));
xiyuan 2016/08/26 19:32:30 This is not necessary as long as PrefChangeRegistr
khmel 2016/08/26 23:26:18 Overfixed :)
1528 // Handling of prefs::kArcEnabled change should be called deferred to avoid 1528 // Handling of prefs::kArcEnabled change should be called deferred to avoid
1529 // race condition when OnAppUninstalledPrepared for Arc apps is called after 1529 // race condition when OnAppUninstalledPrepared for Arc apps is called after
1530 // UpdateAppLaunchersFromPref. 1530 // UpdateAppLaunchersFromPref.
1531 pref_change_registrar_.Add( 1531 pref_change_registrar_.Add(
1532 prefs::kArcEnabled, 1532 prefs::kArcEnabled,
1533 base::Bind( 1533 base::Bind(
1534 &ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref, 1534 &ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref,
1535 base::Unretained(this))); 1535 weak_ptr_factory_.GetWeakPtr()));
1536 pref_change_registrar_.Add( 1536 pref_change_registrar_.Add(
1537 prefs::kShelfAlignmentLocal, 1537 prefs::kShelfAlignmentLocal,
1538 base::Bind(&ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs, 1538 base::Bind(&ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs,
1539 base::Unretained(this))); 1539 weak_ptr_factory_.GetWeakPtr()));
1540 pref_change_registrar_.Add( 1540 pref_change_registrar_.Add(
1541 prefs::kShelfAutoHideBehaviorLocal, 1541 prefs::kShelfAutoHideBehaviorLocal,
1542 base::Bind( 1542 base::Bind(
1543 &ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs, 1543 &ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs,
1544 base::Unretained(this))); 1544 weak_ptr_factory_.GetWeakPtr()));
1545 pref_change_registrar_.Add( 1545 pref_change_registrar_.Add(
1546 prefs::kShelfPreferences, 1546 prefs::kShelfPreferences,
1547 base::Bind(&ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs, 1547 base::Bind(&ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs,
1548 base::Unretained(this))); 1548 weak_ptr_factory_.GetWeakPtr()));
1549 pref_change_registrar_.Add( 1549 pref_change_registrar_.Add(
1550 prefs::kTouchVirtualKeyboardEnabled, 1550 prefs::kTouchVirtualKeyboardEnabled,
1551 base::Bind( 1551 base::Bind(
1552 &ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs, 1552 &ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs,
1553 base::Unretained(this))); 1553 weak_ptr_factory_.GetWeakPtr()));
1554 1554
1555 std::unique_ptr<LauncherAppUpdater> extension_app_updater( 1555 std::unique_ptr<LauncherAppUpdater> extension_app_updater(
1556 new LauncherExtensionAppUpdater(this, profile_)); 1556 new LauncherExtensionAppUpdater(this, profile_));
1557 app_updaters_.push_back(std::move(extension_app_updater)); 1557 app_updaters_.push_back(std::move(extension_app_updater));
1558 1558
1559 if (arc::ArcAuthService::IsAllowedForProfile(profile_)) { 1559 if (arc::ArcAuthService::IsAllowedForProfile(profile_)) {
1560 std::unique_ptr<LauncherAppUpdater> arc_app_updater( 1560 std::unique_ptr<LauncherAppUpdater> arc_app_updater(
1561 new LauncherArcAppUpdater(this, profile_)); 1561 new LauncherArcAppUpdater(this, profile_));
1562 app_updaters_.push_back(std::move(arc_app_updater)); 1562 app_updaters_.push_back(std::move(arc_app_updater));
1563 } 1563 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 if (index == -1) 1680 if (index == -1)
1681 continue; 1681 continue;
1682 ash::ShelfItem item = model_->items()[index]; 1682 ash::ShelfItem item = model_->items()[index];
1683 item.image = image; 1683 item.image = image;
1684 if (arc_deferred_launcher_) 1684 if (arc_deferred_launcher_)
1685 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1685 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1686 model_->Set(index, item); 1686 model_->Set(index, item);
1687 // It's possible we're waiting on more than one item, so don't break. 1687 // It's possible we're waiting on more than one item, so don't break.
1688 } 1688 }
1689 } 1689 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698