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

Side by Side Diff: chrome/browser/android/data_usage/data_use_tab_ui_manager_android.cc

Issue 1443683002: Notify DataUseTabModel of navigations and tab closures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/data_usage/data_use_tab_ui_manager_android.h" 5 #include "chrome/browser/android/data_usage/data_use_tab_ui_manager_android.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
11 #include "chrome/browser/android/data_usage/data_use_ui_tab_model.h" 11 #include "chrome/browser/android/data_usage/data_use_ui_tab_model.h"
12 #include "chrome/browser/android/data_usage/data_use_ui_tab_model_factory.h" 12 #include "chrome/browser/android/data_usage/data_use_ui_tab_model_factory.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_android.h" 14 #include "chrome/browser/profiles/profile_android.h"
15 #include "components/sessions/core/session_id.h"
15 #include "jni/DataUseTabUIManager_jni.h" 16 #include "jni/DataUseTabUIManager_jni.h"
16 17
17 // static 18 // static
18 jboolean CheckDataUseTrackingStarted(JNIEnv* env, 19 jboolean CheckDataUseTrackingStarted(JNIEnv* env,
19 const JavaParamRef<jclass>& clazz, 20 const JavaParamRef<jclass>& clazz,
20 jint tab_id, 21 jint tab_id,
21 const JavaParamRef<jobject>& jprofile) { 22 const JavaParamRef<jobject>& jprofile) {
22 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); 23 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile);
23 chrome::android::DataUseUITabModel* data_use_ui_tab_model = 24 chrome::android::DataUseUITabModel* data_use_ui_tab_model =
24 chrome::android::DataUseUITabModelFactory::GetForBrowserContext(profile); 25 chrome::android::DataUseUITabModelFactory::GetForBrowserContext(profile);
25 if (data_use_ui_tab_model) 26 if (data_use_ui_tab_model)
26 return data_use_ui_tab_model->HasDataUseTrackingStarted(tab_id); 27 return data_use_ui_tab_model->HasDataUseTrackingStarted(
28 static_cast<SessionID::id_type>(tab_id));
sclittle 2015/11/30 22:33:38 nit: Could you DCHECK that |tab_id| is a valid >=0
tbansal1 2015/11/30 22:59:09 Done.
27 return false; 29 return false;
28 } 30 }
29 31
30 // static 32 // static
31 jboolean CheckDataUseTrackingEnded(JNIEnv* env, 33 jboolean CheckDataUseTrackingEnded(JNIEnv* env,
32 const JavaParamRef<jclass>& clazz, 34 const JavaParamRef<jclass>& clazz,
33 jint tab_id, 35 jint tab_id,
34 const JavaParamRef<jobject>& jprofile) { 36 const JavaParamRef<jobject>& jprofile) {
35 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); 37 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile);
36 chrome::android::DataUseUITabModel* data_use_ui_tab_model = 38 chrome::android::DataUseUITabModel* data_use_ui_tab_model =
37 chrome::android::DataUseUITabModelFactory::GetForBrowserContext(profile); 39 chrome::android::DataUseUITabModelFactory::GetForBrowserContext(profile);
38 if (data_use_ui_tab_model) 40 if (data_use_ui_tab_model)
39 return data_use_ui_tab_model->HasDataUseTrackingEnded(tab_id); 41 return data_use_ui_tab_model->HasDataUseTrackingEnded(
42 static_cast<SessionID::id_type>(tab_id));
40 return false; 43 return false;
41 } 44 }
42 45
43 // static 46 // static
44 void OnCustomTabInitialNavigation(JNIEnv* env, 47 void OnCustomTabInitialNavigation(JNIEnv* env,
45 const JavaParamRef<jclass>& clazz, 48 const JavaParamRef<jclass>& clazz,
46 jint tab_id, 49 jint tab_id,
47 const JavaParamRef<jstring>& url, 50 const JavaParamRef<jstring>& url,
48 const JavaParamRef<jstring>& package_name, 51 const JavaParamRef<jstring>& package_name,
49 const JavaParamRef<jobject>& jprofile) { 52 const JavaParamRef<jobject>& jprofile) {
50 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); 53 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile);
51 chrome::android::DataUseUITabModel* data_use_ui_tab_model = 54 chrome::android::DataUseUITabModel* data_use_ui_tab_model =
52 chrome::android::DataUseUITabModelFactory::GetForBrowserContext(profile); 55 chrome::android::DataUseUITabModelFactory::GetForBrowserContext(profile);
53 if (data_use_ui_tab_model) { 56 if (data_use_ui_tab_model) {
54 data_use_ui_tab_model->ReportCustomTabInitialNavigation( 57 data_use_ui_tab_model->ReportCustomTabInitialNavigation(
55 tab_id, ConvertJavaStringToUTF8(env, url), 58 static_cast<SessionID::id_type>(tab_id),
59 ConvertJavaStringToUTF8(env, url),
56 ConvertJavaStringToUTF8(env, package_name)); 60 ConvertJavaStringToUTF8(env, package_name));
57 } 61 }
58 } 62 }
59 63
60 bool RegisterDataUseTabUIManager(JNIEnv* env) { 64 bool RegisterDataUseTabUIManager(JNIEnv* env) {
61 return RegisterNativesImpl(env); 65 return RegisterNativesImpl(env);
62 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698