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

Side by Side Diff: apps/shortcut_manager.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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.cc » ('j') | 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 "apps/shortcut_manager.h" 5 #include "apps/shortcut_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/string16.h"
10 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/shell_integration.h" 11 #include "chrome/browser/shell_integration.h"
10 #include "chrome/browser/ui/web_applications/web_app_ui.h" 12 #include "chrome/browser/ui/web_applications/web_app_ui.h"
11 #include "chrome/browser/web_applications/web_app.h" 13 #include "chrome/browser/web_applications/web_app.h"
12 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
13 #include "content/public/browser/notification_details.h" 15 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
15 17
16 using extensions::Extension; 18 using extensions::Extension;
17 19
18 namespace { 20 namespace {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 .ptr(); 56 .ptr();
55 const Extension* extension = installed_info->extension; 57 const Extension* extension = installed_info->extension;
56 if (extension->is_platform_app() && 58 if (extension->is_platform_app() &&
57 extension->location() != extensions::Manifest::COMPONENT) { 59 extension->location() != extensions::Manifest::COMPONENT) {
58 // If the app is being updated, update any existing shortcuts but do not 60 // If the app is being updated, update any existing shortcuts but do not
59 // create new ones. If it is being installed, automatically create a 61 // create new ones. If it is being installed, automatically create a
60 // shortcut in the applications menu (e.g., Start Menu). 62 // shortcut in the applications menu (e.g., Start Menu).
61 base::Callback<void(const ShellIntegration::ShortcutInfo&)> 63 base::Callback<void(const ShellIntegration::ShortcutInfo&)>
62 create_or_update; 64 create_or_update;
63 if (installed_info->is_update) { 65 if (installed_info->is_update) {
64 create_or_update = base::Bind(&web_app::UpdateAllShortcuts); 66 string16 old_title = UTF8ToUTF16(installed_info->old_name);
67 create_or_update = base::Bind(&web_app::UpdateAllShortcuts,
68 old_title);
65 } else { 69 } else {
66 create_or_update = base::Bind(&CreateShortcutsInApplicationsMenu); 70 create_or_update = base::Bind(&CreateShortcutsInApplicationsMenu);
67 } 71 }
68 72
69 web_app::UpdateShortcutInfoAndIconForApp(*extension, profile_, 73 web_app::UpdateShortcutInfoAndIconForApp(*extension, profile_,
70 create_or_update); 74 create_or_update);
71 } 75 }
72 #endif // !defined(OS_MACOSX) 76 #endif // !defined(OS_MACOSX)
73 break; 77 break;
74 } 78 }
75 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { 79 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
76 const Extension* extension = content::Details<const Extension>( 80 const Extension* extension = content::Details<const Extension>(
77 details).ptr(); 81 details).ptr();
78 DeleteApplicationShortcuts(extension); 82 DeleteApplicationShortcuts(extension);
79 break; 83 break;
80 } 84 }
81 default: 85 default:
82 NOTREACHED(); 86 NOTREACHED();
83 } 87 }
84 } 88 }
85 89
86 void ShortcutManager::DeleteApplicationShortcuts( 90 void ShortcutManager::DeleteApplicationShortcuts(
87 const Extension* extension) { 91 const Extension* extension) {
88 ShellIntegration::ShortcutInfo delete_info = 92 ShellIntegration::ShortcutInfo delete_info =
89 web_app::ShortcutInfoForExtensionAndProfile(extension, profile_); 93 web_app::ShortcutInfoForExtensionAndProfile(extension, profile_);
90 web_app::DeleteAllShortcuts(delete_info); 94 web_app::DeleteAllShortcuts(delete_info);
91 } 95 }
92 96
93 } // namespace apps 97 } // namespace apps
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698