OLD | NEW |
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/extensions/app_shortcut_manager.h" | 5 #include "chrome/browser/extensions/app_shortcut_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/web_applications/web_app.h" | 10 #include "chrome/browser/web_applications/web_app.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_APP_DEFAULT_ICON); | 50 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_APP_DEFAULT_ICON); |
51 int size = kDesiredSizes[arraysize(kDesiredSizes) - 1]; | 51 int size = kDesiredSizes[arraysize(kDesiredSizes) - 1]; |
52 SkBitmap bmp = skia::ImageOperations::Resize( | 52 SkBitmap bmp = skia::ImageOperations::Resize( |
53 *default_icon.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST, | 53 *default_icon.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST, |
54 size, size); | 54 size, size); |
55 shortcut_info_.favicon = gfx::Image(bmp); | 55 shortcut_info_.favicon = gfx::Image(bmp); |
56 } else { | 56 } else { |
57 shortcut_info_.favicon = image; | 57 shortcut_info_.favicon = image; |
58 } | 58 } |
59 | 59 |
60 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_); | 60 web_app::CreateShortcuts(shortcut_info_); |
61 } | 61 } |
62 | 62 |
63 void AppShortcutManager::Observe(int type, | 63 void AppShortcutManager::Observe(int type, |
64 const content::NotificationSource& source, | 64 const content::NotificationSource& source, |
65 const content::NotificationDetails& details) { | 65 const content::NotificationDetails& details) { |
66 #if !defined(OS_MACOSX) | 66 #if !defined(OS_MACOSX) |
67 switch (type) { | 67 switch (type) { |
68 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 68 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { |
69 const Extension* extension = content::Details<const Extension>( | 69 const Extension* extension = content::Details<const Extension>( |
70 details).ptr(); | 70 details).ptr(); |
71 if (!disable_shortcut_creation_for_tests && | 71 if (!disable_shortcut_creation_for_tests && |
72 extension->is_platform_app() && | 72 extension->is_platform_app() && |
73 extension->location() != Extension::LOAD) { | 73 extension->location() != Extension::LOAD) { |
74 InstallApplicationShortcuts(extension); | 74 InstallApplicationShortcuts(extension); |
75 } | 75 } |
76 break; | 76 break; |
77 } | 77 } |
78 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { | 78 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { |
79 std::string extension_id = | 79 const Extension* extension = content::Details<const Extension>( |
80 content::Details<const Extension>(details).ptr()->id(); | 80 details).ptr(); |
81 if (!disable_shortcut_creation_for_tests) | 81 if (!disable_shortcut_creation_for_tests) |
82 web_app::DeleteAllShortcuts(profile_->GetPath(), extension_id); | 82 DeleteApplicationShortcuts(extension); |
83 break; | 83 break; |
84 } | 84 } |
85 default: | 85 default: |
86 NOTREACHED(); | 86 NOTREACHED(); |
87 } | 87 } |
88 #endif | 88 #endif |
89 } | 89 } |
90 | 90 |
91 // static | 91 // static |
92 void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) { | 92 void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 132 } |
133 info_list.push_back( | 133 info_list.push_back( |
134 ImageLoadingTracker::ImageInfo(resource, gfx::Size(size, size))); | 134 ImageLoadingTracker::ImageInfo(resource, gfx::Size(size, size))); |
135 } | 135 } |
136 | 136 |
137 // |icon_resources| may still be empty at this point, in which case LoadImage | 137 // |icon_resources| may still be empty at this point, in which case LoadImage |
138 // will call the OnImageLoaded callback with an empty image and exit | 138 // will call the OnImageLoaded callback with an empty image and exit |
139 // immediately. | 139 // immediately. |
140 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); | 140 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); |
141 } | 141 } |
| 142 |
| 143 void AppShortcutManager::DeleteApplicationShortcuts( |
| 144 const Extension* extension) { |
| 145 ShellIntegration::ShortcutInfo delete_info; |
| 146 delete_info.extension_id = extension->id(); |
| 147 delete_info.url = GURL(extension->launch_web_url()); |
| 148 delete_info.title = UTF8ToUTF16(extension->name()); |
| 149 delete_info.description = UTF8ToUTF16(extension->description()); |
| 150 delete_info.extension_path = extension->path(); |
| 151 delete_info.is_platform_app = extension->is_platform_app(); |
| 152 delete_info.create_in_applications_menu = true; |
| 153 delete_info.create_in_quick_launch_bar = true; |
| 154 delete_info.create_on_desktop = true; |
| 155 delete_info.profile_path = profile_->GetPath(); |
| 156 web_app::DeleteAllShortcuts(delete_info); |
| 157 } |
OLD | NEW |