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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 GetRemoteSuggestionsScheduler(); | 401 GetRemoteSuggestionsScheduler(); |
402 // Can be null if the feature has been disabled but the scheduler has not been | 402 // Can be null if the feature has been disabled but the scheduler has not been |
403 // unregistered yet. The next start should unregister it. | 403 // unregistered yet. The next start should unregister it. |
404 if (!scheduler) { | 404 if (!scheduler) { |
405 return; | 405 return; |
406 } | 406 } |
407 | 407 |
408 scheduler->OnNTPOpened(); | 408 scheduler->OnNTPOpened(); |
409 } | 409 } |
410 | 410 |
| 411 void NTPSnippetsBridge::OnColdStart( |
| 412 JNIEnv* env, |
| 413 const base::android::JavaParamRef<jobject>& obj) { |
| 414 ntp_snippets::RemoteSuggestionsScheduler* scheduler = |
| 415 GetRemoteSuggestionsScheduler(); |
| 416 // TODO(fhorschig): Remove guard when https://crbug.com/678556 is resolved. |
| 417 if (!scheduler) { |
| 418 return; |
| 419 } |
| 420 scheduler->OnBrowserColdStart(); |
| 421 } |
| 422 |
| 423 void NTPSnippetsBridge::OnActivityWarmResumed( |
| 424 JNIEnv* env, |
| 425 const base::android::JavaParamRef<jobject>& obj) { |
| 426 ntp_snippets::RemoteSuggestionsScheduler* scheduler = |
| 427 GetRemoteSuggestionsScheduler(); |
| 428 // TODO(fhorschig): Remove guard when https://crbug.com/678556 is resolved. |
| 429 if (!scheduler) { |
| 430 return; |
| 431 } |
| 432 scheduler->OnBrowserForegrounded(); |
| 433 } |
| 434 |
411 NTPSnippetsBridge::~NTPSnippetsBridge() {} | 435 NTPSnippetsBridge::~NTPSnippetsBridge() {} |
412 | 436 |
413 void NTPSnippetsBridge::OnNewSuggestions(Category category) { | 437 void NTPSnippetsBridge::OnNewSuggestions(Category category) { |
414 JNIEnv* env = base::android::AttachCurrentThread(); | 438 JNIEnv* env = base::android::AttachCurrentThread(); |
415 Java_SnippetsBridge_onNewSuggestions(env, bridge_, | 439 Java_SnippetsBridge_onNewSuggestions(env, bridge_, |
416 static_cast<int>(category.id())); | 440 static_cast<int>(category.id())); |
417 } | 441 } |
418 | 442 |
419 void NTPSnippetsBridge::OnCategoryStatusChanged(Category category, | 443 void NTPSnippetsBridge::OnCategoryStatusChanged(Category category, |
420 CategoryStatus new_status) { | 444 CategoryStatus new_status) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 JNIEnv* env = AttachCurrentThread(); | 483 JNIEnv* env = AttachCurrentThread(); |
460 Java_SnippetsBridge_onMoreSuggestions( | 484 Java_SnippetsBridge_onMoreSuggestions( |
461 env, bridge_, category.id(), | 485 env, bridge_, category.id(), |
462 ToJavaSuggestionList(env, category, suggestions)); | 486 ToJavaSuggestionList(env, category, suggestions)); |
463 } | 487 } |
464 | 488 |
465 // static | 489 // static |
466 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 490 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
467 return RegisterNativesImpl(env); | 491 return RegisterNativesImpl(env); |
468 } | 492 } |
OLD | NEW |