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 25 matching lines...) Expand all Loading... |
36 content::Source<Profile>(profile_)); | 36 content::Source<Profile>(profile_)); |
37 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 37 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
38 content::Source<Profile>(profile_)); | 38 content::Source<Profile>(profile_)); |
39 } | 39 } |
40 | 40 |
41 AppShortcutManager::~AppShortcutManager() {} | 41 AppShortcutManager::~AppShortcutManager() {} |
42 | 42 |
43 void AppShortcutManager::Observe(int type, | 43 void AppShortcutManager::Observe(int type, |
44 const content::NotificationSource& source, | 44 const content::NotificationSource& source, |
45 const content::NotificationDetails& details) { | 45 const content::NotificationDetails& details) { |
46 #if !defined(OS_MACOSX) | |
47 switch (type) { | 46 switch (type) { |
48 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 47 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { |
| 48 #if !defined(OS_MACOSX) |
49 const Extension* extension = content::Details<const Extension>( | 49 const Extension* extension = content::Details<const Extension>( |
50 details).ptr(); | 50 details).ptr(); |
51 if (extension->is_platform_app() && | 51 if (extension->is_platform_app() && |
52 extension->location() != Manifest::COMPONENT) { | 52 extension->location() != Manifest::COMPONENT) { |
53 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
54 if (BrowserDistribution::GetDistribution()->AppHostIsSupported() && | 54 if (BrowserDistribution::GetDistribution()->AppHostIsSupported() && |
55 extensions::AppHostInstaller::GetInstallWithLauncher()) { | 55 extensions::AppHostInstaller::GetInstallWithLauncher()) { |
56 scoped_refptr<Extension> extension_ref(const_cast<Extension*>( | 56 scoped_refptr<Extension> extension_ref(const_cast<Extension*>( |
57 extension)); | 57 extension)); |
58 extensions::AppHostInstaller::EnsureAppHostInstalled( | 58 extensions::AppHostInstaller::EnsureAppHostInstalled( |
59 base::Bind(&AppShortcutManager::OnAppHostInstallationComplete, | 59 base::Bind(&AppShortcutManager::OnAppHostInstallationComplete, |
60 weak_factory_.GetWeakPtr(), extension_ref)); | 60 weak_factory_.GetWeakPtr(), extension_ref)); |
61 } else { | 61 } else { |
62 UpdateApplicationShortcuts(extension); | 62 UpdateApplicationShortcuts(extension); |
63 } | 63 } |
64 #else | 64 #else |
65 UpdateApplicationShortcuts(extension); | 65 UpdateApplicationShortcuts(extension); |
66 #endif | 66 #endif // defined(OS_WIN) |
67 } | 67 } |
| 68 #endif // !defined(OS_MACOSX) |
68 break; | 69 break; |
69 } | 70 } |
70 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { | 71 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { |
71 const Extension* extension = content::Details<const Extension>( | 72 const Extension* extension = content::Details<const Extension>( |
72 details).ptr(); | 73 details).ptr(); |
73 DeleteApplicationShortcuts(extension); | 74 DeleteApplicationShortcuts(extension); |
74 break; | 75 break; |
75 } | 76 } |
76 default: | 77 default: |
77 NOTREACHED(); | 78 NOTREACHED(); |
78 } | 79 } |
79 #endif | |
80 } | 80 } |
81 | 81 |
82 #if defined(OS_WIN) | 82 #if defined(OS_WIN) |
83 void AppShortcutManager::OnAppHostInstallationComplete( | 83 void AppShortcutManager::OnAppHostInstallationComplete( |
84 scoped_refptr<Extension> extension, bool app_host_install_success) { | 84 scoped_refptr<Extension> extension, bool app_host_install_success) { |
85 if (!app_host_install_success) { | 85 if (!app_host_install_success) { |
86 // Do not create shortcuts if App Host fails to install. | 86 // Do not create shortcuts if App Host fails to install. |
87 LOG(ERROR) << "Application Runtime installation failed."; | 87 LOG(ERROR) << "Application Runtime installation failed."; |
88 return; | 88 return; |
89 } | 89 } |
90 UpdateApplicationShortcuts(extension); | 90 UpdateApplicationShortcuts(extension); |
91 } | 91 } |
92 #endif | 92 #endif |
93 | 93 |
94 void AppShortcutManager::UpdateApplicationShortcuts( | 94 void AppShortcutManager::UpdateApplicationShortcuts( |
95 const Extension* extension) { | 95 const Extension* extension) { |
96 web_app::UpdateShortcutInfoAndIconForApp(*extension, profile_, | 96 web_app::UpdateShortcutInfoAndIconForApp(*extension, profile_, |
97 base::Bind(&web_app::UpdateAllShortcuts)); | 97 base::Bind(&web_app::UpdateAllShortcuts)); |
98 } | 98 } |
99 | 99 |
100 void AppShortcutManager::DeleteApplicationShortcuts( | 100 void AppShortcutManager::DeleteApplicationShortcuts( |
101 const Extension* extension) { | 101 const Extension* extension) { |
102 ShellIntegration::ShortcutInfo delete_info = | 102 ShellIntegration::ShortcutInfo delete_info = |
103 web_app::ShortcutInfoForExtensionAndProfile(extension, profile_); | 103 web_app::ShortcutInfoForExtensionAndProfile(extension, profile_); |
104 web_app::DeleteAllShortcuts(delete_info); | 104 web_app::DeleteAllShortcuts(delete_info); |
105 } | 105 } |
106 | 106 |
107 } // namespace extensions | 107 } // namespace extensions |
OLD | NEW |