Index: chrome/browser/web_applications/web_app.cc |
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc |
index 02f227757f62472cfa2c8f8db8486b616c9af242..27d42a08c5aaa3d35c6c384f5b3ec243666efe61 100644 |
--- a/chrome/browser/web_applications/web_app.cc |
+++ b/chrome/browser/web_applications/web_app.cc |
@@ -14,6 +14,8 @@ |
#include "base/threading/thread.h" |
#include "chrome/browser/extensions/extension_ui_util.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/profiles/profile_manager.h" |
+#include "chrome/browser/browser_process.h" |
jackhou1
2014/12/03 05:12:05
Includes should be sorted.
mitchellj
2014/12/04 04:53:53
Done.
|
#include "chrome/common/chrome_constants.h" |
#include "chrome/common/chrome_version_info.h" |
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
@@ -268,7 +270,7 @@ void GetShortcutInfoForApp(const extensions::Extension* extension, |
bool ShouldCreateShortcutFor(Profile* profile, |
const extensions::Extension* extension) { |
- return extension->is_platform_app() && |
+ return (extension->is_platform_app() || extension->is_hosted_app()) && |
extension->location() != extensions::Manifest::COMPONENT && |
extensions::ui_util::CanDisplayInAppLauncher(extension, profile); |
} |
@@ -343,6 +345,21 @@ void CreateShortcutsWithInfo( |
const extensions::FileHandlersInfo& file_handlers_info) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ // It's possible for the extension to be deleted before we get here. |
+ // For example, creating a hosted app from a website. Double check that |
+ // it still exists. |
+ Profile* profile = g_browser_process->profile_manager() |
+ ->GetProfileByPath(shortcut_info.profile_path); |
+ if (!profile) |
+ return; |
+ |
+ extensions::ExtensionRegistry* registry = |
+ extensions::ExtensionRegistry::Get(profile); |
+ const extensions::Extension* extension = registry->GetExtensionById( |
+ shortcut_info.extension_id, extensions::ExtensionRegistry::ENABLED); |
+ if (!extension) |
+ return; |
+ |
BrowserThread::PostTask( |
BrowserThread::FILE, |
FROM_HERE, |