shortcut_manager.cc revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
1558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch// Copyright 2013 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch#include "chrome/browser/apps/shortcut_manager.h" 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/bind.h" 8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/command_line.h" 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/compiler_specific.h" 10eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/prefs/pref_service.h" 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h" 13eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/browser/browser_process.h" 147dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/chrome_notification_types.h" 15eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/browser/extensions/extension_service.h" 16eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/browser/profiles/profile.h" 17eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/browser/profiles/profile_info_cache.h" 18eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/browser/profiles/profile_manager.h" 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/shell_integration.h" 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/web_applications/web_app_ui.h" 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/web_applications/web_app.h" 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/common/chrome_switches.h" 234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "chrome/common/pref_names.h" 244e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "components/user_prefs/pref_registry_syncable.h" 25eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "content/public/browser/browser_thread.h" 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/notification_details.h" 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/notification_source.h" 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "extensions/browser/extension_system.h" 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "extensions/common/extension_set.h" 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 31a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#if defined(OS_MACOSX) 32a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "apps/app_shim/app_shim_mac.h" 33a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#endif 34a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)using extensions::Extension; 362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 37c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace { 38c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 39eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// Creates a shortcut for an application in the applications menu, if there is 40eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// not already one present. 41c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void CreateShortcutsInApplicationsMenu( 42c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) const ShellIntegration::ShortcutInfo& shortcut_info) { 43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ShellIntegration::ShortcutLocations creation_locations; 44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Create the shortcut in the Chrome Apps subdir. 45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) creation_locations.applications_menu_location = 46a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) ShellIntegration::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS; 47eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch web_app::CreateShortcuts(shortcut_info, creation_locations, 48558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch web_app::SHORTCUT_CREATION_AUTOMATED); 49eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch} 50eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 51eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochbool ShouldCreateShortcutFor(const extensions::Extension* extension) { 52eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch return extension->is_platform_app() && 53eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch extension->location() != extensions::Manifest::COMPONENT && 54eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch extension->ShouldDisplayInAppLauncher(); 55c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 56c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 57c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} // namespace 58c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 594e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// static 604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)void AppShortcutManager::RegisterProfilePrefs( 614e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) user_prefs::PrefRegistrySyncable* registry) { 624e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Indicates whether app shortcuts have been created. 634e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) registry->RegisterBooleanPref( 644e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) prefs::kAppShortcutsHaveBeenCreated, false, 654e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 664e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 674e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 68558790d6acca3451cf3a6b497803a5f07d0bec58Ben MurdochAppShortcutManager::AppShortcutManager(Profile* profile) 692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) : profile_(profile), 70eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch is_profile_info_cache_observer_(false), 71eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch prefs_(profile->GetPrefs()), 72c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) weak_factory_(this) { 732385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch // Use of g_browser_process requires that we are either on the UI thread, or 742385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch // there are no threads initialized (such as in unit tests). 75ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch DCHECK(!content::BrowserThread::IsThreadInitialized( 76ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch content::BrowserThread::UI) || 77ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 782385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch 792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::Source<Profile>(profile_)); 812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::Source<Profile>(profile_)); 83eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Wait for extensions to be ready before running OnceOffCreateShortcuts. 84eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, 85eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch content::Source<Profile>(profile_)); 86eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 87eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ProfileManager* profile_manager = g_browser_process->profile_manager(); 88eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // profile_manager might be NULL in testing environments. 89eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (profile_manager) { 90eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch profile_manager->GetProfileInfoCache().AddObserver(this); 91eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch is_profile_info_cache_observer_ = true; 92eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch } 932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 95558790d6acca3451cf3a6b497803a5f07d0bec58Ben MurdochAppShortcutManager::~AppShortcutManager() { 96eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (g_browser_process && is_profile_info_cache_observer_) { 97eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ProfileManager* profile_manager = g_browser_process->profile_manager(); 98eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // profile_manager might be NULL in testing environments or during shutdown. 99eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (profile_manager) 100eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch profile_manager->GetProfileInfoCache().RemoveObserver(this); 101eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch } 102eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch} 1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 104558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdochvoid AppShortcutManager::Observe(int type, 1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const content::NotificationSource& source, 1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const content::NotificationDetails& details) { 1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) switch (type) { 108eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch case chrome::NOTIFICATION_EXTENSIONS_READY: { 109eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch OnceOffCreateShortcuts(); 110eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch break; 111eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch } 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case chrome::NOTIFICATION_EXTENSION_INSTALLED: { 113868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#if defined(OS_MACOSX) 114a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) if (!apps::IsAppShimsEnabled()) 115868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) break; 116868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif // defined(OS_MACOSX) 117868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 118c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) const extensions::InstalledExtensionInfo* installed_info = 119c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) content::Details<const extensions::InstalledExtensionInfo>(details) 120c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) .ptr(); 121c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) const Extension* extension = installed_info->extension; 122eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (ShouldCreateShortcutFor(extension)) { 123c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // If the app is being updated, update any existing shortcuts but do not 124c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // create new ones. If it is being installed, automatically create a 125c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // shortcut in the applications menu (e.g., Start Menu). 126c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) base::Callback<void(const ShellIntegration::ShortcutInfo&)> 127c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) create_or_update; 128c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (installed_info->is_update) { 1295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::string16 old_title = 1305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::UTF8ToUTF16(installed_info->old_name); 13190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) create_or_update = base::Bind(&web_app::UpdateAllShortcuts, 13290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) old_title); 133c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } else { 134c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) create_or_update = base::Bind(&CreateShortcutsInApplicationsMenu); 135c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 136c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) web_app::UpdateShortcutInfoAndIconForApp(*extension, profile_, 138c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) create_or_update); 1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 1412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { 1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const Extension* extension = content::Details<const Extension>( 1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) details).ptr(); 1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DeleteApplicationShortcuts(extension); 1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) default: 1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) NOTREACHED(); 1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 153558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdochvoid AppShortcutManager::OnProfileWillBeRemoved( 154eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch const base::FilePath& profile_path) { 155eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (profile_path != profile_->GetPath()) 156eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch return; 157eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch content::BrowserThread::PostTask( 158eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch content::BrowserThread::FILE, FROM_HERE, 159eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch base::Bind(&web_app::internals::DeleteAllShortcutsForProfile, 160eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch profile_path)); 161eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch} 162eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 163558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdochvoid AppShortcutManager::OnceOffCreateShortcuts() { 1644e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) bool was_enabled = prefs_->GetBoolean(prefs::kAppShortcutsHaveBeenCreated); 165eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Creation of shortcuts on Mac currently can be disabled with 1675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // --disable-app-shims, so check the flag, and set the pref accordingly. 168eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#if defined(OS_MACOSX) 169a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) bool is_now_enabled = apps::IsAppShimsEnabled(); 170eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#else 171eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch bool is_now_enabled = true; 172eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#endif // defined(OS_MACOSX) 173eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 174eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (was_enabled != is_now_enabled) 1754e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) prefs_->SetBoolean(prefs::kAppShortcutsHaveBeenCreated, is_now_enabled); 176eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 177eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (was_enabled || !is_now_enabled) 178eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch return; 179eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 180eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Check if extension system/service are available. They might not be in 181eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // tests. 182eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch extensions::ExtensionSystem* extension_system; 183eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ExtensionServiceInterface* extension_service; 184eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (!(extension_system = extensions::ExtensionSystem::Get(profile_)) || 185eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch !(extension_service = extension_system->extension_service())) 186eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch return; 187eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 188eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Create an applications menu shortcut for each app in this profile. 1895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const extensions::ExtensionSet* apps = extension_service->extensions(); 1905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) for (extensions::ExtensionSet::const_iterator it = apps->begin(); 191eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch it != apps->end(); ++it) { 192eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (ShouldCreateShortcutFor(it->get())) 193eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch web_app::UpdateShortcutInfoAndIconForApp( 194eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch *it->get(), profile_, base::Bind(&CreateShortcutsInApplicationsMenu)); 195eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch } 196eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch} 197eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 198558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdochvoid AppShortcutManager::DeleteApplicationShortcuts( 1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const Extension* extension) { 2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ShellIntegration::ShortcutInfo delete_info = 2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) web_app::ShortcutInfoForExtensionAndProfile(extension, profile_); 2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) web_app::DeleteAllShortcuts(delete_info); 2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 204