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

Side by Side Diff: chrome/browser/android/shortcut_helper.cc

Issue 2199413003: Make WebAPK use "start URL longest path" as the scope if the scope is missing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_builder_impl2_scope Created 4 years, 4 months 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 unified diff | Download patch
OLDNEW
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 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 276 }
277 277
278 // static 278 // static
279 bool ShortcutHelper::IsWebApkInstalled(const GURL& url) { 279 bool ShortcutHelper::IsWebApkInstalled(const GURL& url) {
280 JNIEnv* env = base::android::AttachCurrentThread(); 280 JNIEnv* env = base::android::AttachCurrentThread();
281 ScopedJavaLocalRef<jstring> java_url = 281 ScopedJavaLocalRef<jstring> java_url =
282 base::android::ConvertUTF8ToJavaString(env, url.spec()); 282 base::android::ConvertUTF8ToJavaString(env, url.spec());
283 return Java_ShortcutHelper_isWebApkInstalled(env, java_url.obj()); 283 return Java_ShortcutHelper_isWebApkInstalled(env, java_url.obj());
284 } 284 }
285 285
286 GURL ShortcutHelper::GetScopeFromURL(const GURL& url) {
287 JNIEnv* env = base::android::AttachCurrentThread();
288 ScopedJavaLocalRef<jstring> java_url =
289 base::android::ConvertUTF8ToJavaString(env, url.spec());
290 ScopedJavaLocalRef<jstring> java_scope_url =
291 Java_ShortcutHelper_getScopeFromUrl(env, java_url.obj());
292 return GURL(base::android::ConvertJavaStringToUTF16(env, java_scope_url));
293 }
294
286 // Callback used by Java when the shortcut has been created. 295 // Callback used by Java when the shortcut has been created.
287 // |splash_image_callback| is a pointer to a base::Closure allocated in 296 // |splash_image_callback| is a pointer to a base::Closure allocated in
288 // AddShortcutInBackgroundWithSkBitmap, so reinterpret_cast it back and run it. 297 // AddShortcutInBackgroundWithSkBitmap, so reinterpret_cast it back and run it.
289 // 298 //
290 // This callback should only ever be called when the shortcut was for a 299 // This callback should only ever be called when the shortcut was for a
291 // webapp-capable site; otherwise, |splash_image_callback| will have never been 300 // webapp-capable site; otherwise, |splash_image_callback| will have never been
292 // allocated and doesn't need to be run or deleted. 301 // allocated and doesn't need to be run or deleted.
293 void OnWebappDataStored(JNIEnv* env, 302 void OnWebappDataStored(JNIEnv* env,
294 const JavaParamRef<jclass>& clazz, 303 const JavaParamRef<jclass>& clazz,
295 jlong jsplash_image_callback) { 304 jlong jsplash_image_callback) {
296 DCHECK(jsplash_image_callback); 305 DCHECK(jsplash_image_callback);
297 base::Closure* splash_image_callback = 306 base::Closure* splash_image_callback =
298 reinterpret_cast<base::Closure*>(jsplash_image_callback); 307 reinterpret_cast<base::Closure*>(jsplash_image_callback);
299 splash_image_callback->Run(); 308 splash_image_callback->Run();
300 delete splash_image_callback; 309 delete splash_image_callback;
301 } 310 }
302 311
303 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { 312 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
304 return RegisterNativesImpl(env); 313 return RegisterNativesImpl(env);
305 } 314 }
OLDNEW
« no previous file with comments | « chrome/browser/android/shortcut_helper.h ('k') | chrome/browser/android/webapk/webapk_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698