OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/recently_closed_tabs_bridge.h" | 5 #include "chrome/browser/android/recently_closed_tabs_bridge.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "chrome/browser/android/tab_android.h" | 8 #include "chrome/browser/android/tab_android.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_android.h" | 10 #include "chrome/browser/profiles/profile_android.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 void AddTabToList(JNIEnv* env, | 24 void AddTabToList(JNIEnv* env, |
25 TabRestoreService::Entry* entry, | 25 TabRestoreService::Entry* entry, |
26 jobject jtabs_list) { | 26 jobject jtabs_list) { |
27 const TabRestoreService::Tab* tab = | 27 const TabRestoreService::Tab* tab = |
28 static_cast<TabRestoreService::Tab*>(entry); | 28 static_cast<TabRestoreService::Tab*>(entry); |
29 const sessions::SerializedNavigationEntry& current_navigation = | 29 const sessions::SerializedNavigationEntry& current_navigation = |
30 tab->navigations.at(tab->current_navigation_index); | 30 tab->navigations.at(tab->current_navigation_index); |
31 Java_RecentlyClosedBridge_pushTab( | 31 Java_RecentlyClosedBridge_pushTab( |
32 env, jtabs_list, entry->id, | 32 env, jtabs_list, entry->id, |
33 ConvertUTF16ToJavaString(env, current_navigation.title()).Release(), | 33 ConvertUTF16ToJavaString(env, current_navigation.title()).obj(), |
34 ConvertUTF8ToJavaString(env, current_navigation.virtual_url().spec()) | 34 ConvertUTF8ToJavaString(env, current_navigation.virtual_url().spec()) |
35 .Release()); | 35 .obj()); |
36 } | 36 } |
37 | 37 |
38 void AddTabsToList(JNIEnv* env, | 38 void AddTabsToList(JNIEnv* env, |
39 const TabRestoreService::Entries& entries, | 39 const TabRestoreService::Entries& entries, |
40 jobject jtabs_list, | 40 jobject jtabs_list, |
41 int max_tab_count) { | 41 int max_tab_count) { |
42 int added_count = 0; | 42 int added_count = 0; |
43 for (TabRestoreService::Entries::const_iterator it = entries.begin(); | 43 for (TabRestoreService::Entries::const_iterator it = entries.begin(); |
44 it != entries.end() && added_count < max_tab_count; ++it) { | 44 it != entries.end() && added_count < max_tab_count; ++it) { |
45 TabRestoreService::Entry* entry = *it; | 45 TabRestoreService::Entry* entry = *it; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) { | 160 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) { |
161 RecentlyClosedTabsBridge* bridge = new RecentlyClosedTabsBridge( | 161 RecentlyClosedTabsBridge* bridge = new RecentlyClosedTabsBridge( |
162 ProfileAndroid::FromProfileAndroid(jprofile)); | 162 ProfileAndroid::FromProfileAndroid(jprofile)); |
163 return reinterpret_cast<intptr_t>(bridge); | 163 return reinterpret_cast<intptr_t>(bridge); |
164 } | 164 } |
165 | 165 |
166 // static | 166 // static |
167 bool RecentlyClosedTabsBridge::Register(JNIEnv* env) { | 167 bool RecentlyClosedTabsBridge::Register(JNIEnv* env) { |
168 return RegisterNativesImpl(env); | 168 return RegisterNativesImpl(env); |
169 } | 169 } |
OLD | NEW |