| 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 1d8866712809f1d9d5700ce829f7147cac7c5d69..76c396fbcae39d31b143a61f8f4085e9cec06786 100644
|
| --- a/chrome/browser/web_applications/web_app.cc
|
| +++ b/chrome/browser/web_applications/web_app.cc
|
| @@ -12,18 +12,23 @@
|
| #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/extensions/image_loader.h"
|
| #include "chrome/browser/extensions/tab_helper.h"
|
| #include "chrome/browser/favicon/favicon_tab_helper.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"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "extensions/browser/extension_registry.h"
|
| #include "extensions/common/constants.h"
|
| #include "extensions/common/extension.h"
|
| +#include "extensions/common/extension_set.h"
|
| #include "extensions/common/manifest_handlers/icons_handler.h"
|
| #include "grit/theme_resources.h"
|
| #include "skia/ext/image_operations.h"
|
| @@ -74,6 +79,13 @@ base::FilePath GetShortcutDataDir(const web_app::ShortcutInfo& shortcut_info) {
|
| shortcut_info.url);
|
| }
|
|
|
| +bool ShouldCreateShortcutFor(Profile* profile,
|
| + const extensions::Extension* extension) {
|
| + return extension->is_platform_app() &&
|
| + extension->location() != extensions::Manifest::COMPONENT &&
|
| + extensions::ui_util::ShouldDisplayInAppLauncher(extension, profile);
|
| +}
|
| +
|
| void CreateShortcutsWithInfo(
|
| web_app::ShortcutCreationReason reason,
|
| const web_app::ShortcutLocations& locations,
|
| @@ -203,6 +215,25 @@ static const char* kCrxAppPrefix = "_crx_";
|
|
|
| namespace internals {
|
|
|
| +void CallForProfileAndAppId(
|
| + const base::FilePath& profile_path,
|
| + const std::string app_id,
|
| + const ShortcutOperationCallback& callback) {
|
| + ProfileManager* profile_manager = g_browser_process->profile_manager();
|
| + Profile* profile = profile_manager->GetProfileByPath(profile_path);
|
| + if (!profile || !profile_manager->IsValidProfile(profile))
|
| + return;
|
| +
|
| + extensions::ExtensionRegistry* registry =
|
| + extensions::ExtensionRegistry::Get(profile);
|
| + const extensions::Extension* extension = registry->GetExtensionById(
|
| + app_id, extensions::ExtensionRegistry::EVERYTHING);
|
| + if (!extension || !extension->is_platform_app())
|
| + return;
|
| +
|
| + callback.Run(profile, extension);
|
| +}
|
| +
|
| base::FilePath GetSanitizedFileName(const base::string16& name) {
|
| #if defined(OS_WIN)
|
| base::string16 file_name = name;
|
| @@ -374,6 +405,9 @@ void CreateShortcuts(ShortcutCreationReason reason,
|
| const extensions::Extension* app) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| + if (!ShouldCreateShortcutFor(profile, app))
|
| + return;
|
| +
|
| GetInfoForApp(app,
|
| profile,
|
| base::Bind(&CreateShortcutsWithInfo, reason, locations));
|
| @@ -401,6 +435,30 @@ void UpdateAllShortcuts(const base::string16& old_app_title,
|
| base::Bind(&UpdateAllShortcutsForShortcutInfo, old_app_title));
|
| }
|
|
|
| +void UpdateShortcutsForAllApps(Profile* profile) {
|
| + extensions::ExtensionRegistry* registry =
|
| + extensions::ExtensionRegistry::Get(profile);
|
| + if (!registry)
|
| + return;
|
| +
|
| + // Get a set of app ids.
|
| + scoped_ptr<extensions::ExtensionSet> everything =
|
| + registry->GenerateInstalledExtensionsSet();
|
| + std::set<std::string> app_ids;
|
| + for (extensions::ExtensionSet::const_iterator it = everything->begin();
|
| + it != everything->end(); ++it) {
|
| + if (ShouldCreateShortcutFor(profile, it->get()))
|
| + app_ids.insert((*it)->id());
|
| + }
|
| +
|
| + BrowserThread::PostTask(
|
| + BrowserThread::FILE,
|
| + FROM_HERE,
|
| + base::Bind(
|
| + &web_app::internals::UpdateShortcutsForAllAppsForProfile,
|
| + profile->GetPath(), app_ids));
|
| +}
|
| +
|
| bool IsValidUrl(const GURL& url) {
|
| static const char* const kValidUrlSchemes[] = {
|
| content::kFileScheme,
|
|
|