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

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

Issue 14533004: Start menu shortcuts for apps on Windows are now inside a "Chrome Apps" submenu. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « chrome/browser/ui/views/create_application_shortcut_view.cc ('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 (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 <shlobj.h> 7 #include <shlobj.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/md5.h" 12 #include "base/md5.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/win/shortcut.h" 16 #include "base/win/shortcut.h"
17 #include "base/win/windows_version.h" 17 #include "base/win/windows_version.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/installer/launcher_support/chrome_launcher_support.h" 19 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
20 #include "chrome/installer/util/util_constants.h" 20 #include "chrome/installer/util/util_constants.h"
21 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "grit/chromium_strings.h"
23 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/gfx/icon_util.h" 24 #include "ui/gfx/icon_util.h"
23 #include "ui/gfx/image/image.h" 25 #include "ui/gfx/image/image.h"
24 #include "ui/gfx/image/image_family.h" 26 #include "ui/gfx/image/image_family.h"
25 27
26 namespace { 28 namespace {
27 29
28 const base::FilePath::CharType kIconChecksumFileExt[] = 30 const base::FilePath::CharType kIconChecksumFileExt[] =
29 FILE_PATH_LITERAL(".ico.md5"); 31 FILE_PATH_LITERAL(".ico.md5");
30 32
31 // Width and height of icons exported to .ico files. 33 // Width and height of icons exported to .ico files.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 235 }
234 } 236 }
235 base::win::ShortcutProperties shortcut_properties; 237 base::win::ShortcutProperties shortcut_properties;
236 shortcut_properties.set_target(chrome_exe); 238 shortcut_properties.set_target(chrome_exe);
237 shortcut_properties.set_working_dir(working_dir); 239 shortcut_properties.set_working_dir(working_dir);
238 shortcut_properties.set_arguments(wide_switches); 240 shortcut_properties.set_arguments(wide_switches);
239 shortcut_properties.set_description(description); 241 shortcut_properties.set_description(description);
240 shortcut_properties.set_icon(icon_file, 0); 242 shortcut_properties.set_icon(icon_file, 0);
241 shortcut_properties.set_app_id(app_id); 243 shortcut_properties.set_app_id(app_id);
242 shortcut_properties.set_dual_mode(false); 244 shortcut_properties.set_dual_mode(false);
245 if (!file_util::PathExists(shortcut_file.DirName()) &&
246 !file_util::CreateDirectory(shortcut_file.DirName())) {
247 NOTREACHED();
248 return false;
249 }
243 success = base::win::CreateOrUpdateShortcutLink( 250 success = base::win::CreateOrUpdateShortcutLink(
244 shortcut_file, shortcut_properties, 251 shortcut_file, shortcut_properties,
245 base::win::SHORTCUT_CREATE_ALWAYS) && success; 252 base::win::SHORTCUT_CREATE_ALWAYS) && success;
246 } 253 }
247 254
248 if (success && pin_to_taskbar) { 255 if (success && pin_to_taskbar) {
249 // Use the web app path shortcut for pinning to avoid having unique numbers 256 // Use the web app path shortcut for pinning to avoid having unique numbers
250 // in the application name. 257 // in the application name.
251 base::FilePath shortcut_to_pin = web_app_path.Append(file_name). 258 base::FilePath shortcut_to_pin = web_app_path.Append(file_name).
252 AddExtension(installer::kLnkExt); 259 AddExtension(installer::kLnkExt);
(...skipping 23 matching lines...) Expand all
276 void DeletePlatformShortcuts( 283 void DeletePlatformShortcuts(
277 const base::FilePath& web_app_path, 284 const base::FilePath& web_app_path,
278 const ShellIntegration::ShortcutInfo& shortcut_info) { 285 const ShellIntegration::ShortcutInfo& shortcut_info) {
279 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 286 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
280 287
281 // Get all possible locations for shortcuts. 288 // Get all possible locations for shortcuts.
282 ShellIntegration::ShortcutLocations all_shortcut_locations; 289 ShellIntegration::ShortcutLocations all_shortcut_locations;
283 all_shortcut_locations.in_applications_menu = true; 290 all_shortcut_locations.in_applications_menu = true;
284 all_shortcut_locations.in_quick_launch_bar = true; 291 all_shortcut_locations.in_quick_launch_bar = true;
285 all_shortcut_locations.on_desktop = true; 292 all_shortcut_locations.on_desktop = true;
293 // Delete shortcuts from the Chrome Apps subdirectory.
294 // This matches the subdir name set by CreateApplicationShortcutView::Accept.
295 all_shortcut_locations.applications_menu_subdir =
296 l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME);
286 std::vector<base::FilePath> shortcut_paths = GetShortcutPaths( 297 std::vector<base::FilePath> shortcut_paths = GetShortcutPaths(
287 all_shortcut_locations); 298 all_shortcut_locations);
288 if (base::win::GetVersion() >= base::win::VERSION_WIN7) 299 if (base::win::GetVersion() >= base::win::VERSION_WIN7)
289 shortcut_paths.push_back(web_app_path); 300 shortcut_paths.push_back(web_app_path);
290 301
291 for (std::vector<base::FilePath>::const_iterator i = shortcut_paths.begin(); 302 for (std::vector<base::FilePath>::const_iterator i = shortcut_paths.begin();
292 i != shortcut_paths.end(); ++i) { 303 i != shortcut_paths.end(); ++i) {
293 std::vector<base::FilePath> shortcut_files = 304 std::vector<base::FilePath> shortcut_files =
294 MatchingShortcutsForProfileAndExtension(*i, shortcut_info.profile_path, 305 MatchingShortcutsForProfileAndExtension(*i, shortcut_info.profile_path,
295 shortcut_info.title); 306 shortcut_info.title);
296 for (std::vector<base::FilePath>::const_iterator j = shortcut_files.begin(); 307 for (std::vector<base::FilePath>::const_iterator j = shortcut_files.begin();
297 j != shortcut_files.end(); ++j) { 308 j != shortcut_files.end(); ++j) {
298 // Any shortcut could have been pinned, either by chrome or the user, so 309 // Any shortcut could have been pinned, either by chrome or the user, so
299 // they are all unpinned. 310 // they are all unpinned.
300 base::win::TaskbarUnpinShortcutLink(j->value().c_str()); 311 base::win::TaskbarUnpinShortcutLink(j->value().c_str());
301 file_util::Delete(*j, false); 312 file_util::Delete(*j, false);
gab 2013/04/29 21:43:57 This will not delete the "Chrome Apps" folder its
Matt Giuca 2013/04/30 00:53:43 Noted. It should delete the folder if it becomes e
Matt Giuca 2013/04/30 02:58:03 Actually, I just did it here (not too big after al
302 } 313 }
303 } 314 }
304 } 315 }
305 316
306 std::vector<base::FilePath> GetShortcutPaths( 317 std::vector<base::FilePath> GetShortcutPaths(
307 const ShellIntegration::ShortcutLocations& creation_locations) { 318 const ShellIntegration::ShortcutLocations& creation_locations) {
308 // Shortcut paths under which to create shortcuts. 319 // Shortcut paths under which to create shortcuts.
309 std::vector<base::FilePath> shortcut_paths; 320 std::vector<base::FilePath> shortcut_paths;
310 // Locations to add to shortcut_paths. 321 // Locations to add to shortcut_paths.
311 struct { 322 struct {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 path = path.Append(locations[i].subdir); 360 path = path.Append(locations[i].subdir);
350 shortcut_paths.push_back(path); 361 shortcut_paths.push_back(path);
351 } 362 }
352 } 363 }
353 return shortcut_paths; 364 return shortcut_paths;
354 } 365 }
355 366
356 } // namespace internals 367 } // namespace internals
357 368
358 } // namespace web_app 369 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/create_application_shortcut_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698