| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/webapps/add_to_homescreen_manager.h" | 5 #include "chrome/browser/android/webapps/add_to_homescreen_manager.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 void AddToHomescreenManager::AddShortcut( | 59 void AddToHomescreenManager::AddShortcut( |
| 60 JNIEnv* env, | 60 JNIEnv* env, |
| 61 const JavaParamRef<jobject>& obj, | 61 const JavaParamRef<jobject>& obj, |
| 62 const JavaParamRef<jstring>& j_user_title) { | 62 const JavaParamRef<jstring>& j_user_title) { |
| 63 content::WebContents* web_contents = data_fetcher_->web_contents(); | 63 content::WebContents* web_contents = data_fetcher_->web_contents(); |
| 64 if (!web_contents) | 64 if (!web_contents) |
| 65 return; | 65 return; |
| 66 | 66 |
| 67 base::string16 user_title = | 67 base::string16 user_title = |
| 68 base::android::ConvertJavaStringToUTF16(env, j_user_title); | 68 base::android::ConvertJavaStringToUTF16(env, j_user_title); |
| 69 if (!user_title.empty()) | |
| 70 data_fetcher_->shortcut_info().user_title = user_title; | |
| 71 | 69 |
| 72 RecordAddToHomescreen(); | 70 RecordAddToHomescreen(); |
| 73 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, | 71 ShortcutHelper::AddToLauncherWithSkBitmap( |
| 74 data_fetcher_->shortcut_info(), | 72 web_contents, data_fetcher_->shortcut_info(), user_title, |
| 75 data_fetcher_->primary_icon()); | 73 data_fetcher_->primary_icon()); |
| 76 | 74 |
| 77 // Fire the appinstalled event. | 75 // Fire the appinstalled event. |
| 78 banners::AppBannerManagerAndroid* app_banner_manager = | 76 banners::AppBannerManagerAndroid* app_banner_manager = |
| 79 banners::AppBannerManagerAndroid::FromWebContents(web_contents); | 77 banners::AppBannerManagerAndroid::FromWebContents(web_contents); |
| 80 app_banner_manager->OnInstall(); | 78 app_banner_manager->OnInstall(); |
| 81 } | 79 } |
| 82 | 80 |
| 83 void AddToHomescreenManager::Start(content::WebContents* web_contents) { | 81 void AddToHomescreenManager::Start(content::WebContents* web_contents) { |
| 84 bool check_webapk_compatible = false; | 82 bool check_webapk_compatible = false; |
| 85 if (ChromeWebApkHost::CanInstallWebApk() && | 83 if (ChromeWebApkHost::CanInstallWebApk() && |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 167 } |
| 170 | 168 |
| 171 void AddToHomescreenManager::CreateInfoBarForWebApk( | 169 void AddToHomescreenManager::CreateInfoBarForWebApk( |
| 172 const ShortcutInfo& info, | 170 const ShortcutInfo& info, |
| 173 const SkBitmap& primary_icon, | 171 const SkBitmap& primary_icon, |
| 174 const SkBitmap& badge_icon) { | 172 const SkBitmap& badge_icon) { |
| 175 content::WebContents* web_contents = data_fetcher_->web_contents(); | 173 content::WebContents* web_contents = data_fetcher_->web_contents(); |
| 176 banners::AppBannerManagerAndroid* app_banner_manager = | 174 banners::AppBannerManagerAndroid* app_banner_manager = |
| 177 banners::AppBannerManagerAndroid::FromWebContents(web_contents); | 175 banners::AppBannerManagerAndroid::FromWebContents(web_contents); |
| 178 banners::AppBannerInfoBarDelegateAndroid::Create( | 176 banners::AppBannerInfoBarDelegateAndroid::Create( |
| 179 web_contents, app_banner_manager->GetWeakPtr(), info.user_title, | 177 web_contents, app_banner_manager->GetWeakPtr(), |
| 180 base::MakeUnique<ShortcutInfo>(info), primary_icon, badge_icon, | 178 base::MakeUnique<ShortcutInfo>(info), primary_icon, badge_icon, |
| 181 -1 /* event_request_id */, true /* is_webapk */, | 179 -1 /* event_request_id */, true /* is_webapk */, |
| 182 webapk::INSTALL_SOURCE_MENU); | 180 webapk::INSTALL_SOURCE_MENU); |
| 183 } | 181 } |
| 184 | 182 |
| 185 SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground( | 183 SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground( |
| 186 const SkBitmap& bitmap, | 184 const SkBitmap& bitmap, |
| 187 const GURL& url, | 185 const GURL& url, |
| 188 bool* is_generated) { | 186 bool* is_generated) { |
| 189 base::ThreadRestrictions::AssertIOAllowed(); | 187 base::ThreadRestrictions::AssertIOAllowed(); |
| 190 | 188 |
| 191 return ShortcutHelper::FinalizeLauncherIconInBackground(bitmap, url, | 189 return ShortcutHelper::FinalizeLauncherIconInBackground(bitmap, url, |
| 192 is_generated); | 190 is_generated); |
| 193 } | 191 } |
| OLD | NEW |