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

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 and treib@ comments. 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 // TODO(vitaliii): Pass |offline_page_id| as a numeric variable.
Bernhard Bauer 2016/11/16 17:04:02 Any particular reason you're not doing that now?
vitaliii 2016/11/16 17:28:10 Neither Mark nor I knew whether this was possible
94 Java_SnippetsBridge_setDownloadOfflinePageDataForLastSuggestion(
Bernhard Bauer 2016/11/16 17:04:02 I realize this is just following existing code, bu
vitaliii 2016/11/16 17:28:10 I added a TODO (as per your following comment).
95 env, result,
96 ConvertUTF8ToJavaString(
97 env, suggestion.download_suggestion_extra()->offline_page_id));
98 }
93 } 99 }
94 if (suggestion.id().category().IsKnownCategory( 100 if (suggestion.id().category().IsKnownCategory(
95 KnownCategories::RECENT_TABS) && 101 KnownCategories::RECENT_TABS) &&
96 suggestion.recent_tab_suggestion_extra() != nullptr) { 102 suggestion.recent_tab_suggestion_extra() != nullptr) {
97 Java_SnippetsBridge_setRecentTabDataForLastSuggestion( 103 Java_SnippetsBridge_setRecentTabDataForLastSuggestion(
98 env, result, 104 env, result,
99 ConvertUTF8ToJavaString( 105 ConvertUTF8ToJavaString(
100 env, suggestion.recent_tab_suggestion_extra()->tab_id), 106 env, suggestion.recent_tab_suggestion_extra()->tab_id),
101 ConvertUTF8ToJavaString( 107 ConvertUTF8ToJavaString(
102 env, suggestion.recent_tab_suggestion_extra()->offline_page_id)); 108 env, suggestion.recent_tab_suggestion_extra()->offline_page_id));
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 462 }
457 463
458 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { 464 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) {
459 return content_suggestions_service_->category_factory()->FromIDValue(id); 465 return content_suggestions_service_->category_factory()->FromIDValue(id);
460 } 466 }
461 467
462 // static 468 // static
463 bool NTPSnippetsBridge::Register(JNIEnv* env) { 469 bool NTPSnippetsBridge::Register(JNIEnv* env) {
464 return RegisterNativesImpl(env); 470 return RegisterNativesImpl(env);
465 } 471 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698