Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4054)

Unified Diff: chrome/browser/web_applications/web_app.cc

Issue 777543002: Create hosted app shims on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed global static initialisers Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ec13b3742313d5c40a59dfe42a7de9b8504ada5c 100644
--- a/chrome/browser/web_applications/web_app.cc
+++ b/chrome/browser/web_applications/web_app.cc
@@ -12,8 +12,10 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_ui_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
@@ -268,9 +270,18 @@ void GetShortcutInfoForApp(const extensions::Extension* extension,
bool ShouldCreateShortcutFor(Profile* profile,
const extensions::Extension* extension) {
- return extension->is_platform_app() &&
- extension->location() != extensions::Manifest::COMPONENT &&
- extensions::ui_util::CanDisplayInAppLauncher(extension, profile);
+ bool app_type_requires_shortcut = extension->is_platform_app();
+
+// An additional check here for OS X. We need app shims to be
+// able to show them in the dock.
+#if defined(OS_MACOSX)
+ app_type_requires_shortcut =
+ app_type_requires_shortcut || extension->is_hosted_app();
+#endif
+
+ return (app_type_requires_shortcut &&
+ extension->location() != extensions::Manifest::COMPONENT &&
+ extensions::ui_util::CanDisplayInAppLauncher(extension, profile));
}
base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path,
@@ -343,6 +354,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,

Powered by Google App Engine
This is Rietveld 408576698