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

Unified Diff: chrome/browser/extensions/tab_helper.cc

Issue 64853004: Use high resolution icons where possible for streamlined hosted app icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browser_experiment_create_app_from_page
Patch Set: rework, add tests Created 7 years, 1 month 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/extensions/tab_helper.cc
diff --git a/chrome/browser/extensions/tab_helper.cc b/chrome/browser/extensions/tab_helper.cc
index c11fd60ccc5ea4385997e96b1a760c0d0b7236ac..6127b5a81a0f9e1e47671bb8dc3aaa85c6787856 100644
--- a/chrome/browser/extensions/tab_helper.cc
+++ b/chrome/browser/extensions/tab_helper.cc
@@ -34,6 +34,7 @@
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/host_desktop.h"
+#include "chrome/browser/ui/web_applications/hosted_app_tab_helper.h"
#include "chrome/browser/ui/web_applications/web_app_ui.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/extensions/extension.h"
@@ -309,7 +310,8 @@ void TabHelper::OnDidGetApplicationInfo(int32 page_id,
break;
}
case CREATE_HOSTED_APP: {
- CreateHostedApp(info);
+ HostedAppTabHelper::FromWebContents(web_contents())->
+ CreateHostedApp(info);
break;
}
case UPDATE_SHORTCUT: {
@@ -328,39 +330,6 @@ void TabHelper::OnDidGetApplicationInfo(int32 page_id,
#endif
}
-void TabHelper::CreateHostedApp(const WebApplicationInfo& info) {
- ShellIntegration::ShortcutInfo shortcut_info;
- web_app::GetShortcutInfoForTab(web_contents(), &shortcut_info);
- WebApplicationInfo web_app_info;
-
- web_app_info.is_bookmark_app = true;
- web_app_info.app_url = shortcut_info.url;
- web_app_info.title = shortcut_info.title;
- web_app_info.urls.push_back(web_app_info.app_url);
-
- // TODO(calamity): this should attempt to download the best icon that it can
- // from |info.icons| rather than just using the favicon as it scales up badly.
- // Fix this once |info.icons| gets populated commonly.
-
- // Get the smallest icon in the icon family (should have only 1).
- const gfx::Image* icon = shortcut_info.favicon.GetBest(0, 0);
- SkBitmap bitmap = icon ? icon->AsBitmap() : SkBitmap();
-
- if (!icon->IsEmpty()) {
- WebApplicationInfo::IconInfo icon_info;
- icon_info.data = bitmap;
- icon_info.width = icon_info.data.width();
- icon_info.height = icon_info.data.height();
- web_app_info.icons.push_back(icon_info);
- }
-
- ExtensionService* service = profile_->GetExtensionService();
- scoped_refptr<extensions::CrxInstaller> installer(
- extensions::CrxInstaller::CreateSilent(service));
- installer->set_error_on_unsupported_requirements(true);
- installer->InstallWebApp(web_app_info);
-}
-
void TabHelper::OnInlineWebstoreInstall(
int install_id,
int return_route_id,

Powered by Google App Engine
This is Rietveld 408576698