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/apps/shortcut_manager.h" | 5 #include "chrome/browser/apps/shortcut_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if (is_update && !from_ephemeral) { | 131 if (is_update && !from_ephemeral) { |
132 web_app::UpdateAllShortcuts( | 132 web_app::UpdateAllShortcuts( |
133 base::UTF8ToUTF16(old_name), profile_, extension); | 133 base::UTF8ToUTF16(old_name), profile_, extension); |
134 } else { | 134 } else { |
135 CreateShortcutsForApp(profile_, extension); | 135 CreateShortcutsForApp(profile_, extension); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 void AppShortcutManager::OnExtensionUninstalled( | 139 void AppShortcutManager::OnExtensionUninstalled( |
140 content::BrowserContext* browser_context, | 140 content::BrowserContext* browser_context, |
141 const Extension* extension) { | 141 const Extension* extension, |
| 142 extensions::UninstallReason reason) { |
142 web_app::DeleteAllShortcuts(profile_, extension); | 143 web_app::DeleteAllShortcuts(profile_, extension); |
143 } | 144 } |
144 | 145 |
145 void AppShortcutManager::OnProfileWillBeRemoved( | 146 void AppShortcutManager::OnProfileWillBeRemoved( |
146 const base::FilePath& profile_path) { | 147 const base::FilePath& profile_path) { |
147 if (profile_path != profile_->GetPath()) | 148 if (profile_path != profile_->GetPath()) |
148 return; | 149 return; |
149 content::BrowserThread::PostTask( | 150 content::BrowserThread::PostTask( |
150 content::BrowserThread::FILE, FROM_HERE, | 151 content::BrowserThread::FILE, FROM_HERE, |
151 base::Bind(&web_app::internals::DeleteAllShortcutsForProfile, | 152 base::Bind(&web_app::internals::DeleteAllShortcutsForProfile, |
152 profile_path)); | 153 profile_path)); |
153 } | 154 } |
154 | 155 |
155 void AppShortcutManager::UpdateShortcutsForAllAppsIfNeeded() { | 156 void AppShortcutManager::UpdateShortcutsForAllAppsIfNeeded() { |
156 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) | 157 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) |
157 return; | 158 return; |
158 | 159 |
159 int last_version = prefs_->GetInteger(prefs::kAppShortcutsVersion); | 160 int last_version = prefs_->GetInteger(prefs::kAppShortcutsVersion); |
160 if (last_version >= kCurrentAppShortcutsVersion) | 161 if (last_version >= kCurrentAppShortcutsVersion) |
161 return; | 162 return; |
162 | 163 |
163 content::BrowserThread::PostDelayedTask( | 164 content::BrowserThread::PostDelayedTask( |
164 content::BrowserThread::UI, | 165 content::BrowserThread::UI, |
165 FROM_HERE, | 166 FROM_HERE, |
166 base::Bind(&web_app::UpdateShortcutsForAllApps, | 167 base::Bind(&web_app::UpdateShortcutsForAllApps, |
167 profile_, | 168 profile_, |
168 base::Bind(&SetCurrentAppShortcutsVersion, prefs_)), | 169 base::Bind(&SetCurrentAppShortcutsVersion, prefs_)), |
169 base::TimeDelta::FromSeconds(kUpdateShortcutsForAllAppsDelay)); | 170 base::TimeDelta::FromSeconds(kUpdateShortcutsForAllAppsDelay)); |
170 } | 171 } |
OLD | NEW |