OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/launcher_arc_app_updater.h" | 5 #include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h" |
6 | 6 |
| 7 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 8 |
7 LauncherArcAppUpdater::LauncherArcAppUpdater( | 9 LauncherArcAppUpdater::LauncherArcAppUpdater( |
8 Delegate* delegate, | 10 Delegate* delegate, |
9 content::BrowserContext* browser_context) | 11 content::BrowserContext* browser_context) |
10 : LauncherAppUpdater(delegate, browser_context) { | 12 : LauncherAppUpdater(delegate, browser_context) { |
11 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser_context); | 13 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser_context); |
12 DCHECK(prefs); | 14 DCHECK(prefs); |
13 prefs->AddObserver(this); | 15 prefs->AddObserver(this); |
14 } | 16 } |
15 | 17 |
16 LauncherArcAppUpdater::~LauncherArcAppUpdater() { | 18 LauncherArcAppUpdater::~LauncherArcAppUpdater() { |
17 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser_context()); | 19 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser_context()); |
18 DCHECK(prefs); | 20 DCHECK(prefs); |
19 prefs->RemoveObserver(this); | 21 prefs->RemoveObserver(this); |
20 } | 22 } |
21 | 23 |
22 void LauncherArcAppUpdater::OnAppRegistered( | 24 void LauncherArcAppUpdater::OnAppRegistered( |
23 const std::string& app_id, | 25 const std::string& app_id, |
24 const ArcAppListPrefs::AppInfo& app_info) { | 26 const ArcAppListPrefs::AppInfo& app_info) { |
25 delegate()->OnAppInstalled(browser_context(), app_id); | 27 delegate()->OnAppInstalled(browser_context(), app_id); |
26 } | 28 } |
27 | 29 |
28 void LauncherArcAppUpdater::OnAppRemoved(const std::string& app_id) { | 30 void LauncherArcAppUpdater::OnAppRemoved(const std::string& app_id) { |
| 31 // ChromeLauncherController generally removes items from the sync model when |
| 32 // they are removed from the shelf model, but that should not happen when ARC |
| 33 // apps are disabled due to ARC itself being disabled. The app entries should |
| 34 // remain in the sync model for other synced devices that do support ARC, and |
| 35 // to restore the respective shelf items if ARC is re-enabled on this device. |
| 36 ChromeLauncherController::ScopedPinSyncDisabler scoped_pin_sync_disabler = |
| 37 ChromeLauncherController::instance()->GetScopedPinSyncDisabler(); |
29 delegate()->OnAppUninstalledPrepared(browser_context(), app_id); | 38 delegate()->OnAppUninstalledPrepared(browser_context(), app_id); |
30 delegate()->OnAppUninstalled(browser_context(), app_id); | 39 delegate()->OnAppUninstalled(browser_context(), app_id); |
31 } | 40 } |
OLD | NEW |