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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 GetRemoteSuggestionsScheduler(); | 403 GetRemoteSuggestionsScheduler(); |
404 // Can be null if the feature has been disabled but the scheduler has not been | 404 // Can be null if the feature has been disabled but the scheduler has not been |
405 // unregistered yet. The next start should unregister it. | 405 // unregistered yet. The next start should unregister it. |
406 if (!scheduler) { | 406 if (!scheduler) { |
407 return; | 407 return; |
408 } | 408 } |
409 | 409 |
410 scheduler->OnNTPOpened(); | 410 scheduler->OnNTPOpened(); |
411 } | 411 } |
412 | 412 |
| 413 void NTPSnippetsBridge::OnColdStart( |
| 414 JNIEnv* env, |
| 415 const base::android::JavaParamRef<jobject>& obj) { |
| 416 ntp_snippets::RemoteSuggestionsScheduler* scheduler = |
| 417 GetRemoteSuggestionsScheduler(); |
| 418 // TODO(fhorschig): Remove guard when https://crbug.com/678556 is resolved. |
| 419 if (!scheduler) { |
| 420 return; |
| 421 } |
| 422 scheduler->OnBrowserColdStart(); |
| 423 } |
| 424 |
| 425 void NTPSnippetsBridge::OnActivityWarmResumed( |
| 426 JNIEnv* env, |
| 427 const base::android::JavaParamRef<jobject>& obj) { |
| 428 ntp_snippets::RemoteSuggestionsScheduler* scheduler = |
| 429 GetRemoteSuggestionsScheduler(); |
| 430 // TODO(fhorschig): Remove guard when https://crbug.com/678556 is resolved. |
| 431 if (!scheduler) { |
| 432 return; |
| 433 } |
| 434 scheduler->OnBrowserForegrounded(); |
| 435 } |
| 436 |
413 NTPSnippetsBridge::~NTPSnippetsBridge() {} | 437 NTPSnippetsBridge::~NTPSnippetsBridge() {} |
414 | 438 |
415 void NTPSnippetsBridge::OnNewSuggestions(Category category) { | 439 void NTPSnippetsBridge::OnNewSuggestions(Category category) { |
416 if (observer_.is_null()) { | 440 if (observer_.is_null()) { |
417 return; | 441 return; |
418 } | 442 } |
419 | 443 |
420 JNIEnv* env = base::android::AttachCurrentThread(); | 444 JNIEnv* env = base::android::AttachCurrentThread(); |
421 Java_SnippetsBridge_onNewSuggestions(env, observer_, | 445 Java_SnippetsBridge_onNewSuggestions(env, observer_, |
422 static_cast<int>(category.id())); | 446 static_cast<int>(category.id())); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 JNIEnv* env = AttachCurrentThread(); | 501 JNIEnv* env = AttachCurrentThread(); |
478 Java_SnippetsBridge_onMoreSuggestions( | 502 Java_SnippetsBridge_onMoreSuggestions( |
479 env, observer_, category.id(), | 503 env, observer_, category.id(), |
480 ToJavaSuggestionList(env, category, suggestions)); | 504 ToJavaSuggestionList(env, category, suggestions)); |
481 } | 505 } |
482 | 506 |
483 // static | 507 // static |
484 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 508 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
485 return RegisterNativesImpl(env); | 509 return RegisterNativesImpl(env); |
486 } | 510 } |
OLD | NEW |