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

Side by Side Diff: chrome/browser/extensions/app_shortcut_manager.cc

Issue 11054006: Make application shortcuts point to app_host.exe, install App Host during app installation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Now installing App Host in AppShortcutManager, instead of CrxInstaller / UnpackedInstaller. Created 8 years, 1 month 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/extensions/app_shortcut_manager.h" 5 #include "chrome/browser/extensions/app_shortcut_manager.h"
6 6
7 #include "base/bind.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/app_host_installer.h"
9 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/web_applications/web_app.h" 12 #include "chrome/browser/web_applications/web_app.h"
11 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/extensions/extension_resource.h" 15 #include "chrome/common/extensions/extension_resource.h"
14 #include "content/public/browser/notification_details.h" 16 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
16 #include "grit/theme_resources.h" 18 #include "grit/theme_resources.h"
17 #include "skia/ext/image_operations.h" 19 #include "skia/ext/image_operations.h"
18 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 77
76 void AppShortcutManager::Observe(int type, 78 void AppShortcutManager::Observe(int type,
77 const content::NotificationSource& source, 79 const content::NotificationSource& source,
78 const content::NotificationDetails& details) { 80 const content::NotificationDetails& details) {
79 #if !defined(OS_MACOSX) 81 #if !defined(OS_MACOSX)
80 switch (type) { 82 switch (type) {
81 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { 83 case chrome::NOTIFICATION_EXTENSION_INSTALLED: {
82 const Extension* extension = content::Details<const Extension>( 84 const Extension* extension = content::Details<const Extension>(
83 details).ptr(); 85 details).ptr();
84 if (extension->is_platform_app()) 86 if (extension->is_platform_app())
85 UpdateApplicationShortcuts(extension); 87 UpdateApplicationShortcuts(extension);
erikwright (departed) 2012/11/02 01:07:26 Perhaps we can just put, here: #ifdef OS_WIN Ap
huangs 2012/11/02 18:39:01 Done.
86 break; 88 break;
87 } 89 }
88 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { 90 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
89 const Extension* extension = content::Details<const Extension>( 91 const Extension* extension = content::Details<const Extension>(
90 details).ptr(); 92 details).ptr();
91 DeleteApplicationShortcuts(extension); 93 DeleteApplicationShortcuts(extension);
92 break; 94 break;
93 } 95 }
94 default: 96 default:
95 NOTREACHED(); 97 NOTREACHED();
96 } 98 }
97 #endif 99 #endif
98 } 100 }
99 101
100 void AppShortcutManager::UpdateApplicationShortcuts( 102 void AppShortcutManager::UpdateApplicationShortcuts(
101 const Extension* extension) { 103 const Extension* extension) {
104 app_host_installer::InstallAppHostIfNecessary(
105 *extension, base::Bind(&AppShortcutManager::OnAppHostInstallationComplete,
106 base::Unretained(this), extension));
107 }
108
109 void AppShortcutManager::OnAppHostInstallationComplete(
110 const Extension* extension, bool app_host_install_success) {
111 if (!app_host_install_success) {
112 // Do not create shortcuts if App Host fails to install.
113 return;
114 }
115
102 shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_); 116 shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_);
103 117
104 std::vector<ImageLoadingTracker::ImageRepresentation> info_list; 118 std::vector<ImageLoadingTracker::ImageRepresentation> info_list;
105 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { 119 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) {
106 int size = kDesiredSizes[i]; 120 int size = kDesiredSizes[i];
107 ExtensionResource resource = extension->GetIconResource( 121 ExtensionResource resource = extension->GetIconResource(
108 size, ExtensionIconSet::MATCH_EXACTLY); 122 size, ExtensionIconSet::MATCH_EXACTLY);
109 if (!resource.empty()) { 123 if (!resource.empty()) {
110 info_list.push_back(ImageLoadingTracker::ImageRepresentation( 124 info_list.push_back(ImageLoadingTracker::ImageRepresentation(
111 resource, 125 resource,
(...skipping 30 matching lines...) Expand all
142 } 156 }
143 157
144 void AppShortcutManager::DeleteApplicationShortcuts( 158 void AppShortcutManager::DeleteApplicationShortcuts(
145 const Extension* extension) { 159 const Extension* extension) {
146 ShellIntegration::ShortcutInfo delete_info = 160 ShellIntegration::ShortcutInfo delete_info =
147 ShortcutInfoForExtensionAndProfile(extension, profile_); 161 ShortcutInfoForExtensionAndProfile(extension, profile_);
148 web_app::DeleteAllShortcuts(delete_info); 162 web_app::DeleteAllShortcuts(delete_info);
149 } 163 }
150 164
151 } // namespace extensions 165 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698