| Index: chrome/browser/ui/web_applications/web_app_ui.cc
|
| diff --git a/chrome/browser/ui/web_applications/web_app_ui.cc b/chrome/browser/ui/web_applications/web_app_ui.cc
|
| index 8a5bf2a0df6f0376e676cc1fe238247f83af9dca..d800c5206e3b877b870690e65598f219c06af209 100644
|
| --- a/chrome/browser/ui/web_applications/web_app_ui.cc
|
| +++ b/chrome/browser/ui/web_applications/web_app_ui.cc
|
| @@ -8,32 +8,18 @@
|
| #include "base/bind_helpers.h"
|
| #include "base/file_util.h"
|
| #include "base/path_service.h"
|
| -#include "base/prefs/pref_service.h"
|
| -#include "base/strings/string16.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/browser/chrome_notification_types.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/history/select_favicon_frames.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/web_applications/web_app.h"
|
| -#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
|
| -#include "chrome/common/extensions/manifest_handlers/icons_handler.h"
|
| -#include "chrome/common/pref_names.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/notification_details.h"
|
| #include "content/public/browser/notification_registrar.h"
|
| #include "content/public/browser/notification_source.h"
|
| #include "content/public/browser/web_contents.h"
|
| -#include "extensions/common/extension.h"
|
| -#include "grit/theme_resources.h"
|
| -#include "skia/ext/image_operations.h"
|
| -#include "third_party/skia/include/core/SkBitmap.h"
|
| -#include "ui/base/resource/resource_bundle.h"
|
| -#include "ui/gfx/image/image.h"
|
| -#include "ui/gfx/image/image_family.h"
|
| -#include "ui/gfx/image/image_skia.h"
|
| #include "url/gurl.h"
|
|
|
| #if defined(OS_POSIX) && !defined(OS_MACOSX)
|
| @@ -53,22 +39,7 @@ using content::WebContents;
|
|
|
| namespace {
|
|
|
| -#if defined(OS_MACOSX)
|
| -const int kDesiredSizes[] = {16, 32, 128, 256, 512};
|
| -const size_t kNumDesiredSizes = arraysize(kDesiredSizes);
|
| -#elif defined(OS_LINUX)
|
| -// Linux supports icons of any size. FreeDesktop Icon Theme Specification states
|
| -// that "Minimally you should install a 48x48 icon in the hicolor theme."
|
| -const int kDesiredSizes[] = {16, 32, 48, 128, 256, 512};
|
| -const size_t kNumDesiredSizes = arraysize(kDesiredSizes);
|
| -#elif defined(OS_WIN)
|
| -const int* kDesiredSizes = IconUtil::kIconDimensions;
|
| -const size_t kNumDesiredSizes = IconUtil::kNumIconDimensions;
|
| -#else
|
| -const int kDesiredSizes[] = {32};
|
| -const size_t kNumDesiredSizes = arraysize(kDesiredSizes);
|
| -#endif
|
| -
|
| +// TODO(jackhou): Move all win-specific code to web_app_win.
|
| #if defined(OS_WIN)
|
| // UpdateShortcutWorker holds all context data needed for update shortcut.
|
| // It schedules a pre-update check to find all shortcuts that needs to be
|
| @@ -343,41 +314,10 @@ void UpdateShortcutWorker::DeleteMeOnUIThread() {
|
| }
|
| #endif // defined(OS_WIN)
|
|
|
| -void OnImageLoaded(ShellIntegration::ShortcutInfo shortcut_info,
|
| - web_app::ShortcutInfoCallback callback,
|
| - const gfx::ImageFamily& image_family) {
|
| - // If the image failed to load (e.g. if the resource being loaded was empty)
|
| - // use the standard application icon.
|
| - if (image_family.empty()) {
|
| - gfx::Image default_icon =
|
| - ResourceBundle::GetSharedInstance().GetImageNamed(IDR_APP_DEFAULT_ICON);
|
| - int size = kDesiredSizes[kNumDesiredSizes - 1];
|
| - SkBitmap bmp = skia::ImageOperations::Resize(
|
| - *default_icon.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST,
|
| - size, size);
|
| - gfx::ImageSkia image_skia = gfx::ImageSkia::CreateFrom1xBitmap(bmp);
|
| - // We are on the UI thread, and this image is needed from the FILE thread,
|
| - // for creating shortcut icon files.
|
| - image_skia.MakeThreadSafe();
|
| - shortcut_info.favicon.Add(gfx::Image(image_skia));
|
| - } else {
|
| - shortcut_info.favicon = image_family;
|
| - }
|
| -
|
| - callback.Run(shortcut_info);
|
| -}
|
| -
|
| } // namespace
|
|
|
| namespace web_app {
|
|
|
| -ShellIntegration::ShortcutInfo ShortcutInfoForExtensionAndProfile(
|
| - const extensions::Extension* extension, Profile* profile) {
|
| - ShellIntegration::ShortcutInfo shortcut_info;
|
| - web_app::UpdateShortcutInfoForApp(*extension, profile, &shortcut_info);
|
| - return shortcut_info;
|
| -}
|
| -
|
| void GetShortcutInfoForTab(WebContents* web_contents,
|
| ShellIntegration::ShortcutInfo* info) {
|
| DCHECK(info); // Must provide a valid info.
|
| @@ -410,70 +350,4 @@ void UpdateShortcutForTabContents(WebContents* web_contents) {
|
| #endif // defined(OS_WIN)
|
| }
|
|
|
| -void UpdateShortcutInfoForApp(const extensions::Extension& app,
|
| - Profile* profile,
|
| - ShellIntegration::ShortcutInfo* shortcut_info) {
|
| - shortcut_info->extension_id = app.id();
|
| - shortcut_info->is_platform_app = app.is_platform_app();
|
| - shortcut_info->url = extensions::AppLaunchInfo::GetLaunchWebURL(&app);
|
| - shortcut_info->title = base::UTF8ToUTF16(app.name());
|
| - shortcut_info->description = base::UTF8ToUTF16(app.description());
|
| - shortcut_info->extension_path = app.path();
|
| - shortcut_info->profile_path = profile->GetPath();
|
| - shortcut_info->profile_name =
|
| - profile->GetPrefs()->GetString(prefs::kProfileName);
|
| -}
|
| -
|
| -void UpdateShortcutInfoAndIconForApp(
|
| - const extensions::Extension* extension,
|
| - Profile* profile,
|
| - const web_app::ShortcutInfoCallback& callback) {
|
| - ShellIntegration::ShortcutInfo shortcut_info =
|
| - ShortcutInfoForExtensionAndProfile(extension, profile);
|
| -
|
| - std::vector<extensions::ImageLoader::ImageRepresentation> info_list;
|
| - for (size_t i = 0; i < kNumDesiredSizes; ++i) {
|
| - int size = kDesiredSizes[i];
|
| - extensions::ExtensionResource resource =
|
| - extensions::IconsInfo::GetIconResource(
|
| - extension, size, ExtensionIconSet::MATCH_EXACTLY);
|
| - if (!resource.empty()) {
|
| - info_list.push_back(extensions::ImageLoader::ImageRepresentation(
|
| - resource,
|
| - extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE,
|
| - gfx::Size(size, size),
|
| - ui::SCALE_FACTOR_100P));
|
| - }
|
| - }
|
| -
|
| - if (info_list.empty()) {
|
| - size_t i = kNumDesiredSizes - 1;
|
| - int size = kDesiredSizes[i];
|
| -
|
| - // If there is no icon at the desired sizes, we will resize what we can get.
|
| - // Making a large icon smaller is preferred to making a small icon larger,
|
| - // so look for a larger icon first:
|
| - extensions::ExtensionResource resource =
|
| - extensions::IconsInfo::GetIconResource(
|
| - extension, size, ExtensionIconSet::MATCH_BIGGER);
|
| - if (resource.empty()) {
|
| - resource = extensions::IconsInfo::GetIconResource(
|
| - extension, size, ExtensionIconSet::MATCH_SMALLER);
|
| - }
|
| - info_list.push_back(extensions::ImageLoader::ImageRepresentation(
|
| - resource,
|
| - extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE,
|
| - gfx::Size(size, size),
|
| - ui::SCALE_FACTOR_100P));
|
| - }
|
| -
|
| - // |info_list| may still be empty at this point, in which case
|
| - // LoadImageFamilyAsync will call the OnImageLoaded callback with an empty
|
| - // image and exit immediately.
|
| - extensions::ImageLoader::Get(profile)->LoadImageFamilyAsync(
|
| - extension,
|
| - info_list,
|
| - base::Bind(&OnImageLoaded, shortcut_info, callback));
|
| -}
|
| -
|
| } // namespace web_app
|
|
|