Chromium Code Reviews| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 content::Source<Profile>(profile_)); | 56 content::Source<Profile>(profile_)); |
| 57 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 57 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 58 content::Source<Profile>(profile_)); | 58 content::Source<Profile>(profile_)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 AppShortcutManager::~AppShortcutManager() {} | 61 AppShortcutManager::~AppShortcutManager() {} |
| 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) | |
| 67 switch (type) { | 66 switch (type) { |
| 68 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 67 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { |
| 68 #if !defined(OS_MACOSX) | |
| 69 const Extension* extension = content::Details<const Extension>( | 69 const Extension* extension = content::Details<const Extension>( |
| 70 details).ptr(); | 70 details).ptr(); |
| 71 if (extension->is_platform_app() && | 71 if (extension->is_platform_app() && |
| 72 extension->location() != Manifest::COMPONENT) { | 72 extension->location() != Manifest::COMPONENT) { |
| 73 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
| 74 if (BrowserDistribution::GetDistribution()->AppHostIsSupported() && | 74 if (BrowserDistribution::GetDistribution()->AppHostIsSupported() && |
| 75 extensions::AppHostInstaller::GetInstallWithLauncher()) { | 75 extensions::AppHostInstaller::GetInstallWithLauncher()) { |
| 76 scoped_refptr<Extension> extension_ref(const_cast<Extension*>( | 76 scoped_refptr<Extension> extension_ref(const_cast<Extension*>( |
| 77 extension)); | 77 extension)); |
| 78 extensions::AppHostInstaller::EnsureAppHostInstalled( | 78 extensions::AppHostInstaller::EnsureAppHostInstalled( |
| 79 base::Bind(&AppShortcutManager::OnAppHostInstallationComplete, | 79 base::Bind(&AppShortcutManager::OnAppHostInstallationComplete, |
| 80 weak_factory_.GetWeakPtr(), extension_ref)); | 80 weak_factory_.GetWeakPtr(), extension_ref)); |
| 81 } else { | 81 } else { |
| 82 UpdateApplicationShortcuts(extension); | 82 UpdateApplicationShortcuts(extension); |
| 83 } | 83 } |
| 84 #else | 84 #else |
| 85 UpdateApplicationShortcuts(extension); | 85 UpdateApplicationShortcuts(extension); |
| 86 #endif | 86 #endif |
|
Avi (use Gerrit)
2013/02/05 00:19:25
Can you label some of these? It's hard to keep tra
jeremya
2013/02/05 02:38:14
Done.
| |
| 87 } | 87 } |
| 88 #endif | |
|
Avi (use Gerrit)
2013/02/05 00:19:25
...and here.
jeremya
2013/02/05 02:38:14
Done.
| |
| 88 break; | 89 break; |
| 89 } | 90 } |
| 90 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { | 91 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { |
| 91 const Extension* extension = content::Details<const Extension>( | 92 const Extension* extension = content::Details<const Extension>( |
| 92 details).ptr(); | 93 details).ptr(); |
| 93 DeleteApplicationShortcuts(extension); | 94 DeleteApplicationShortcuts(extension); |
| 94 break; | 95 break; |
| 95 } | 96 } |
| 96 default: | 97 default: |
| 97 NOTREACHED(); | 98 NOTREACHED(); |
| 98 } | 99 } |
| 99 #endif | |
| 100 } | 100 } |
| 101 | 101 |
| 102 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
| 103 void AppShortcutManager::OnAppHostInstallationComplete( | 103 void AppShortcutManager::OnAppHostInstallationComplete( |
| 104 scoped_refptr<Extension> extension, bool app_host_install_success) { | 104 scoped_refptr<Extension> extension, bool app_host_install_success) { |
| 105 if (!app_host_install_success) { | 105 if (!app_host_install_success) { |
| 106 // Do not create shortcuts if App Host fails to install. | 106 // Do not create shortcuts if App Host fails to install. |
| 107 LOG(ERROR) << "Application Runtime installation failed."; | 107 LOG(ERROR) << "Application Runtime installation failed."; |
| 108 return; | 108 return; |
| 109 } | 109 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 } | 176 } |
| 177 | 177 |
| 178 void AppShortcutManager::DeleteApplicationShortcuts( | 178 void AppShortcutManager::DeleteApplicationShortcuts( |
| 179 const Extension* extension) { | 179 const Extension* extension) { |
| 180 ShellIntegration::ShortcutInfo delete_info = | 180 ShellIntegration::ShortcutInfo delete_info = |
| 181 ShortcutInfoForExtensionAndProfile(extension, profile_); | 181 ShortcutInfoForExtensionAndProfile(extension, profile_); |
| 182 web_app::DeleteAllShortcuts(delete_info); | 182 web_app::DeleteAllShortcuts(delete_info); |
| 183 } | 183 } |
| 184 | 184 |
| 185 } // namespace extensions | 185 } // namespace extensions |
| OLD | NEW |