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

Side by Side Diff: chrome/browser/android/ntp/ntp_snippets_bridge.cc

Issue 2507793002: [NTP] Propagate OfflineId from C++ for Downloads. (Closed)
Patch Set: rebase. Created 4 years, 1 month 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 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 ConvertUTF8ToJavaString(env, suggestion.id().id_within_category()), 74 ConvertUTF8ToJavaString(env, suggestion.id().id_within_category()),
75 ConvertUTF16ToJavaString(env, suggestion.title()), 75 ConvertUTF16ToJavaString(env, suggestion.title()),
76 ConvertUTF16ToJavaString(env, suggestion.publisher_name()), 76 ConvertUTF16ToJavaString(env, suggestion.publisher_name()),
77 ConvertUTF16ToJavaString(env, suggestion.snippet_text()), 77 ConvertUTF16ToJavaString(env, suggestion.snippet_text()),
78 ConvertUTF8ToJavaString(env, suggestion.url().spec()), 78 ConvertUTF8ToJavaString(env, suggestion.url().spec()),
79 ConvertUTF8ToJavaString(env, suggestion.amp_url().spec()), 79 ConvertUTF8ToJavaString(env, suggestion.amp_url().spec()),
80 suggestion.publish_date().ToJavaTime(), suggestion.score(), 80 suggestion.publish_date().ToJavaTime(), suggestion.score(),
81 static_cast<int>(info->card_layout())); 81 static_cast<int>(info->card_layout()));
82 if (suggestion.id().category().IsKnownCategory( 82 if (suggestion.id().category().IsKnownCategory(
83 KnownCategories::DOWNLOADS) && 83 KnownCategories::DOWNLOADS) &&
84 suggestion.download_suggestion_extra() != nullptr && 84 suggestion.download_suggestion_extra() != nullptr) {
85 suggestion.download_suggestion_extra()->is_download_asset) { 85 if (suggestion.download_suggestion_extra()->is_download_asset) {
86 Java_SnippetsBridge_setDownloadAssetDataForLastSuggestion( 86 Java_SnippetsBridge_setDownloadAssetDataForLastSuggestion(
87 env, result, 87 env, result,
88 ConvertUTF8ToJavaString( 88 ConvertUTF8ToJavaString(env, suggestion.download_suggestion_extra()
89 env, 89 ->target_file_path.value()),
90 suggestion.download_suggestion_extra()->target_file_path.value()), 90 ConvertUTF8ToJavaString(
91 ConvertUTF8ToJavaString( 91 env, suggestion.download_suggestion_extra()->mime_type));
92 env, suggestion.download_suggestion_extra()->mime_type)); 92 } else {
93 Java_SnippetsBridge_setDownloadOfflinePageDataForLastSuggestion(
94 env, result,
95 suggestion.download_suggestion_extra()->offline_page_id);
96 }
93 } 97 }
94 if (suggestion.id().category().IsKnownCategory( 98 if (suggestion.id().category().IsKnownCategory(
95 KnownCategories::RECENT_TABS) && 99 KnownCategories::RECENT_TABS) &&
96 suggestion.recent_tab_suggestion_extra() != nullptr) { 100 suggestion.recent_tab_suggestion_extra() != nullptr) {
97 Java_SnippetsBridge_setRecentTabDataForLastSuggestion( 101 Java_SnippetsBridge_setRecentTabDataForLastSuggestion(
98 env, result, 102 env, result,
99 ConvertUTF8ToJavaString( 103 ConvertUTF8ToJavaString(
100 env, suggestion.recent_tab_suggestion_extra()->tab_id), 104 env, suggestion.recent_tab_suggestion_extra()->tab_id),
101 ConvertUTF8ToJavaString( 105 suggestion.recent_tab_suggestion_extra()->offline_page_id);
102 env, suggestion.recent_tab_suggestion_extra()->offline_page_id));
103 } 106 }
104 } 107 }
105 108
106 return result; 109 return result;
107 } 110 }
108 111
109 } // namespace 112 } // namespace
110 113
111 static jlong Init(JNIEnv* env, 114 static jlong Init(JNIEnv* env,
112 const JavaParamRef<jobject>& obj, 115 const JavaParamRef<jobject>& obj,
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 459 }
457 460
458 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { 461 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) {
459 return content_suggestions_service_->category_factory()->FromIDValue(id); 462 return content_suggestions_service_->category_factory()->FromIDValue(id);
460 } 463 }
461 464
462 // static 465 // static
463 bool NTPSnippetsBridge::Register(JNIEnv* env) { 466 bool NTPSnippetsBridge::Register(JNIEnv* env) {
464 return RegisterNativesImpl(env); 467 return RegisterNativesImpl(env);
465 } 468 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698