Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shortcut_helper.h" | 5 #include "chrome/browser/android/shortcut_helper.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 11 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
| 12 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
|
dominickn
2017/03/01 02:29:39
This command_line.h include can be removed while y
| |
| 16 #include "base/guid.h" | |
| 16 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/threading/sequenced_worker_pool.h" | 19 #include "base/threading/sequenced_worker_pool.h" |
| 19 #include "chrome/browser/android/webapk/chrome_webapk_host.h" | 20 #include "chrome/browser/android/webapk/chrome_webapk_host.h" |
| 20 #include "chrome/browser/android/webapk/webapk_install_service.h" | 21 #include "chrome/browser/android/webapk/webapk_install_service.h" |
| 21 #include "chrome/browser/manifest/manifest_icon_downloader.h" | 22 #include "chrome/browser/manifest/manifest_icon_downloader.h" |
| 22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 25 #include "jni/ShortcutHelper_jni.h" | 26 #include "jni/ShortcutHelper_jni.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); | 126 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); |
| 126 | 127 |
| 127 Java_ShortcutHelper_addShortcut(env, java_id, java_url, java_user_title, | 128 Java_ShortcutHelper_addShortcut(env, java_id, java_url, java_user_title, |
| 128 java_bitmap, info.source); | 129 java_bitmap, info.source); |
| 129 } | 130 } |
| 130 | 131 |
| 131 } // anonymous namespace | 132 } // anonymous namespace |
| 132 | 133 |
| 133 // static | 134 // static |
| 134 void ShortcutHelper::AddToLauncherWithSkBitmap( | 135 void ShortcutHelper::AddToLauncherWithSkBitmap( |
| 135 content::BrowserContext* browser_context, | 136 content::WebContents* web_contents, |
| 136 const ShortcutInfo& info, | 137 const ShortcutInfo& info, |
| 137 const std::string& webapp_id, | 138 const SkBitmap& icon_bitmap) { |
| 138 const SkBitmap& icon_bitmap, | 139 std::string webapp_id = base::GenerateGUID(); |
| 139 const base::Closure& splash_image_callback) { | |
| 140 if (info.display == blink::WebDisplayModeStandalone || | 140 if (info.display == blink::WebDisplayModeStandalone || |
| 141 info.display == blink::WebDisplayModeFullscreen) { | 141 info.display == blink::WebDisplayModeFullscreen) { |
| 142 base::Closure splash_image_callback = | |
| 143 base::Bind(&ShortcutHelper::FetchSplashScreenImage, web_contents, | |
|
dominickn
2017/03/01 02:29:39
Nit: remove the local and pass the result of base:
| |
| 144 info.splash_image_url, info.ideal_splash_image_size_in_px, | |
| 145 info.minimum_splash_image_size_in_px, webapp_id); | |
| 146 | |
| 142 AddWebappWithSkBitmap(info, webapp_id, icon_bitmap, splash_image_callback); | 147 AddWebappWithSkBitmap(info, webapp_id, icon_bitmap, splash_image_callback); |
| 143 return; | 148 return; |
| 144 } | 149 } |
| 145 AddShortcutWithSkBitmap(info, webapp_id, icon_bitmap); | 150 AddShortcutWithSkBitmap(info, webapp_id, icon_bitmap); |
| 146 } | 151 } |
| 147 | 152 |
| 148 // static | 153 // static |
| 149 void ShortcutHelper::InstallWebApkWithSkBitmap( | 154 void ShortcutHelper::InstallWebApkWithSkBitmap( |
| 150 content::BrowserContext* browser_context, | 155 content::BrowserContext* browser_context, |
| 151 const ShortcutInfo& info, | 156 const ShortcutInfo& info, |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 | 360 |
| 356 ShortcutHelper::WebApkInfoCallback* webapk_list_callback = | 361 ShortcutHelper::WebApkInfoCallback* webapk_list_callback = |
| 357 reinterpret_cast<ShortcutHelper::WebApkInfoCallback*>(jcallback_pointer); | 362 reinterpret_cast<ShortcutHelper::WebApkInfoCallback*>(jcallback_pointer); |
| 358 webapk_list_callback->Run(webapk_list); | 363 webapk_list_callback->Run(webapk_list); |
| 359 delete webapk_list_callback; | 364 delete webapk_list_callback; |
| 360 } | 365 } |
| 361 | 366 |
| 362 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { | 367 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { |
| 363 return RegisterNativesImpl(env); | 368 return RegisterNativesImpl(env); |
| 364 } | 369 } |
| OLD | NEW |