OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ntp/ntp_snippets_bridge.h" | 5 #include "chrome/browser/android/ntp/ntp_snippets_bridge.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 Java_SnippetsBridge_createSuggestionList(env); | 57 Java_SnippetsBridge_createSuggestionList(env); |
58 for (const ContentSuggestion& suggestion : suggestions) { | 58 for (const ContentSuggestion& suggestion : suggestions) { |
59 ScopedJavaLocalRef<jobject> java_suggestion = | 59 ScopedJavaLocalRef<jobject> java_suggestion = |
60 Java_SnippetsBridge_addSuggestion( | 60 Java_SnippetsBridge_addSuggestion( |
61 env, result, category.id(), | 61 env, result, category.id(), |
62 ConvertUTF8ToJavaString(env, suggestion.id().id_within_category()), | 62 ConvertUTF8ToJavaString(env, suggestion.id().id_within_category()), |
63 ConvertUTF16ToJavaString(env, suggestion.title()), | 63 ConvertUTF16ToJavaString(env, suggestion.title()), |
64 ConvertUTF16ToJavaString(env, suggestion.publisher_name()), | 64 ConvertUTF16ToJavaString(env, suggestion.publisher_name()), |
65 ConvertUTF16ToJavaString(env, suggestion.snippet_text()), | 65 ConvertUTF16ToJavaString(env, suggestion.snippet_text()), |
66 ConvertUTF8ToJavaString(env, suggestion.url().spec()), | 66 ConvertUTF8ToJavaString(env, suggestion.url().spec()), |
67 ConvertUTF8ToJavaString(env, suggestion.amp_url().spec()), | |
68 suggestion.publish_date().ToJavaTime(), suggestion.score()); | 67 suggestion.publish_date().ToJavaTime(), suggestion.score()); |
69 if (suggestion.id().category().IsKnownCategory( | 68 if (suggestion.id().category().IsKnownCategory( |
70 KnownCategories::DOWNLOADS) && | 69 KnownCategories::DOWNLOADS) && |
71 suggestion.download_suggestion_extra() != nullptr) { | 70 suggestion.download_suggestion_extra() != nullptr) { |
72 if (suggestion.download_suggestion_extra()->is_download_asset) { | 71 if (suggestion.download_suggestion_extra()->is_download_asset) { |
73 Java_SnippetsBridge_setAssetDownloadDataForSuggestion( | 72 Java_SnippetsBridge_setAssetDownloadDataForSuggestion( |
74 env, java_suggestion, | 73 env, java_suggestion, |
75 ConvertUTF8ToJavaString(env, suggestion.download_suggestion_extra() | 74 ConvertUTF8ToJavaString(env, suggestion.download_suggestion_extra() |
76 ->target_file_path.value()), | 75 ->target_file_path.value()), |
77 ConvertUTF8ToJavaString( | 76 ConvertUTF8ToJavaString( |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 JNIEnv* env = AttachCurrentThread(); | 480 JNIEnv* env = AttachCurrentThread(); |
482 Java_SnippetsBridge_onMoreSuggestions( | 481 Java_SnippetsBridge_onMoreSuggestions( |
483 env, observer_, category.id(), | 482 env, observer_, category.id(), |
484 ToJavaSuggestionList(env, category, suggestions)); | 483 ToJavaSuggestionList(env, category, suggestions)); |
485 } | 484 } |
486 | 485 |
487 // static | 486 // static |
488 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 487 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
489 return RegisterNativesImpl(env); | 488 return RegisterNativesImpl(env); |
490 } | 489 } |
OLD | NEW |