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

Side by Side Diff: chrome/browser/web_applications/web_app.cc

Issue 14993013: Windows: When an app is updated and its name changes, recreate shortcuts. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Respond to reviewer feedback. Created 7 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_applications/web_app.h" 5 #include "chrome/browser/web_applications/web_app.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/i18n/file_util_icu.h" 10 #include "base/i18n/file_util_icu.h"
(...skipping 25 matching lines...) Expand all
36 const ShellIntegration::ShortcutInfo& shortcut_info) { 36 const ShellIntegration::ShortcutInfo& shortcut_info) {
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
38 38
39 base::FilePath shortcut_data_dir = web_app::GetWebAppDataDirectory( 39 base::FilePath shortcut_data_dir = web_app::GetWebAppDataDirectory(
40 shortcut_info.profile_path, shortcut_info.extension_id, GURL()); 40 shortcut_info.profile_path, shortcut_info.extension_id, GURL());
41 return web_app::internals::DeletePlatformShortcuts( 41 return web_app::internals::DeletePlatformShortcuts(
42 shortcut_data_dir, shortcut_info); 42 shortcut_data_dir, shortcut_info);
43 } 43 }
44 44
45 void UpdateShortcutsOnFileThread( 45 void UpdateShortcutsOnFileThread(
46 const string16& old_app_title,
46 const ShellIntegration::ShortcutInfo& shortcut_info) { 47 const ShellIntegration::ShortcutInfo& shortcut_info) {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
48 49
49 base::FilePath shortcut_data_dir = web_app::GetWebAppDataDirectory( 50 base::FilePath shortcut_data_dir = web_app::GetWebAppDataDirectory(
50 shortcut_info.profile_path, shortcut_info.extension_id, GURL()); 51 shortcut_info.profile_path, shortcut_info.extension_id, GURL());
51 return web_app::internals::UpdatePlatformShortcuts( 52 return web_app::internals::UpdatePlatformShortcuts(
52 shortcut_data_dir, shortcut_info); 53 shortcut_data_dir, old_app_title, shortcut_info);
53 } 54 }
54 55
55 } // namespace 56 } // namespace
56 57
57 namespace web_app { 58 namespace web_app {
58 59
59 // The following string is used to build the directory name for 60 // The following string is used to build the directory name for
60 // shortcuts to chrome applications (the kind which are installed 61 // shortcuts to chrome applications (the kind which are installed
61 // from a CRX). Application shortcuts to URLs use the {host}_{path} 62 // from a CRX). Application shortcuts to URLs use the {host}_{path}
62 // for the name of this directory. Hosts can't include an underscore. 63 // for the name of this directory. Hosts can't include an underscore.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 158
158 void DeleteAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info) { 159 void DeleteAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info) {
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
160 161
161 BrowserThread::PostTask( 162 BrowserThread::PostTask(
162 BrowserThread::FILE, 163 BrowserThread::FILE,
163 FROM_HERE, 164 FROM_HERE,
164 base::Bind(&DeleteShortcutsOnFileThread, shortcut_info)); 165 base::Bind(&DeleteShortcutsOnFileThread, shortcut_info));
165 } 166 }
166 167
167 void UpdateAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info) { 168 void UpdateAllShortcuts(const string16& old_app_title,
169 const ShellIntegration::ShortcutInfo& shortcut_info) {
168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
169 171
170 BrowserThread::PostTask( 172 BrowserThread::PostTask(
171 BrowserThread::FILE, 173 BrowserThread::FILE,
172 FROM_HERE, 174 FROM_HERE,
173 base::Bind(&UpdateShortcutsOnFileThread, shortcut_info)); 175 base::Bind(&UpdateShortcutsOnFileThread, old_app_title, shortcut_info));
174 } 176 }
175 177
176 bool CreateShortcutsOnFileThread( 178 bool CreateShortcutsOnFileThread(
177 const ShellIntegration::ShortcutInfo& shortcut_info, 179 const ShellIntegration::ShortcutInfo& shortcut_info,
178 const ShellIntegration::ShortcutLocations& creation_locations) { 180 const ShellIntegration::ShortcutLocations& creation_locations) {
179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
180 182
181 base::FilePath shortcut_data_dir = GetWebAppDataDirectory( 183 base::FilePath shortcut_data_dir = GetWebAppDataDirectory(
182 shortcut_info.profile_path, shortcut_info.extension_id, 184 shortcut_info.profile_path, shortcut_info.extension_id,
183 shortcut_info.url); 185 shortcut_info.url);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 #endif 231 #endif
230 232
231 string16 GetAppShortcutsSubdirName() { 233 string16 GetAppShortcutsSubdirName() {
232 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 234 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
233 if (channel == chrome::VersionInfo::CHANNEL_CANARY) 235 if (channel == chrome::VersionInfo::CHANNEL_CANARY)
234 return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME_CANARY); 236 return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME_CANARY);
235 return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME); 237 return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME);
236 } 238 }
237 239
238 } // namespace web_app 240 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app.h ('k') | chrome/browser/web_applications/web_app_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698