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

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: Refactoring; moving App Host install errors to logs. 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"
9 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.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"
19 21
22 #if defined(OS_WIN)
23 #include "chrome/browser/extensions/app_host_installer_win.h"
24 #endif
25
20 namespace extensions { 26 namespace extensions {
21 27
22 namespace { 28 namespace {
23 29
24 #if defined(OS_MACOSX) 30 #if defined(OS_MACOSX)
25 const int kDesiredSizes[] = {16, 32, 128, 256, 512}; 31 const int kDesiredSizes[] = {16, 32, 128, 256, 512};
26 #else 32 #else
27 const int kDesiredSizes[] = {32}; 33 const int kDesiredSizes[] = {32};
28 #endif 34 #endif
29 35
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 80 }
75 81
76 void AppShortcutManager::Observe(int type, 82 void AppShortcutManager::Observe(int type,
77 const content::NotificationSource& source, 83 const content::NotificationSource& source,
78 const content::NotificationDetails& details) { 84 const content::NotificationDetails& details) {
79 #if !defined(OS_MACOSX) 85 #if !defined(OS_MACOSX)
80 switch (type) { 86 switch (type) {
81 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { 87 case chrome::NOTIFICATION_EXTENSION_INSTALLED: {
82 const Extension* extension = content::Details<const Extension>( 88 const Extension* extension = content::Details<const Extension>(
83 details).ptr(); 89 details).ptr();
84 if (extension->is_platform_app()) 90 if (extension->is_platform_app()) {
91 #if defined(OS_WIN)
92 extensions::AppHostInstaller::EnsureAppHostInstalled(
93 base::Bind(&AppShortcutManager::OnAppHostInstallationComplete,
94 base::Unretained(this), extension));
erikwright (departed) 2012/11/02 18:56:38 For safety the instance pointer should be a weak p
huangs 2012/11/02 20:22:36 Done.
95 #else
85 UpdateApplicationShortcuts(extension); 96 UpdateApplicationShortcuts(extension);
97 #endif
98 }
86 break; 99 break;
87 } 100 }
88 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { 101 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
89 const Extension* extension = content::Details<const Extension>( 102 const Extension* extension = content::Details<const Extension>(
90 details).ptr(); 103 details).ptr();
91 DeleteApplicationShortcuts(extension); 104 DeleteApplicationShortcuts(extension);
92 break; 105 break;
93 } 106 }
94 default: 107 default:
95 NOTREACHED(); 108 NOTREACHED();
96 } 109 }
97 #endif 110 #endif
98 } 111 }
99 112
113 #if defined(OS_WIN)
114 void AppShortcutManager::OnAppHostInstallationComplete(
115 const Extension* extension, bool app_host_install_success) {
116 if (!app_host_install_success) {
117 // Do not create shortcuts if App Host fails to install.
118 LOG(ERROR) << "Application Runtime installation failed.";
119 return;
120 }
121 UpdateApplicationShortcuts(extension);
122 }
123 #endif
124
100 void AppShortcutManager::UpdateApplicationShortcuts( 125 void AppShortcutManager::UpdateApplicationShortcuts(
101 const Extension* extension) { 126 const Extension* extension) {
102 shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_); 127 shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_);
103 128
104 std::vector<ImageLoadingTracker::ImageRepresentation> info_list; 129 std::vector<ImageLoadingTracker::ImageRepresentation> info_list;
105 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { 130 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) {
106 int size = kDesiredSizes[i]; 131 int size = kDesiredSizes[i];
107 ExtensionResource resource = extension->GetIconResource( 132 ExtensionResource resource = extension->GetIconResource(
108 size, ExtensionIconSet::MATCH_EXACTLY); 133 size, ExtensionIconSet::MATCH_EXACTLY);
109 if (!resource.empty()) { 134 if (!resource.empty()) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 167 }
143 168
144 void AppShortcutManager::DeleteApplicationShortcuts( 169 void AppShortcutManager::DeleteApplicationShortcuts(
145 const Extension* extension) { 170 const Extension* extension) {
146 ShellIntegration::ShortcutInfo delete_info = 171 ShellIntegration::ShortcutInfo delete_info =
147 ShortcutInfoForExtensionAndProfile(extension, profile_); 172 ShortcutInfoForExtensionAndProfile(extension, profile_);
148 web_app::DeleteAllShortcuts(delete_info); 173 web_app::DeleteAllShortcuts(delete_info);
149 } 174 }
150 175
151 } // namespace extensions 176 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698