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_extension_app_updater.h" | 5 #include "chrome/browser/ui/ash/launcher/launcher_extension_app_updater.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/extensions/gfx_utils.h" | 7 #include "chrome/browser/chromeos/extensions/gfx_utils.h" |
8 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 8 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 extensions::UninstallReason reason) { | 51 extensions::UninstallReason reason) { |
52 delegate()->OnAppUninstalled(browser_context, extension->id()); | 52 delegate()->OnAppUninstalled(browser_context, extension->id()); |
53 } | 53 } |
54 | 54 |
55 void LauncherExtensionAppUpdater::OnShutdown( | 55 void LauncherExtensionAppUpdater::OnShutdown( |
56 extensions::ExtensionRegistry* registry) { | 56 extensions::ExtensionRegistry* registry) { |
57 DCHECK_EQ(extension_registry_, registry); | 57 DCHECK_EQ(extension_registry_, registry); |
58 StopObservingExtensionRegistry(); | 58 StopObservingExtensionRegistry(); |
59 } | 59 } |
60 | 60 |
61 void LauncherExtensionAppUpdater::OnPackageListInitialRefreshed() { | |
khmel
2017/04/20 00:13:38
This is reason why badge may not be applied also.
| |
62 const ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser_context()); | |
63 const std::vector<std::string> package_names = prefs->GetPackagesFromPrefs(); | |
64 for (auto& package_name : package_names) | |
65 UpdateEquivalentApp(package_name); | |
66 } | |
67 | |
61 void LauncherExtensionAppUpdater::OnPackageInstalled( | 68 void LauncherExtensionAppUpdater::OnPackageInstalled( |
62 const arc::mojom::ArcPackageInfo& package_info) { | 69 const arc::mojom::ArcPackageInfo& package_info) { |
63 UpdateEquivalentHostedApp(package_info.package_name); | 70 UpdateEquivalentApp(package_info.package_name); |
64 } | 71 } |
65 | 72 |
66 void LauncherExtensionAppUpdater::OnPackageRemoved( | 73 void LauncherExtensionAppUpdater::OnPackageRemoved( |
67 const std::string& package_name) { | 74 const std::string& package_name, |
68 UpdateEquivalentHostedApp(package_name); | 75 bool uninstalled) { |
76 UpdateEquivalentApp(package_name); | |
69 } | 77 } |
70 | 78 |
71 void LauncherExtensionAppUpdater::StartObservingExtensionRegistry() { | 79 void LauncherExtensionAppUpdater::StartObservingExtensionRegistry() { |
72 DCHECK(!extension_registry_); | 80 DCHECK(!extension_registry_); |
73 extension_registry_ = extensions::ExtensionRegistry::Get(browser_context()); | 81 extension_registry_ = extensions::ExtensionRegistry::Get(browser_context()); |
74 extension_registry_->AddObserver(this); | 82 extension_registry_->AddObserver(this); |
75 } | 83 } |
76 | 84 |
77 void LauncherExtensionAppUpdater::StopObservingExtensionRegistry() { | 85 void LauncherExtensionAppUpdater::StopObservingExtensionRegistry() { |
78 if (!extension_registry_) | 86 if (!extension_registry_) |
79 return; | 87 return; |
80 extension_registry_->RemoveObserver(this); | 88 extension_registry_->RemoveObserver(this); |
81 extension_registry_ = nullptr; | 89 extension_registry_ = nullptr; |
82 } | 90 } |
83 | 91 |
84 void LauncherExtensionAppUpdater::UpdateHostedApps() { | 92 void LauncherExtensionAppUpdater::UpdateApp(const std::string& app_id) { |
khmel
2017/04/20 00:13:38
Well, this code was not used. I had temptation to
| |
85 if (!extension_registry_) | |
86 return; | |
87 | |
88 UpdateHostedApps(extension_registry_->enabled_extensions()); | |
89 UpdateHostedApps(extension_registry_->disabled_extensions()); | |
90 UpdateHostedApps(extension_registry_->terminated_extensions()); | |
91 } | |
92 | |
93 void LauncherExtensionAppUpdater::UpdateHostedApps( | |
94 const extensions::ExtensionSet& extensions) { | |
95 content::BrowserContext* context = browser_context(); | |
96 extensions::ExtensionSet::const_iterator it; | |
97 for (it = extensions.begin(); it != extensions.end(); ++it) { | |
98 if ((*it)->is_hosted_app()) | |
99 delegate()->OnAppUpdated(context, (*it)->id()); | |
100 } | |
101 } | |
102 | |
103 void LauncherExtensionAppUpdater::UpdateHostedApp(const std::string& app_id) { | |
104 delegate()->OnAppUpdated(browser_context(), app_id); | 93 delegate()->OnAppUpdated(browser_context(), app_id); |
105 } | 94 } |
106 | 95 |
107 void LauncherExtensionAppUpdater::UpdateEquivalentHostedApp( | 96 void LauncherExtensionAppUpdater::UpdateEquivalentApp( |
108 const std::string& arc_package_name) { | 97 const std::string& arc_package_name) { |
109 const std::vector<std::string> extension_ids = | 98 const std::vector<std::string> extension_ids = |
110 extensions::util::GetEquivalentInstalledExtensions(browser_context(), | 99 extensions::util::GetEquivalentInstalledExtensions(browser_context(), |
111 arc_package_name); | 100 arc_package_name); |
112 for (const auto& iter : extension_ids) | 101 for (const auto& iter : extension_ids) |
113 UpdateHostedApp(iter); | 102 UpdateApp(iter); |
114 } | 103 } |
OLD | NEW |