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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 DCHECK_EQ(chrome::NOTIFICATION_EXTENSIONS_READY, type); | 102 DCHECK_EQ(chrome::NOTIFICATION_EXTENSIONS_READY, type); |
103 OnceOffCreateShortcuts(); | 103 OnceOffCreateShortcuts(); |
104 } | 104 } |
105 | 105 |
106 void AppShortcutManager::OnExtensionWillBeInstalled( | 106 void AppShortcutManager::OnExtensionWillBeInstalled( |
107 content::BrowserContext* browser_context, | 107 content::BrowserContext* browser_context, |
108 const Extension* extension, | 108 const Extension* extension, |
109 bool is_update, | 109 bool is_update, |
110 bool from_ephemeral, | 110 bool from_ephemeral, |
111 const std::string& old_name) { | 111 const std::string& old_name) { |
112 if (!extension->is_app()) | |
tmdiep
2014/05/28 05:13:34
Added optimization here to avoid scanning for shor
| |
113 return; | |
114 | |
112 // If the app is being updated, update any existing shortcuts but do not | 115 // If the app is being updated, update any existing shortcuts but do not |
113 // create new ones. If it is being installed, automatically create a | 116 // create new ones. If it is being installed, automatically create a |
114 // shortcut in the applications menu (e.g., Start Menu). | 117 // shortcut in the applications menu (e.g., Start Menu). |
115 if (is_update) { | 118 if (is_update && !from_ephemeral) { |
116 web_app::UpdateAllShortcuts( | 119 web_app::UpdateAllShortcuts( |
117 base::UTF8ToUTF16(old_name), profile_, extension); | 120 base::UTF8ToUTF16(old_name), profile_, extension); |
118 } else if (ShouldCreateShortcutFor(profile_, extension)) { | 121 } else if (ShouldCreateShortcutFor(profile_, extension)) { |
119 CreateShortcutsInApplicationsMenu(profile_, extension); | 122 CreateShortcutsInApplicationsMenu(profile_, extension); |
120 } | 123 } |
121 } | 124 } |
122 | 125 |
123 void AppShortcutManager::OnExtensionUninstalled( | 126 void AppShortcutManager::OnExtensionUninstalled( |
124 content::BrowserContext* browser_context, | 127 content::BrowserContext* browser_context, |
125 const Extension* extension) { | 128 const Extension* extension) { |
(...skipping 25 matching lines...) Expand all Loading... | |
151 return; | 154 return; |
152 | 155 |
153 // Create an applications menu shortcut for each app in this profile. | 156 // Create an applications menu shortcut for each app in this profile. |
154 const extensions::ExtensionSet* apps = extension_service->extensions(); | 157 const extensions::ExtensionSet* apps = extension_service->extensions(); |
155 for (extensions::ExtensionSet::const_iterator it = apps->begin(); | 158 for (extensions::ExtensionSet::const_iterator it = apps->begin(); |
156 it != apps->end(); ++it) { | 159 it != apps->end(); ++it) { |
157 if (ShouldCreateShortcutFor(profile_, it->get())) | 160 if (ShouldCreateShortcutFor(profile_, it->get())) |
158 CreateShortcutsInApplicationsMenu(profile_, it->get()); | 161 CreateShortcutsInApplicationsMenu(profile_, it->get()); |
159 } | 162 } |
160 } | 163 } |
OLD | NEW |