| 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 void NTPSnippetsBridge::OnMoreButtonClicked(JNIEnv* env, | 389 void NTPSnippetsBridge::OnMoreButtonClicked(JNIEnv* env, |
| 390 const JavaParamRef<jobject>& obj, | 390 const JavaParamRef<jobject>& obj, |
| 391 jint j_category_id, | 391 jint j_category_id, |
| 392 jint position) { | 392 jint position) { |
| 393 ntp_snippets::metrics::OnMoreButtonClicked( | 393 ntp_snippets::metrics::OnMoreButtonClicked( |
| 394 Category::FromIDValue(j_category_id), position); | 394 Category::FromIDValue(j_category_id), position); |
| 395 content_suggestions_service_->user_classifier()->OnEvent( | 395 content_suggestions_service_->user_classifier()->OnEvent( |
| 396 ntp_snippets::UserClassifier::Metric::SUGGESTIONS_USED); | 396 ntp_snippets::UserClassifier::Metric::SUGGESTIONS_USED); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void NTPSnippetsBridge::OnNTPInitialized( |
| 400 JNIEnv* env, |
| 401 const base::android::JavaParamRef<jobject>& obj) { |
| 402 content_suggestions_service_->remote_suggestions_scheduler()->OnNTPOpened(); |
| 403 } |
| 404 |
| 399 NTPSnippetsBridge::~NTPSnippetsBridge() {} | 405 NTPSnippetsBridge::~NTPSnippetsBridge() {} |
| 400 | 406 |
| 401 void NTPSnippetsBridge::OnNewSuggestions(Category category) { | 407 void NTPSnippetsBridge::OnNewSuggestions(Category category) { |
| 402 if (observer_.is_null()) { | 408 if (observer_.is_null()) { |
| 403 return; | 409 return; |
| 404 } | 410 } |
| 405 | 411 |
| 406 JNIEnv* env = base::android::AttachCurrentThread(); | 412 JNIEnv* env = base::android::AttachCurrentThread(); |
| 407 Java_SnippetsBridge_onNewSuggestions(env, observer_, | 413 Java_SnippetsBridge_onNewSuggestions(env, observer_, |
| 408 static_cast<int>(category.id())); | 414 static_cast<int>(category.id())); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 JNIEnv* env = AttachCurrentThread(); | 469 JNIEnv* env = AttachCurrentThread(); |
| 464 Java_SnippetsBridge_onMoreSuggestions( | 470 Java_SnippetsBridge_onMoreSuggestions( |
| 465 env, observer_, category.id(), | 471 env, observer_, category.id(), |
| 466 ToJavaSuggestionList(env, category, suggestions)); | 472 ToJavaSuggestionList(env, category, suggestions)); |
| 467 } | 473 } |
| 468 | 474 |
| 469 // static | 475 // static |
| 470 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 476 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 471 return RegisterNativesImpl(env); | 477 return RegisterNativesImpl(env); |
| 472 } | 478 } |
| OLD | NEW |