Make certificate viewer a tab-modal dialog.
[chromium-blink-merge.git] / apps / shortcut_manager.cc
blobe3fb8e6995ecefa0b8d3b3bb1e8a8c1093e938bc
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
3 // found in the LICENSE file.
5 #include "apps/shortcut_manager.h"
7 #include "base/bind.h"
8 #include "base/compiler_specific.h"
9 #include "chrome/browser/shell_integration.h"
10 #include "chrome/browser/ui/web_applications/web_app_ui.h"
11 #include "chrome/browser/web_applications/web_app.h"
12 #include "chrome/common/chrome_notification_types.h"
13 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_source.h"
16 using extensions::Extension;
18 namespace apps {
20 ShortcutManager::ShortcutManager(Profile* profile)
21 : profile_(profile),
22 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
23 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
24 content::Source<Profile>(profile_));
25 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
26 content::Source<Profile>(profile_));
29 ShortcutManager::~ShortcutManager() {}
31 void ShortcutManager::Observe(int type,
32 const content::NotificationSource& source,
33 const content::NotificationDetails& details) {
34 switch (type) {
35 case chrome::NOTIFICATION_EXTENSION_INSTALLED: {
36 #if !defined(OS_MACOSX)
37 const Extension* extension = content::Details<const Extension>(
38 details).ptr();
39 if (extension->is_platform_app() &&
40 extension->location() != extensions::Manifest::COMPONENT) {
41 web_app::UpdateShortcutInfoAndIconForApp(*extension, profile_,
42 base::Bind(&web_app::UpdateAllShortcuts));
44 #endif // !defined(OS_MACOSX)
45 break;
47 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
48 const Extension* extension = content::Details<const Extension>(
49 details).ptr();
50 DeleteApplicationShortcuts(extension);
51 break;
53 default:
54 NOTREACHED();
58 void ShortcutManager::DeleteApplicationShortcuts(
59 const Extension* extension) {
60 ShellIntegration::ShortcutInfo delete_info =
61 web_app::ShortcutInfoForExtensionAndProfile(extension, profile_);
62 web_app::DeleteAllShortcuts(delete_info);
65 } // namespace apps