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

Unified Diff: chrome/browser/extensions/app_shortcut_manager.cc

Issue 10837034: Remove packaged app Windows shortcuts when app is uninstalled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android compile Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/app_shortcut_manager.cc
diff --git a/chrome/browser/extensions/app_shortcut_manager.cc b/chrome/browser/extensions/app_shortcut_manager.cc
index cdf2ce2e8d54476110471b9401ff15f80737ee87..6d8fc81656d41ba09b50568b643fabf5760c487d 100644
--- a/chrome/browser/extensions/app_shortcut_manager.cc
+++ b/chrome/browser/extensions/app_shortcut_manager.cc
@@ -29,6 +29,23 @@ const int kDesiredSizes[] = {16, 32, 128, 256, 512};
#else
const int kDesiredSizes[] = {32};
#endif
+
+ShellIntegration::ShortcutInfo ShortcutInfoForExtensionAndProfile(
+ const Extension* extension, Profile* profile) {
+ ShellIntegration::ShortcutInfo shortcut_info;
+ shortcut_info.extension_id = extension->id();
+ shortcut_info.url = GURL(extension->launch_web_url());
+ shortcut_info.title = UTF8ToUTF16(extension->name());
+ shortcut_info.description = UTF8ToUTF16(extension->description());
+ shortcut_info.extension_path = extension->path();
+ shortcut_info.is_platform_app = extension->is_platform_app();
+ shortcut_info.create_in_applications_menu = true;
+ shortcut_info.create_in_quick_launch_bar = true;
+ shortcut_info.create_on_desktop = true;
+ shortcut_info.profile_path = profile->GetPath();
+ return shortcut_info;
+}
+
} // namespace
AppShortcutManager::AppShortcutManager(Profile* profile)
@@ -57,7 +74,7 @@ void AppShortcutManager::OnImageLoaded(const gfx::Image& image,
shortcut_info_.favicon = image;
}
- web_app::CreateShortcut(profile_->GetPath(), shortcut_info_);
+ web_app::CreateShortcuts(shortcut_info_);
}
void AppShortcutManager::Observe(int type,
@@ -76,10 +93,10 @@ void AppShortcutManager::Observe(int type,
break;
}
case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
- std::string extension_id =
- content::Details<const Extension>(details).ptr()->id();
+ const Extension* extension = content::Details<const Extension>(
+ details).ptr();
if (!disable_shortcut_creation_for_tests)
- web_app::DeleteAllShortcuts(profile_->GetPath(), extension_id);
+ DeleteApplicationShortcuts(extension);
break;
}
default:
@@ -95,17 +112,7 @@ void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) {
void AppShortcutManager::InstallApplicationShortcuts(
const Extension* extension) {
- shortcut_info_.extension_id = extension->id();
- shortcut_info_.url = GURL(extension->launch_web_url());
- shortcut_info_.title = UTF8ToUTF16(extension->name());
- shortcut_info_.description = UTF8ToUTF16(extension->description());
- shortcut_info_.extension_path = extension->path();
- shortcut_info_.is_platform_app = extension->is_platform_app();
- shortcut_info_.create_in_applications_menu = true;
- shortcut_info_.create_in_quick_launch_bar = true;
- shortcut_info_.create_on_desktop = true;
- shortcut_info_.profile_path = profile_->GetPath();
-
+ shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_);
std::vector<ImageLoadingTracker::ImageInfo> info_list;
for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) {
int size = kDesiredSizes[i];
@@ -139,3 +146,10 @@ void AppShortcutManager::InstallApplicationShortcuts(
// immediately.
tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE);
}
+
+void AppShortcutManager::DeleteApplicationShortcuts(
+ const Extension* extension) {
+ ShellIntegration::ShortcutInfo delete_info =
+ ShortcutInfoForExtensionAndProfile(extension, profile_);
+ web_app::DeleteAllShortcuts(delete_info);
+}
« no previous file with comments | « chrome/browser/extensions/app_shortcut_manager.h ('k') | chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698