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