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 "apps/shortcut_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | |
9 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | |
11 #include "base/utf_string_conversions.h" | |
12 #include "chrome/browser/extensions/image_loader.h" | |
13 #include "chrome/browser/profiles/profile.h" | |
14 #include "chrome/browser/shell_integration.h" | 9 #include "chrome/browser/shell_integration.h" |
15 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 10 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
16 #include "chrome/browser/web_applications/web_app.h" | 11 #include "chrome/browser/web_applications/web_app.h" |
17 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/chrome_switches.h" | |
19 #include "chrome/common/extensions/extension_resource.h" | |
20 #include "content/public/browser/notification_details.h" | 13 #include "content/public/browser/notification_details.h" |
21 #include "content/public/browser/notification_source.h" | 14 #include "content/public/browser/notification_source.h" |
22 #include "grit/theme_resources.h" | |
23 #include "skia/ext/image_operations.h" | |
24 #include "ui/base/resource/resource_bundle.h" | |
25 | 15 |
26 namespace extensions { | 16 using extensions::Extension; |
27 | 17 |
28 AppShortcutManager::AppShortcutManager(Profile* profile) | 18 namespace apps { |
| 19 |
| 20 ShortcutManager::ShortcutManager(Profile* profile) |
29 : profile_(profile), | 21 : profile_(profile), |
30 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 22 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
31 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 23 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
32 content::Source<Profile>(profile_)); | 24 content::Source<Profile>(profile_)); |
33 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 25 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
34 content::Source<Profile>(profile_)); | 26 content::Source<Profile>(profile_)); |
35 } | 27 } |
36 | 28 |
37 AppShortcutManager::~AppShortcutManager() {} | 29 ShortcutManager::~ShortcutManager() {} |
38 | 30 |
39 void AppShortcutManager::Observe(int type, | 31 void ShortcutManager::Observe(int type, |
40 const content::NotificationSource& source, | 32 const content::NotificationSource& source, |
41 const content::NotificationDetails& details) { | 33 const content::NotificationDetails& details) { |
42 switch (type) { | 34 switch (type) { |
43 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 35 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { |
44 #if !defined(OS_MACOSX) | 36 #if !defined(OS_MACOSX) |
45 const Extension* extension = content::Details<const Extension>( | 37 const Extension* extension = content::Details<const Extension>( |
46 details).ptr(); | 38 details).ptr(); |
47 if (extension->is_platform_app() && | 39 if (extension->is_platform_app() && |
48 extension->location() != Manifest::COMPONENT) { | 40 extension->location() != extensions::Manifest::COMPONENT) { |
49 web_app::UpdateShortcutInfoAndIconForApp(*extension, profile_, | 41 web_app::UpdateShortcutInfoAndIconForApp(*extension, profile_, |
50 base::Bind(&web_app::UpdateAllShortcuts)); | 42 base::Bind(&web_app::UpdateAllShortcuts)); |
51 } | 43 } |
52 #endif // !defined(OS_MACOSX) | 44 #endif // !defined(OS_MACOSX) |
53 break; | 45 break; |
54 } | 46 } |
55 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { | 47 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { |
56 const Extension* extension = content::Details<const Extension>( | 48 const Extension* extension = content::Details<const Extension>( |
57 details).ptr(); | 49 details).ptr(); |
58 DeleteApplicationShortcuts(extension); | 50 DeleteApplicationShortcuts(extension); |
59 break; | 51 break; |
60 } | 52 } |
61 default: | 53 default: |
62 NOTREACHED(); | 54 NOTREACHED(); |
63 } | 55 } |
64 } | 56 } |
65 | 57 |
66 void AppShortcutManager::DeleteApplicationShortcuts( | 58 void ShortcutManager::DeleteApplicationShortcuts( |
67 const Extension* extension) { | 59 const Extension* extension) { |
68 ShellIntegration::ShortcutInfo delete_info = | 60 ShellIntegration::ShortcutInfo delete_info = |
69 web_app::ShortcutInfoForExtensionAndProfile(extension, profile_); | 61 web_app::ShortcutInfoForExtensionAndProfile(extension, profile_); |
70 web_app::DeleteAllShortcuts(delete_info); | 62 web_app::DeleteAllShortcuts(delete_info); |
71 } | 63 } |
72 | 64 |
73 } // namespace extensions | 65 } // namespace apps |
OLD | NEW |