| 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/guid.h" | |
| 10 #include "base/location.h" | 9 #include "base/location.h" |
| 11 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 15 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" | 14 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" |
| 16 #include "chrome/browser/android/shortcut_helper.h" | 15 #include "chrome/browser/android/shortcut_helper.h" |
| 17 #include "chrome/browser/android/webapk/chrome_webapk_host.h" | 16 #include "chrome/browser/android/webapk/chrome_webapk_host.h" |
| 18 #include "chrome/browser/android/webapk/webapk_install_service.h" | 17 #include "chrome/browser/android/webapk/webapk_install_service.h" |
| 19 #include "chrome/browser/android/webapk/webapk_metrics.h" | 18 #include "chrome/browser/android/webapk/webapk_metrics.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 DCHECK(add_shortcut_pending_); | 109 DCHECK(add_shortcut_pending_); |
| 111 if (!add_shortcut_pending_) | 110 if (!add_shortcut_pending_) |
| 112 return; | 111 return; |
| 113 add_shortcut_pending_ = false; | 112 add_shortcut_pending_ = false; |
| 114 | 113 |
| 115 content::WebContents* web_contents = data_fetcher_->web_contents(); | 114 content::WebContents* web_contents = data_fetcher_->web_contents(); |
| 116 if (!web_contents) | 115 if (!web_contents) |
| 117 return; | 116 return; |
| 118 | 117 |
| 119 RecordAddToHomescreen(); | 118 RecordAddToHomescreen(); |
| 120 | 119 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, info, icon); |
| 121 const std::string& uid = base::GenerateGUID(); | |
| 122 ShortcutHelper::AddToLauncherWithSkBitmap( | |
| 123 web_contents->GetBrowserContext(), info, uid, icon, | |
| 124 data_fetcher_->FetchSplashScreenImageCallback(uid)); | |
| 125 | 120 |
| 126 // Fire the appinstalled event. | 121 // Fire the appinstalled event. |
| 127 blink::mojom::InstallationServicePtr installation_service; | 122 blink::mojom::InstallationServicePtr installation_service; |
| 128 web_contents->GetMainFrame()->GetRemoteInterfaces()->GetInterface( | 123 web_contents->GetMainFrame()->GetRemoteInterfaces()->GetInterface( |
| 129 mojo::MakeRequest(&installation_service)); | 124 mojo::MakeRequest(&installation_service)); |
| 130 DCHECK(installation_service); | 125 DCHECK(installation_service); |
| 131 installation_service->OnInstall(); | 126 installation_service->OnInstall(); |
| 132 } | 127 } |
| 133 | 128 |
| 134 void AddToHomescreenManager::RecordAddToHomescreen() { | 129 void AddToHomescreenManager::RecordAddToHomescreen() { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 195 |
| 201 SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground( | 196 SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground( |
| 202 const SkBitmap& bitmap, | 197 const SkBitmap& bitmap, |
| 203 const GURL& url, | 198 const GURL& url, |
| 204 bool* is_generated) { | 199 bool* is_generated) { |
| 205 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 200 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 206 | 201 |
| 207 return ShortcutHelper::FinalizeLauncherIconInBackground(bitmap, url, | 202 return ShortcutHelper::FinalizeLauncherIconInBackground(bitmap, url, |
| 208 is_generated); | 203 is_generated); |
| 209 } | 204 } |
| OLD | NEW |