Chromium Code Reviews| 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 7f9964552949d1b2321b08cfaafdcf63be7b996f..d6e25b6c305be99f9596986c5c856509c9686600 100644 |
| --- a/chrome/browser/web_applications/web_app.cc |
| +++ b/chrome/browser/web_applications/web_app.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/threading/thread.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" |
| @@ -21,8 +22,10 @@ |
| #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| #include "chrome/common/pref_names.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 +77,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, |
| @@ -374,6 +384,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 +414,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()); |
|
tapted
2014/05/30 06:33:27
Why not just call
web_app::UpdateAllShortcuts(bas
jackhou1
2014/06/02 04:25:19
Yeah, I agree with making this simpler until we ac
|
| + } |
| + |
| + 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[] = { |
| url::kFileScheme, |