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

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

Issue 2456803002: Remove OnOptInChanged callback. (Closed)
Patch Set: Address comments. Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_extension_app_updater.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "extensions/browser/extension_registry.h" 11 #include "extensions/browser/extension_registry.h"
12 12
13 LauncherExtensionAppUpdater::LauncherExtensionAppUpdater( 13 LauncherExtensionAppUpdater::LauncherExtensionAppUpdater(
14 Delegate* delegate, 14 Delegate* delegate,
15 content::BrowserContext* browser_context) 15 content::BrowserContext* browser_context)
16 : LauncherAppUpdater(delegate, browser_context) { 16 : LauncherAppUpdater(delegate, browser_context) {
17 StartObservingExtensionRegistry(); 17 StartObservingExtensionRegistry();
18 18
19 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
20 // ArcAuthService may not be available for some unit tests.
21 if (arc_auth_service)
22 arc_auth_service->AddObserver(this);
23
24 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser_context); 19 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser_context);
25 if (prefs) 20 if (prefs)
26 prefs->AddObserver(this); 21 prefs->AddObserver(this);
27 } 22 }
28 23
29 LauncherExtensionAppUpdater::~LauncherExtensionAppUpdater() { 24 LauncherExtensionAppUpdater::~LauncherExtensionAppUpdater() {
30 StopObservingExtensionRegistry(); 25 StopObservingExtensionRegistry();
31 26
32 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
33 if (arc_auth_service)
34 arc_auth_service->RemoveObserver(this);
35
36 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser_context()); 27 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser_context());
37 if (prefs) 28 if (prefs)
38 prefs->RemoveObserver(this); 29 prefs->RemoveObserver(this);
39 } 30 }
40 31
41 void LauncherExtensionAppUpdater::OnExtensionLoaded( 32 void LauncherExtensionAppUpdater::OnExtensionLoaded(
42 content::BrowserContext* browser_context, 33 content::BrowserContext* browser_context,
43 const extensions::Extension* extension) { 34 const extensions::Extension* extension) {
44 delegate()->OnAppInstalled(browser_context, extension->id()); 35 delegate()->OnAppInstalled(browser_context, extension->id());
45 } 36 }
(...skipping 14 matching lines...) Expand all
60 extensions::UninstallReason reason) { 51 extensions::UninstallReason reason) {
61 delegate()->OnAppUninstalled(browser_context, extension->id()); 52 delegate()->OnAppUninstalled(browser_context, extension->id());
62 } 53 }
63 54
64 void LauncherExtensionAppUpdater::OnShutdown( 55 void LauncherExtensionAppUpdater::OnShutdown(
65 extensions::ExtensionRegistry* registry) { 56 extensions::ExtensionRegistry* registry) {
66 DCHECK_EQ(extension_registry_, registry); 57 DCHECK_EQ(extension_registry_, registry);
67 StopObservingExtensionRegistry(); 58 StopObservingExtensionRegistry();
68 } 59 }
69 60
70 void LauncherExtensionAppUpdater::OnOptInChanged(
71 arc::ArcAuthService::State state) {
72 if (!chromeos::ProfileHelper::IsPrimaryProfile(
73 Profile::FromBrowserContext(browser_context()))) {
74 return;
75 }
76 UpdateHostedApps();
77 }
78
79 void LauncherExtensionAppUpdater::OnPackageInstalled( 61 void LauncherExtensionAppUpdater::OnPackageInstalled(
80 const arc::mojom::ArcPackageInfo& package_info) { 62 const arc::mojom::ArcPackageInfo& package_info) {
81 UpdateEquivalentHostedApp(package_info.package_name); 63 UpdateEquivalentHostedApp(package_info.package_name);
82 } 64 }
83 65
84 void LauncherExtensionAppUpdater::OnPackageRemoved( 66 void LauncherExtensionAppUpdater::OnPackageRemoved(
85 const std::string& package_name) { 67 const std::string& package_name) {
86 UpdateEquivalentHostedApp(package_name); 68 UpdateEquivalentHostedApp(package_name);
87 } 69 }
88 70
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 105 }
124 106
125 void LauncherExtensionAppUpdater::UpdateEquivalentHostedApp( 107 void LauncherExtensionAppUpdater::UpdateEquivalentHostedApp(
126 const std::string& arc_package_name) { 108 const std::string& arc_package_name) {
127 const std::vector<std::string> extension_ids = 109 const std::vector<std::string> extension_ids =
128 extensions::util::GetEquivalentInstalledExtensions(browser_context(), 110 extensions::util::GetEquivalentInstalledExtensions(browser_context(),
129 arc_package_name); 111 arc_package_name);
130 for (const auto& iter : extension_ids) 112 for (const auto& iter : extension_ids)
131 UpdateHostedApp(iter); 113 UpdateHostedApp(iter);
132 } 114 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_extension_app_updater.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698