OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/apps/shortcut_manager.h" | 5 #include "chrome/browser/apps/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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 AppShortcutManager::AppShortcutManager(Profile* profile) | 68 AppShortcutManager::AppShortcutManager(Profile* profile) |
69 : profile_(profile), | 69 : profile_(profile), |
70 is_profile_info_cache_observer_(false), | 70 is_profile_info_cache_observer_(false), |
71 prefs_(profile->GetPrefs()) { | 71 prefs_(profile->GetPrefs()) { |
72 // Use of g_browser_process requires that we are either on the UI thread, or | 72 // Use of g_browser_process requires that we are either on the UI thread, or |
73 // there are no threads initialized (such as in unit tests). | 73 // there are no threads initialized (such as in unit tests). |
74 DCHECK(!content::BrowserThread::IsThreadInitialized( | 74 DCHECK(!content::BrowserThread::IsThreadInitialized( |
75 content::BrowserThread::UI) || | 75 content::BrowserThread::UI) || |
76 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 76 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
77 | 77 |
78 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 78 registrar_.Add(this, |
| 79 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED, |
79 content::Source<Profile>(profile_)); | 80 content::Source<Profile>(profile_)); |
80 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 81 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
81 content::Source<Profile>(profile_)); | 82 content::Source<Profile>(profile_)); |
82 // Wait for extensions to be ready before running OnceOffCreateShortcuts. | 83 // Wait for extensions to be ready before running OnceOffCreateShortcuts. |
83 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, | 84 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
84 content::Source<Profile>(profile_)); | 85 content::Source<Profile>(profile_)); |
85 | 86 |
86 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 87 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
87 // profile_manager might be NULL in testing environments. | 88 // profile_manager might be NULL in testing environments. |
88 if (profile_manager) { | 89 if (profile_manager) { |
(...skipping 12 matching lines...) Expand all Loading... |
101 } | 102 } |
102 | 103 |
103 void AppShortcutManager::Observe(int type, | 104 void AppShortcutManager::Observe(int type, |
104 const content::NotificationSource& source, | 105 const content::NotificationSource& source, |
105 const content::NotificationDetails& details) { | 106 const content::NotificationDetails& details) { |
106 switch (type) { | 107 switch (type) { |
107 case chrome::NOTIFICATION_EXTENSIONS_READY: { | 108 case chrome::NOTIFICATION_EXTENSIONS_READY: { |
108 OnceOffCreateShortcuts(); | 109 OnceOffCreateShortcuts(); |
109 break; | 110 break; |
110 } | 111 } |
111 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 112 case chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED: { |
112 #if defined(OS_MACOSX) | 113 #if defined(OS_MACOSX) |
113 if (!apps::IsAppShimsEnabled()) | 114 if (!apps::IsAppShimsEnabled()) |
114 break; | 115 break; |
115 #endif // defined(OS_MACOSX) | 116 #endif // defined(OS_MACOSX) |
116 | 117 |
117 const extensions::InstalledExtensionInfo* installed_info = | 118 const extensions::InstalledExtensionInfo* installed_info = |
118 content::Details<const extensions::InstalledExtensionInfo>(details) | 119 content::Details<const extensions::InstalledExtensionInfo>(details) |
119 .ptr(); | 120 .ptr(); |
120 const Extension* extension = installed_info->extension; | 121 const Extension* extension = installed_info->extension; |
121 // If the app is being updated, update any existing shortcuts but do not | 122 // If the app is being updated, update any existing shortcuts but do not |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return; | 177 return; |
177 | 178 |
178 // Create an applications menu shortcut for each app in this profile. | 179 // Create an applications menu shortcut for each app in this profile. |
179 const extensions::ExtensionSet* apps = extension_service->extensions(); | 180 const extensions::ExtensionSet* apps = extension_service->extensions(); |
180 for (extensions::ExtensionSet::const_iterator it = apps->begin(); | 181 for (extensions::ExtensionSet::const_iterator it = apps->begin(); |
181 it != apps->end(); ++it) { | 182 it != apps->end(); ++it) { |
182 if (ShouldCreateShortcutFor(profile_, it->get())) | 183 if (ShouldCreateShortcutFor(profile_, it->get())) |
183 CreateShortcutsInApplicationsMenu(profile_, it->get()); | 184 CreateShortcutsInApplicationsMenu(profile_, it->get()); |
184 } | 185 } |
185 } | 186 } |
OLD | NEW |