| 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 | 8 |
| 9 #include "base/android/callback_android.h" | 9 #include "base/android/callback_android.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 content_suggestions_service->ntp_snippets_service(); | 85 content_suggestions_service->ntp_snippets_service(); |
| 86 | 86 |
| 87 // Can be null if the feature has been disabled but the scheduler has not been | 87 // Can be null if the feature has been disabled but the scheduler has not been |
| 88 // unregistered yet. The next start should unregister it. | 88 // unregistered yet. The next start should unregister it. |
| 89 if (!service) | 89 if (!service) |
| 90 return; | 90 return; |
| 91 | 91 |
| 92 service->FetchSnippets(j_force_request); | 92 service->FetchSnippets(j_force_request); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Reschedules the fetching of snippets. Used to support different fetching | 95 // Reschedules the fetching of snippets. |
| 96 // intervals for different times of day. | |
| 97 static void RescheduleFetching(JNIEnv* env, | 96 static void RescheduleFetching(JNIEnv* env, |
| 98 const JavaParamRef<jclass>& caller) { | 97 const JavaParamRef<jclass>& caller) { |
| 99 Profile* profile = ProfileManager::GetLastUsedProfile(); | 98 Profile* profile = ProfileManager::GetLastUsedProfile(); |
| 100 // Temporary check while investigating crbug.com/647920. | 99 // Temporary check while investigating crbug.com/647920. |
| 101 CHECK(profile); | 100 CHECK(profile); |
| 102 | 101 |
| 103 ntp_snippets::ContentSuggestionsService* content_suggestions_service = | 102 ntp_snippets::ContentSuggestionsService* content_suggestions_service = |
| 104 ContentSuggestionsServiceFactory::GetForProfile(profile); | 103 ContentSuggestionsServiceFactory::GetForProfile(profile); |
| 105 | 104 |
| 106 // Can maybe be null in some cases? (Incognito profile?) crbug.com/647920 | 105 // Can maybe be null in some cases? (Incognito profile?) crbug.com/647920 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 382 } |
| 384 | 383 |
| 385 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { | 384 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { |
| 386 return content_suggestions_service_->category_factory()->FromIDValue(id); | 385 return content_suggestions_service_->category_factory()->FromIDValue(id); |
| 387 } | 386 } |
| 388 | 387 |
| 389 // static | 388 // static |
| 390 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 389 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 391 return RegisterNativesImpl(env); | 390 return RegisterNativesImpl(env); |
| 392 } | 391 } |
| OLD | NEW |