Commit d6b62689 authored by Evan Stade's avatar Evan Stade Committed by Chromium LUCI CQ

Add WebappsClient::AddShortcut

This installs a homescreen shortcut for a webpage. It seems at least
some of the code for doing this, i.e. AddShortcutWithSkBitmap(), is
componentizable and could run in WebLayer. This may be desirable
specifically for the case where Chrome is not the default browser
(creating a shortcut in the default browser). However for now, that
decision and work is punted.

Bug: 1164069
Change-Id: I8fbb789dc833a09358a821aba828d7a82ee9fd86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2640935Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845837}
parent 5043656d
......@@ -8,7 +8,6 @@
#include "base/callback.h"
#include "chrome/android/chrome_jni_headers/AddToHomescreenInstaller_jni.h"
#include "chrome/browser/android/shortcut_helper.h"
#include "chrome/browser/android/tab_android.h"
#include "components/webapps/browser/webapps_client.h"
#include "content/public/browser/web_contents.h"
......@@ -35,7 +34,7 @@ void AddToHomescreenInstaller::Install(
WebappsClient::Get()->InstallWebApk(web_contents, params);
break;
case AddToHomescreenParams::AppType::SHORTCUT:
InstallShortcut(web_contents, params);
WebappsClient::Get()->InstallShortcut(web_contents, params);
break;
}
event_callback.Run(Event::INSTALL_REQUEST_FINISHED, params);
......@@ -62,13 +61,4 @@ void AddToHomescreenInstaller::InstallOrOpenNativeApp(
params);
}
// static
void AddToHomescreenInstaller::InstallShortcut(
content::WebContents* web_contents,
const AddToHomescreenParams& params) {
ShortcutHelper::AddToLauncherWithSkBitmap(
web_contents, *(params.shortcut_info), params.primary_icon,
params.has_maskable_primary_icon);
}
} // namespace webapps
......@@ -47,8 +47,6 @@ class AddToHomescreenInstaller {
event_callback);
static void InstallWebApk(content::WebContents* web_contents,
const AddToHomescreenParams& params);
static void InstallShortcut(content::WebContents* web_contents,
const AddToHomescreenParams& params);
AddToHomescreenInstaller() = delete;
AddToHomescreenInstaller(const AddToHomescreenInstaller&) = delete;
......
......@@ -11,6 +11,7 @@
#include "content/public/browser/web_contents.h"
#if defined(OS_ANDROID)
#include "chrome/browser/android/shortcut_helper.h"
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/android/tab_web_contents_delegate_android.h"
#include "chrome/browser/android/webapk/webapk_install_service.h"
......@@ -105,6 +106,13 @@ void ChromeWebappsClient::InstallWebApk(content::WebContents* web_contents,
->InstallAsync(web_contents, *(params.shortcut_info), params.primary_icon,
params.has_maskable_primary_icon, params.install_source);
}
void ChromeWebappsClient::InstallShortcut(content::WebContents* web_contents,
const AddToHomescreenParams& params) {
ShortcutHelper::AddToLauncherWithSkBitmap(
web_contents, *(params.shortcut_info), params.primary_icon,
params.has_maskable_primary_icon);
}
#endif
} // namespace webapps
......@@ -33,6 +33,8 @@ class ChromeWebappsClient : public WebappsClient {
content::WebContents* web_contents) override;
void InstallWebApk(content::WebContents* web_contents,
const AddToHomescreenParams& params) override;
void InstallShortcut(content::WebContents* web_contents,
const AddToHomescreenParams& params) override;
#endif
private:
......
......@@ -57,6 +57,9 @@ class WebappsClient {
virtual void InstallWebApk(content::WebContents* web_contents,
const AddToHomescreenParams& params) = 0;
virtual void InstallShortcut(content::WebContents* web_contents,
const AddToHomescreenParams& params) = 0;
#endif
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment